Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Jul 22, 2024
1 parent f79a6e5 commit abe7427
Show file tree
Hide file tree
Showing 16 changed files with 234 additions and 253 deletions.
1 change: 1 addition & 0 deletions metanorma-ieee.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "timecop", "~> 0.9"
spec.add_development_dependency "vcr", "~> 6.1.0"
spec.add_development_dependency "webmock"
spec.add_development_dependency "xml-c14n"
end
68 changes: 34 additions & 34 deletions spec/isodoc/blocks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -335,19 +335,19 @@
</div>
</div>
WORD
expect(xmlpp(strip_guid(IsoDoc::IEEE::PresentationXMLConvert
expect(Xml::C14n.format(strip_guid(IsoDoc::IEEE::PresentationXMLConvert
.new(presxml_options)
.convert("test", input, true)))).to be_equivalent_to xmlpp(presxml)
expect(xmlpp(Nokogiri::XML(IsoDoc::IEEE::HtmlConvert.new({})
.convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(presxml)
expect(Xml::C14n.format(Nokogiri::XML(IsoDoc::IEEE::HtmlConvert.new({})
.convert("test", presxml, true))
.at("//body").to_xml)).to be_equivalent_to xmlpp(html)
.at("//body").to_xml)).to be_equivalent_to Xml::C14n.format(html)
IsoDoc::IEEE::WordConvert.new({}).convert("test", presxml, false)
expect(File.exist?("test.doc")).to be true
doc = Nokogiri::XML(word2xml("test.doc"))
.at("//xmlns:div[xmlns:a[@id = 'A']]")
expect(strip_guid(xmlpp(doc.to_xml
expect(strip_guid(Xml::C14n.format(doc.to_xml
.gsub("<m:", "<").gsub("</m:", "</"))))
.to be_equivalent_to xmlpp(word)
.to be_equivalent_to Xml::C14n.format(word)
expect(Nokogiri::XML(IsoDoc::IEEE::PresentationXMLConvert
.new({ hierarchicalassets: true })
.convert("test", input, true))
Expand Down Expand Up @@ -500,29 +500,29 @@
</div>
</div>
OUTPUT
expect(xmlpp(strip_guid(IsoDoc::IEEE::PresentationXMLConvert
expect(Xml::C14n.format(strip_guid(IsoDoc::IEEE::PresentationXMLConvert
.new(presxml_options)
.convert("test", input, true).gsub("&lt;", "&#x3c;"))))
.to be_equivalent_to xmlpp(presxml)
expect(xmlpp(strip_guid(Nokogiri::XML(IsoDoc::IEEE::HtmlConvert.new({})
.to be_equivalent_to Xml::C14n.format(presxml)
expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::IEEE::HtmlConvert.new({})
.convert("test", presxml, true))
.at("//body").to_xml))).to be_equivalent_to xmlpp(html)
.at("//body").to_xml))).to be_equivalent_to Xml::C14n.format(html)
FileUtils.rm_rf "spec/assets/odf1.emf"
IsoDoc::IEEE::WordConvert.new({}).convert("test", presxml, false)
expect(File.exist?("test.doc")).to be true
doc = Nokogiri::XML(word2xml("test.doc"))
.at("//xmlns:div[xmlns:a[@id = 'A']]")
expect(strip_guid(xmlpp(doc.to_xml
expect(strip_guid(Xml::C14n.format(doc.to_xml
.gsub("<m:", "<").gsub("</m:", "</")
.gsub(/['"][^'".]+\.(gif|xml)['"]/, "'_.\\1'")
.gsub("epub:", "")
.gsub(/mso-bookmark:_Ref\d+/, "mso-bookmark:_Ref"))))
.to be_equivalent_to xmlpp(word)
expect(xmlpp(Nokogiri::XML(IsoDoc::IEEE::PresentationXMLConvert
.to be_equivalent_to Xml::C14n.format(word)
expect(Xml::C14n.format(Nokogiri::XML(IsoDoc::IEEE::PresentationXMLConvert
.new({ hierarchicalassets: true })
.convert("test", input, true))
.at("//xmlns:figure/xmlns:name").to_xml))
.to be_equivalent_to xmlpp(<<~OUTPUT)
.to be_equivalent_to Xml::C14n.format(<<~OUTPUT)
<name>
Figure Preface.1&#x2014;Split-it-right
<em>sample</em>
Expand Down Expand Up @@ -622,13 +622,13 @@
</div>
</body>
OUTPUT
expect(xmlpp(strip_guid(IsoDoc::IEEE::PresentationXMLConvert
expect(Xml::C14n.format(strip_guid(IsoDoc::IEEE::PresentationXMLConvert
.new(presxml_options)
.convert("test", input, true).gsub("&lt;", "&#x3c;"))))
.to be_equivalent_to xmlpp(presxml)
expect(xmlpp(Nokogiri::XML(IsoDoc::IEEE::HtmlConvert.new({})
.to be_equivalent_to Xml::C14n.format(presxml)
expect(Xml::C14n.format(Nokogiri::XML(IsoDoc::IEEE::HtmlConvert.new({})
.convert("test", presxml, true))
.at("//body").to_xml)).to be_equivalent_to xmlpp(html)
.at("//body").to_xml)).to be_equivalent_to Xml::C14n.format(html)
end

it "processes admonitions" do
Expand Down Expand Up @@ -688,13 +688,13 @@
<p>&#xa0;</p>
</div>
OUTPUT
expect(strip_guid(xmlpp(Nokogiri::XML(IsoDoc::IEEE::HtmlConvert.new({})
expect(strip_guid(Xml::C14n.format(Nokogiri::XML(IsoDoc::IEEE::HtmlConvert.new({})
.convert("test", presxml, true))
.at("//body").to_xml))).to be_equivalent_to xmlpp(html)
expect(strip_guid(xmlpp(Nokogiri::XML(IsoDoc::IEEE::WordConvert.new({})
.at("//body").to_xml))).to be_equivalent_to Xml::C14n.format(html)
expect(strip_guid(Xml::C14n.format(Nokogiri::XML(IsoDoc::IEEE::WordConvert.new({})
.convert("test", presxml, true))
.at("//div[@class = 'WordSection2']").to_xml)))
.to be_equivalent_to xmlpp(word)
.to be_equivalent_to Xml::C14n.format(word)
end

it "processes examples" do
Expand Down Expand Up @@ -755,16 +755,16 @@
</div>
</div>
OUTPUT
expect(strip_guid(xmlpp(Nokogiri::XML(IsoDoc::IEEE::HtmlConvert.new({})
expect(strip_guid(Xml::C14n.format(Nokogiri::XML(IsoDoc::IEEE::HtmlConvert.new({})
.convert("test", presxml, true))
.at("//body").to_xml))).to be_equivalent_to xmlpp(html)
.at("//body").to_xml))).to be_equivalent_to Xml::C14n.format(html)
IsoDoc::IEEE::WordConvert.new({}).convert("test", presxml, false)
expect(File.exist?("test.doc")).to be true
doc = Nokogiri::XML(word2xml("test.doc"))
.at("//xmlns:div[xmlns:a[@id = 'A']]")
expect(strip_guid(xmlpp(doc.to_xml
expect(strip_guid(Xml::C14n.format(doc.to_xml
.gsub("<m:", "<").gsub("</m:", "</"))))
.to be_equivalent_to xmlpp(word)
.to be_equivalent_to Xml::C14n.format(word)
end

it "process formulae" do
Expand Down Expand Up @@ -887,20 +887,20 @@
</div>
</div>
OUTPUT
expect(xmlpp(strip_guid(IsoDoc::IEEE::PresentationXMLConvert
expect(Xml::C14n.format(strip_guid(IsoDoc::IEEE::PresentationXMLConvert
.new(presxml_options)
.convert("test", input, true))))
.to be_equivalent_to xmlpp(presxml)
expect(strip_guid(xmlpp(Nokogiri::XML(IsoDoc::IEEE::HtmlConvert.new({})
.to be_equivalent_to Xml::C14n.format(presxml)
expect(strip_guid(Xml::C14n.format(Nokogiri::XML(IsoDoc::IEEE::HtmlConvert.new({})
.convert("test", presxml, true))
.at("//body").to_xml))).to be_equivalent_to xmlpp(html)
.at("//body").to_xml))).to be_equivalent_to Xml::C14n.format(html)
IsoDoc::IEEE::WordConvert.new({}).convert("test", presxml, false)
expect(File.exist?("test.doc")).to be true
doc = Nokogiri::XML(word2xml("test.doc"))
.at("//xmlns:div[xmlns:a[@id = 'A']]")
expect(strip_guid(xmlpp(doc.to_xml
expect(strip_guid(Xml::C14n.format(doc.to_xml
.gsub("<m:", "<").gsub("</m:", "</"))))
.to be_equivalent_to xmlpp(word)
.to be_equivalent_to Xml::C14n.format(word)
end

it "processes amend blocks" do
Expand Down Expand Up @@ -1050,10 +1050,10 @@
</quote>
</clause>
OUTPUT
expect(xmlpp(Nokogiri::XML(
expect(Xml::C14n.format(Nokogiri::XML(
IsoDoc::IEEE::PresentationXMLConvert.new(presxml_options)
.convert("test", input, true),
).at("//xmlns:clause[@id = 'A']").to_xml))
.to be_equivalent_to xmlpp(presxml)
.to be_equivalent_to Xml::C14n.format(presxml)
end
end
16 changes: 8 additions & 8 deletions spec/isodoc/inline_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@
</bibliography>
</iso-standard>
INPUT
expect(xmlpp(strip_guid(output))
expect(Xml::C14n.format(strip_guid(output))
.sub(%r{<i18nyaml>.*</i18nyaml>}m, ""))
.to be_equivalent_to xmlpp(strip_guid(<<~OUTPUT))
.to be_equivalent_to Xml::C14n.format(strip_guid(<<~OUTPUT))
<iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
<preface>
<clause type="toc" id="_" displayorder="1"> <title depth="1">Contents</title> </clause>
Expand Down Expand Up @@ -202,8 +202,8 @@
</p>
</itu-standard>
OUTPUT
expect(xmlpp(IsoDoc::IEEE::PresentationXMLConvert.new(presxml_options)
.convert("test", input, true))).to be_equivalent_to xmlpp(output)
expect(Xml::C14n.format(IsoDoc::IEEE::PresentationXMLConvert.new(presxml_options)
.convert("test", input, true))).to be_equivalent_to Xml::C14n.format(output)
end

it "processes concept markup" do
Expand Down Expand Up @@ -333,8 +333,8 @@
OUTPUT
xml = Nokogiri::XML(IsoDoc::IEEE::PresentationXMLConvert.new(presxml_options)
.convert("test", input, true))
expect(xmlpp(xml.at("//xmlns:foreword").to_xml))
.to be_equivalent_to xmlpp(presxml)
expect(Xml::C14n.format(xml.at("//xmlns:foreword").to_xml))
.to be_equivalent_to Xml::C14n.format(presxml)
end

it "duplicates MathML with AsciiMath and LaTeXMath" do
Expand Down Expand Up @@ -385,7 +385,7 @@
xml = Nokogiri::XML(IsoDoc::IEEE::PresentationXMLConvert.new({})
.convert("test", input, true))
xml.at("//xmlns:metanorma-extension").remove
expect(xmlpp(strip_guid(xml.to_xml)))
.to be_equivalent_to xmlpp(output)
expect(Xml::C14n.format(strip_guid(xml.to_xml)))
.to be_equivalent_to Xml::C14n.format(output)
end
end
20 changes: 10 additions & 10 deletions spec/isodoc/postproc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
<div id='abstract-destination'/>
</main>
OUTPUT
expect(xmlpp(IsoDoc::IEEE::HtmlConvert
expect(Xml::C14n.format(IsoDoc::IEEE::HtmlConvert
.new(htmlcoverpage: nil,
htmlintropage: nil,
bare: true,
filename: "test")
.html_cleanup(Nokogiri::XML(input)).to_xml)
.sub(/^.*<main/m, "<main").sub(%r{</main>.*$}m, "</main>"))
.to be_equivalent_to xmlpp(doc)
.to be_equivalent_to Xml::C14n.format(doc)
end

it "moves abstract in Word, and style abstracts" do
Expand Down Expand Up @@ -81,13 +81,13 @@
</body>
</html>
OUTPUT
expect(xmlpp(IsoDoc::IEEE::WordConvert
expect(Xml::C14n.format(IsoDoc::IEEE::WordConvert
.new(wordcoverpage: nil,
wordintropage: nil,
filename: "test")
.word_cleanup(Nokogiri::XML(input)).to_xml)
.sub(/^.*<main/m, "<main").sub(%r{</main>.*$}m, "</main>"))
.to be_equivalent_to xmlpp(doc)
.to be_equivalent_to Xml::C14n.format(doc)
end

it "copies scope in Word in the absence of abstract" do
Expand Down Expand Up @@ -134,13 +134,13 @@
</body>
</html>
OUTPUT
expect(xmlpp(IsoDoc::IEEE::WordConvert
expect(Xml::C14n.format(IsoDoc::IEEE::WordConvert
.new(wordcoverpage: nil,
wordintropage: nil,
filename: "test")
.word_cleanup(Nokogiri::XML(input)).to_xml)
.sub(/^.*<main/m, "<main").sub(%r{</main>.*$}m, "</main>"))
.to be_equivalent_to xmlpp(doc)
.to be_equivalent_to Xml::C14n.format(doc)
end

it "moves introduction in Word" do
Expand Down Expand Up @@ -179,13 +179,13 @@
</body>
</html>
OUTPUT
expect(xmlpp(IsoDoc::IEEE::WordConvert
expect(Xml::C14n.format(IsoDoc::IEEE::WordConvert
.new(wordcoverpage: nil,
wordintropage: nil,
filename: "test")
.word_cleanup(Nokogiri::XML(input)).to_xml)
.sub(/^.*<main/m, "<main").sub(%r{</main>.*$}m, "</main>"))
.to be_equivalent_to xmlpp(doc)
.to be_equivalent_to Xml::C14n.format(doc)
end

it "renders headings in Word" do
Expand Down Expand Up @@ -236,13 +236,13 @@
</body>
</html>
OUTPUT
expect(xmlpp(IsoDoc::IEEE::WordConvert
expect(Xml::C14n.format(IsoDoc::IEEE::WordConvert
.new(wordcoverpage: nil,
wordintropage: nil,
filename: "test")
.word_cleanup(Nokogiri::XML(input)).to_xml)
.sub(/^.*<main/m, "<main").sub(%r{</main>.*$}m, "</main>"))
.to be_equivalent_to xmlpp(doc)
.to be_equivalent_to Xml::C14n.format(doc)
end

private
Expand Down
12 changes: 6 additions & 6 deletions spec/isodoc/refs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@
IsoDoc::IEEE::PresentationXMLConvert.new(presxml_options)
.convert("test", input, true),
)
expect(xmlpp(strip_guid(out.to_xml)))
.to be_equivalent_to xmlpp(presxml)
expect(Xml::C14n.format(strip_guid(out.to_xml)))
.to be_equivalent_to Xml::C14n.format(presxml)
end
end

Expand Down Expand Up @@ -445,8 +445,8 @@
IsoDoc::IEEE::PresentationXMLConvert.new(presxml_options)
.convert("test", input, true),
)
expect(xmlpp(strip_guid(out.to_xml)))
.to be_equivalent_to xmlpp(presxml)
expect(Xml::C14n.format(strip_guid(out.to_xml)))
.to be_equivalent_to Xml::C14n.format(presxml)
end

it "renders reference without identifier" do
Expand Down Expand Up @@ -517,7 +517,7 @@
IsoDoc::IEEE::PresentationXMLConvert.new(presxml_options)
.convert("test", input, true),
)
expect(xmlpp(strip_guid(out.to_xml)))
.to be_equivalent_to xmlpp(presxml)
expect(Xml::C14n.format(strip_guid(out.to_xml)))
.to be_equivalent_to Xml::C14n.format(presxml)
end
end
Loading

0 comments on commit abe7427

Please sign in to comment.