OUTPUT
output = IsoDoc::Iso::WordConvert.new({}).convert("test", input, true)
expect(xmlpp(Nokogiri::XML(output)
.at("//div[@class = 'WordSection3']").to_xml))
.to be_equivalent_to xmlpp(word)
end
it "deals with foreword and intro" do
input = <<~INPUT
30Foreword
OUTPUT
FileUtils.rm_f "test.doc"
IsoDoc::Iso::WordConvert.new({}).convert("test", input, false)
expect(File.exist?("test.doc")).to be true
output = File.read("test.doc", encoding: "UTF-8")
.sub(/^.*.*$/m, "")
doc = Nokogiri::XML(output)
.xpath("//xmlns:p[@class = 'MsoToc1']").each(&:remove)
.at("//xmlns:div[@class = 'WordSection2']")
expect(xmlpp(doc.to_xml))
.to be_equivalent_to xmlpp(word)
end
it "formats references" do
input = <<~INPUT
50Normative References
The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.
ALUFFI, Paolo, ed. (2022). Facets of Algebraic Geometry: A Collection in Honor of William Fulton's 80th Birthday, 1st edition. Cambridge, UK: CUP.ISO/IEC 712-3:2022
INPUT
word = <<~OUTPUT
Normative References
The following documents are referred to in the text in such a way that
some or all of their content constitutes requirements of this document.
For dated references, only the edition cited applies. For undated
references, the latest edition of the referenced document (including any
amendments) applies.
ISO/IEC712-3:2022, ALUFFI, Paolo, ed. (2022).
Facets of Algebraic Geometry: A Collection in Honor of William
Fulton's 80th Birthday
, 1st edition. Cambridge, UK: CUP.
OUTPUT
FileUtils.rm_f "test.doc"
IsoDoc::Iso::WordConvert.new({}).convert("test", input, false)
expect(File.exist?("test.doc")).to be true
output = File.read("test.doc", encoding: "UTF-8")
.sub(/^.*.*$/m, "")
doc = Nokogiri::XML(output)
.at("//xmlns:div[@class = 'WordSection3']")
expect(xmlpp(doc.to_xml))
.to be_equivalent_to xmlpp(word)
end
it "formats tt" do
input = <<~INPUT
50
A BCDEFGHI
A BCDE
A BCDE
INPUT
word = <<~OUTPUT
Contents
Foreword
A
BC
D
E
F
G
H
I
A
B
C
D
E
A
B
C
D
E
OUTPUT
FileUtils.rm_f "test.doc"
IsoDoc::Iso::WordConvert.new({}).convert("test", input, false)
expect(File.exist?("test.doc")).to be true
output = File.read("test.doc", encoding: "UTF-8")
.sub(/^.*.*$/m, "")
doc = Nokogiri::XML(output)
.xpath("//xmlns:p[@class = 'MsoToc1']").each(&:remove)
.at("//xmlns:div[@class = 'WordSection2']")
expect(xmlpp(doc.to_xml))
.to be_equivalent_to xmlpp(word)
end
it "deals with lists" do
input = <<~INPUT
50
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
A
B
B1
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
INPUT
word = <<~OUTPUT
1
a)
A
b)
B
1)
C
2)
D
i)
E
ii)
F
A)
G
B)
H
I)
I
II)
J
a)
K
b)
L
c)
M
III)
N
C)
O
iii)
P
3)
Q
c)
R
—
A
—
B
—
B1
—
C
—
D
—
E
—
F
—
G
—
H
—
I
—
J
—
K
—
L
—
M
—
N
—
O
—
P
—
Q
—
R
OUTPUT
FileUtils.rm_f "test.doc"
presxml = IsoDoc::Iso::PresentationXMLConvert.new({})
.convert("test", input, true)
IsoDoc::Iso::WordConvert.new({}).convert("test", presxml, false)
expect(File.exist?("test.doc")).to be true
output = File.read("test.doc", encoding: "UTF-8")
.sub(/^.*.*$/m, "")
expect(xmlpp(Nokogiri::XML(output)
.at("//xmlns:div[@class = 'WordSection3']").to_xml))
.to be_equivalent_to xmlpp(word)
end
it "deals with lists and paragraphs" do
input = <<~INPUT
50
ISO and IEC maintain terminological databases for use in
standardization at the following addresses:
ISO Online browsing platform: available at
IEC Electropedia: available at
INPUT
word = <<~OUTPUT
1
ISO and IEC maintain terminological databases for use in standardization
at the following addresses:
OUTPUT
FileUtils.rm_f "test.doc"
presxml = IsoDoc::Iso::PresentationXMLConvert.new({})
.convert("test", input, true)
IsoDoc::Iso::WordConvert.new({}).convert("test", presxml, false)
expect(File.exist?("test.doc")).to be true
output = File.read("test.doc", encoding: "UTF-8")
.sub(/^.*.*$/m, "")
expect(xmlpp(Nokogiri::XML(output)
.at("//xmlns:div[@class = 'WordSection3']").to_xml))
.to be_equivalent_to xmlpp(word)
end
it "deals with ordered list start" do
input = <<~INPUT
50
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
INPUT
word = <<~OUTPUT
1
c)
A
d)
B
3)
C
4)
D
iii)
E
iv)
F
C)
G
D)
H
III)
I
IV)
J
c)
K
d)
L
e)
M
V)
N
E)
O
v)
P
5)
Q
e)
R
OUTPUT
FileUtils.rm_f "test.doc"
presxml = IsoDoc::Iso::PresentationXMLConvert.new({})
.convert("test", input, true)
IsoDoc::Iso::WordConvert.new({}).convert("test", presxml, false)
expect(File.exist?("test.doc")).to be true
output = File.read("test.doc", encoding: "UTF-8")
.sub(/^.*.*$/m, "")
expect(xmlpp(Nokogiri::XML(output)
.at("//xmlns:div[@class = 'WordSection3']").to_xml))
.to be_equivalent_to xmlpp(word)
end
it "deals with tables" do
input = <<~INPUT
50
Table1
A
B
C
D
E
F
INPUT
word = <<~WORD
Table1
A
B
C
D
E
F
WORD
FileUtils.rm_f "test.doc"
IsoDoc::Iso::WordConvert.new({}).convert("test", input, false)
expect(File.exist?("test.doc")).to be true
output = File.read("test.doc", encoding: "UTF-8")
.sub(/^.*.*$/m, "")
expect(xmlpp(Nokogiri::XML(output)
.at("//xmlns:div[@class = 'WordSection3']").to_xml))
.to be_equivalent_to xmlpp(word)
end
it "deals with figures" do
input = <<~INPUT
50
INPUT
word = <<~WORD
FIGURENOTE
Note
Example
Table1
WORD
FileUtils.rm_f "test.doc"
IsoDoc::Iso::WordConvert.new({}).convert("test", input, false)
expect(File.exist?("test.doc")).to be true
output = File.read("test.doc", encoding: "UTF-8")
.sub(/^.*.*$/m, "")
expect(strip_guid(xmlpp(Nokogiri::XML(output)
.at("//xmlns:div[@class = 'WordSection3']").to_xml)))
.to be_equivalent_to xmlpp(word)
end
it "deals with examples" do
input = <<~INPUT
50EXAMPLE
First example
Second example
Code
Continuation
INPUT
word = <<~WORD
EXAMPLE
First example
Second example
Code
Continuation
WORD
FileUtils.rm_f "test.doc"
IsoDoc::Iso::WordConvert.new({}).convert("test", input, false)
expect(File.exist?("test.doc")).to be true
output = File.read("test.doc", encoding: "UTF-8")
.sub(/^.*.*$/m, "")
expect(strip_guid(xmlpp(Nokogiri::XML(output)
.at("//xmlns:div[@class = 'WordSection3']").to_xml)))
.to be_equivalent_to xmlpp(word)
end
it "deals with notes" do
input = <<~INPUT
50NOTE
First example
Second example
Code
Continuation
INPUT
word = <<~WORD
NOTE
First example
Second example
Code
Continuation
WORD
FileUtils.rm_f "test.doc"
IsoDoc::Iso::WordConvert.new({}).convert("test", input, false)
expect(File.exist?("test.doc")).to be true
output = File.read("test.doc", encoding: "UTF-8")
.sub(/^.*.*$/m, "")
expect(strip_guid(xmlpp(Nokogiri::XML(output)
.at("//xmlns:div[@class = 'WordSection3']").to_xml)))
.to be_equivalent_to xmlpp(word)
end
it "deals with unordered lists embedded within notes and examples" do
input = <<~INPUT
50
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
INPUT
word = <<~WORD
1
NOTE
—
A
—
B
—
C
—
D
—
E
—
F
—
G
—
H
—
I
—
J
—
K
—
L
—
M
—
N
—
O
—
P
—
Q
—
R
WORD
FileUtils.rm_f "test.doc"
presxml = IsoDoc::Iso::PresentationXMLConvert.new({})
.convert("test", input, true)
IsoDoc::Iso::WordConvert.new({}).convert("test", presxml, false)
expect(File.exist?("test.doc")).to be true
output = File.read("test.doc", encoding: "UTF-8")
.sub(/^.*.*$/m, "")
expect(strip_guid(xmlpp(Nokogiri::XML(output)
.at("//xmlns:div[@class = 'WordSection3']").to_xml)))
.to be_equivalent_to xmlpp(word)
end
it "deals with ordered lists embedded within notes and examples" do
input = <<~INPUT
50
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
INPUT
word = <<~WORD
1
EXAMPLE
a)
A
b)
B
1)
C
2)
D
i)
E
ii)
F
A)
G
B)
H
I)
I
II)
J
a)
K
b)
L
c)
M
III)
N
C)
O
iii)
P
3)
Q
c)
R
WORD
FileUtils.rm_f "test.doc"
presxml = IsoDoc::Iso::PresentationXMLConvert.new({})
.convert("test", input, true)
IsoDoc::Iso::WordConvert.new({}).convert("test", presxml, false)
expect(File.exist?("test.doc")).to be true
output = File.read("test.doc", encoding: "UTF-8")
.sub(/^.*.*$/m, "")
expect(strip_guid(xmlpp(Nokogiri::XML(output)
.at("//xmlns:div[@class = 'WordSection3']").to_xml)))
.to be_equivalent_to xmlpp(word)
end
it "ignores intervening ul in numbering ol" do
input = <<~INPUT
50
A
List
B
List 2
INPUT
word = <<~WORD
1
—
A
a)
List
—
B
1)
List 2
WORD
FileUtils.rm_f "test.doc"
presxml = IsoDoc::Iso::PresentationXMLConvert.new({})
.convert("test", input, true)
IsoDoc::Iso::WordConvert.new({}).convert("test", presxml, false)
expect(File.exist?("test.doc")).to be true
output = File.read("test.doc", encoding: "UTF-8")
.sub(/^.*.*$/m, "")
expect(strip_guid(xmlpp(Nokogiri::XML(output)
.at("//xmlns:div[@class = 'WordSection3']").to_xml)))
.to be_equivalent_to xmlpp(word)
end
it "deals with definition lists embedded within notes and examples" do
input = <<~INPUT
50EXAMPLE
A
B
INPUT
word = <<~WORD
EXAMPLE
A
B
WORD
FileUtils.rm_f "test.doc"
IsoDoc::Iso::WordConvert.new({}).convert("test", input, false)
expect(File.exist?("test.doc")).to be true
output = File.read("test.doc", encoding: "UTF-8")
.sub(/^.*.*$/m, "")
expect(strip_guid(xmlpp(Nokogiri::XML(output)
.at("//xmlns:div[@class = 'WordSection3']").to_xml)))
.to be_equivalent_to xmlpp(word)
end
it "deals with annexes" do
input = <<~INPUT
50AnnexSubannexSubsubannex
INPUT
word = <<~WORD
Annex
Subannex
Subsubannex
WORD
FileUtils.rm_f "test.doc"
IsoDoc::Iso::WordConvert.new({}).convert("test", input, false)
expect(File.exist?("test.doc")).to be true
output = File.read("test.doc", encoding: "UTF-8")
.sub(/^.*.*$/m, "")
expect(strip_guid(xmlpp(Nokogiri::XML(output)
.at("//xmlns:div[@class = 'WordSection3']").to_xml)))
.to be_equivalent_to xmlpp(word)
end
it "deals with blockquotes" do
input = <<~INPUT
50
Normal clause
Note clause
Example start
X
Example continued
X
INPUT
word = <<~WORD
Normal clause
Note clause
Example start
X
Example continued
X
WORD
FileUtils.rm_f "test.doc"
IsoDoc::Iso::WordConvert.new({}).convert("test", input, false)
expect(File.exist?("test.doc")).to be true
output = File.read("test.doc", encoding: "UTF-8")
.sub(/^.*.*$/m, "")
expect(strip_guid(xmlpp(Nokogiri::XML(output)
.at("//xmlns:div[@class = 'WordSection3']").to_xml)))
.to be_equivalent_to xmlpp(word)
end
it "deals with title" do
input = <<~INPUT
Date and timeRepresentations for information interchangeBasic rules50international-standard8601First clause
INPUT
word = <<~WORD
Date and time — Representations for information interchange —
Part 1:
Basic rules
First clause
WORD
title = <<~WORD
Reference number of project:
Committee identification: /
Date and time — Representations for information interchange
— Part 1: Basic rules
WORD
FileUtils.rm_f "test.doc"
IsoDoc::Iso::WordConvert.new({}).convert("test", input, false)
expect(File.exist?("test.doc")).to be true
output = File.read("test.doc", encoding: "UTF-8")
.sub(/^.*.*$/m, "")
expect(strip_guid(xmlpp(Nokogiri::XML(output)
.at("//xmlns:div[@class = 'WordSection3']").to_xml)))
.to be_equivalent_to xmlpp(word)
expect(strip_guid(xmlpp(Nokogiri::XML(output)
.at("//xmlns:div[@class = 'WordSection1']").to_xml)))
.to be_equivalent_to xmlpp(title)
end
it "deals with amendments" do
input = <<~INPUT
Date and timeRepresentations for information interchangeBasic rulesTechnical corrections50amendment8601ForewordFirst clause
INPUT
word = <<~WORD
Date and time — Representations for information interchange —
Part 1:
Basic rules
AMENDMENT 1: Technical corrections
First clause
WORD
FileUtils.rm_f "test.doc"
IsoDoc::Iso::WordConvert.new({}).convert("test", input, false)
expect(File.exist?("test.doc")).to be true
output = File.read("test.doc", encoding: "UTF-8")
.sub(/^.*.*$/m, "")
expect(strip_guid(xmlpp(Nokogiri::XML(output)
.at("//xmlns:div[@class = 'WordSection3']").to_xml)))
.to be_equivalent_to xmlpp(word)
end
it "deals with copyright boilerplate" do
presxml = <<~OUTPUT
50COPYRIGHT PROTECTED DOCUMENT
This document is not an ISO International Standard. It is distributed for review and
comment. It is subject to change without notice and may not be referred to as
an International Standard.
Recipients
of this draft are invited to submit, with their comments, notification of any
relevant patent rights of which they are aware and to provide supporting
documentation.
OUTPUT
end
it "deals with Simple Template styles" do
input = <<~INPUT
20Clause Title
List
Note
Note List
Example
Example List
XYZ
Table
Annex Title
Annex Table
Annex Clause TitleBibliographyALUFFI, Paolo, ed. (2022). Facets of Algebraic Geometry: A Collection in Honor of William Fulton's 80th Birthday, 1st edition. Cambridge, UK: CUP.ISO/IEC 712-3:2022
INPUT
word = <<~WORD
Clause Title
List
Note
Note List
Example
Example List
Figure Title
XYZ
Table
Annex Title
Annex Table
Annex Clause Title
Bibliography
[1]
ISO/IEC 712-3:2022, ALUFFI, Paolo, ed. (2022).
Facets of Algebraic Geometry: A Collection in Honor of William Fulton's
80th Birthday
, 1st edition. Cambridge, UK: CUP.
WORD
FileUtils.rm_f "test.doc"
IsoDoc::Iso::WordConvert.new({}).convert("test", input, false)
expect(File.exist?("test.doc")).to be true
output = File.read("test.doc", encoding: "UTF-8")
.sub(/^.*.*$/m, "")
expect(strip_guid(xmlpp(Nokogiri::XML(output)
.at("//xmlns:div[@class = 'WordSection3']").to_xml)))
.to be_equivalent_to xmlpp(word)
end
end