spec/isodoc/blocks_spec.rb in isodoc-1.0.6 vs spec/isodoc/blocks_spec.rb in isodoc-1.0.7
- old
+ new
@@ -1,10 +1,10 @@
require "spec_helper"
RSpec.describe IsoDoc do
it "processes unlabelled notes" do
- expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<iso-standard xmlns="http://riboseinc.com/isoxml">
<preface><foreword>
<note>
<p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
</note>
@@ -25,11 +25,11 @@
</html>
OUTPUT
end
it "processes unlabelled notes (Word)" do
- expect(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
+ expect(xmlpp(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<iso-standard xmlns="http://riboseinc.com/isoxml">
<preface><foreword>
<note>
<p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
</note>
@@ -62,11 +62,11 @@
OUTPUT
end
it "processes labelled notes" do
- expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<iso-standard xmlns="http://riboseinc.com/isoxml">
<preface><foreword>
<note id="note1">
<p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
</note>
@@ -87,11 +87,11 @@
</html>
OUTPUT
end
it "processes sequences of notes" do
- expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<iso-standard xmlns="http://riboseinc.com/isoxml">
<preface><foreword>
<note id="note1">
<p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
</note>
@@ -118,11 +118,11 @@
</html>
OUTPUT
end
it "processes multi-para notes" do
- expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<iso-standard xmlns="http://riboseinc.com/isoxml">
<preface><foreword>
<note>
<p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
<p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83a">These results are based on a study carried out on three different types of kernel.</p>
@@ -145,11 +145,11 @@
</html>
OUTPUT
end
it "processes non-para notes" do
- expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<iso-standard xmlns="http://riboseinc.com/isoxml">
<preface><foreword>
<note>
<dl>
<dt>A</dt>
@@ -178,11 +178,11 @@
OUTPUT
end
it "processes non-para notes (Word)" do
- expect(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
+ expect(xmlpp(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<iso-standard xmlns="http://riboseinc.com/isoxml">
<preface><foreword>
<note>
<dl>
<dt>A</dt>
@@ -221,11 +221,11 @@
</html>
OUTPUT
end
it "processes figures" do
- expect(strip_guid(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to <<~"OUTPUT"
+ expect(xmlpp(strip_guid(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<iso-standard xmlns="http://riboseinc.com/isoxml">
<preface><foreword>
<figure id="figureA-1">
<name>Split-it-right <em>sample</em> divider</name>
<image src="rice_images/rice_image1.png" height="20" width="30" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png" alt="alttext" title="titletxt"/>
@@ -281,11 +281,11 @@
</html>
OUTPUT
end
it "processes figures (Word)" do
- expect(strip_guid(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to <<~"OUTPUT"
+ expect(xmlpp(strip_guid(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<iso-standard xmlns="http://riboseinc.com/isoxml">
<preface><foreword>
<figure id="figureA-1">
<name>Split-it-right sample divider</name>
<image src="rice_images/rice_image1.png" height="20" width="30" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png" alt="alttext" title="titletext"/>
@@ -343,11 +343,11 @@
</html>
OUTPUT
end
it "processes examples" do
- expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<iso-standard xmlns="http://riboseinc.com/isoxml">
<preface><foreword>
<example id="samplecode">
<name>Title</name>
<p>Hello</p>
@@ -371,11 +371,11 @@
OUTPUT
end
it "processes sequences of examples" do
- expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<iso-standard xmlns="http://riboseinc.com/isoxml">
<preface><foreword>
<example id="samplecode">
<p>Hello</p>
</example>
@@ -412,11 +412,11 @@
</html>
OUTPUT
end
it "processes sourcecode" do
- expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<iso-standard xmlns="http://riboseinc.com/isoxml">
<preface><foreword>
<sourcecode lang="ruby" id="samplecode">
<name>Ruby <em>code</em></name>
puts x
@@ -436,11 +436,11 @@
</html>
OUTPUT
end
it "processes sourcecode (Word)" do
- expect(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
+ expect(xmlpp(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<iso-standard xmlns="http://riboseinc.com/isoxml">
<preface><foreword>
<sourcecode lang="ruby" id="samplecode">
<name>Ruby <em>code</em></name>
puts x
@@ -477,11 +477,11 @@
</html>
OUTPUT
end
it "processes sourcecode with escapes preserved" do
- expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<iso-standard xmlns="http://riboseinc.com/isoxml">
<preface><foreword>
<sourcecode id="samplecode">
<name>XML code</name>
<xml>
@@ -501,11 +501,11 @@
</html>
OUTPUT
end
it "processes sourcecode with annotations" do
- expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<iso-standard xmlns="http://riboseinc.com/isoxml">
<preface><foreword>
<sourcecode id="_">puts "Hello, world." <callout target="A">1</callout>
%w{a b c}.each do |x|
puts x <callout target="B">2</callout>
@@ -529,11 +529,11 @@
</html>
OUTPUT
end
it "processes admonitions" do
- expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<iso-standard xmlns="http://riboseinc.com/isoxml">
<preface><foreword>
<admonition id="_70234f78-64e5-4dfc-8b6f-f3f037348b6a" type="caution">
<p id="_e94663cc-2473-4ccc-9a72-983a74d989f2">Only use paddy or parboiled rice for the determination of husked rice yield.</p>
</admonition>
@@ -554,11 +554,11 @@
</html>
OUTPUT
end
it "processes admonitions with titles" do
- expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<iso-standard xmlns="http://riboseinc.com/isoxml">
<preface><foreword>
<admonition id="_70234f78-64e5-4dfc-8b6f-f3f037348b6a" type="caution">
<name>Title</name>
<p id="_e94663cc-2473-4ccc-9a72-983a74d989f2">Only use paddy or parboiled rice for the determination of husked rice yield.</p>
@@ -581,11 +581,11 @@
OUTPUT
end
it "processes formulae" do
- expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<iso-standard xmlns="http://riboseinc.com/isoxml">
<preface><foreword>
<formula id="_be9158af-7e93-4ee2-90c5-26d31c181934" unnumbered="true">
<stem type="AsciiMath">r = 1 %</stem>
<dl id="_e4fe94fe-1cde-49d9-b1ad-743293b7e21d">
@@ -627,11 +627,11 @@
</html>
OUTPUT
end
it "processes paragraph alignments" do
- expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<iso-standard xmlns="http://riboseinc.com/isoxml">
<preface><foreword>
<p align="left" id="_08bfe952-d57f-4150-9c95-5d52098cc2a8">Vache Equipment<br/>
Fictitious<br/>
World</p>
@@ -655,11 +655,11 @@
</html>
OUTPUT
end
it "processes paragraph alignments (Word)" do
- expect(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
+ expect(xmlpp(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<iso-standard xmlns="http://riboseinc.com/isoxml">
<preface><foreword>
<p align="left" id="_08bfe952-d57f-4150-9c95-5d52098cc2a8">Vache Equipment<br/>
Fictitious<br/>
World</p>
@@ -696,11 +696,11 @@
end
it "processes blockquotes" do
- expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<iso-standard xmlns="http://riboseinc.com/isoxml">
<preface><foreword>
<quote id="_044bd364-c832-4b78-8fea-92242402a1d1">
<source type="inline" bibitemid="ISO7301" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>1</referenceFrom></locality></source>
<author>ISO</author>
@@ -726,11 +726,11 @@
</html>
OUTPUT
end
it "processes term domains" do
- expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<iso-standard xmlns="http://riboseinc.com/isoxml">
<sections>
<terms>
<term id="_extraneous_matter"><preferred>extraneous matter</preferred><admitted>EM</admitted>
<domain>rice</domain>
@@ -752,11 +752,11 @@
</html>
OUTPUT
end
it "processes permissions" do
- expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<iso-standard xmlns="http://riboseinc.com/isoxml">
<preface><foreword>
<permission id="_">
<label>/ogc/recommendation/wfs/2</label>
<inherit>/ss/584/2015/level/1</inherit>
@@ -838,11 +838,11 @@
</html>
OUTPUT
end
it "processes requirements" do
- expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<iso-standard xmlns="http://riboseinc.com/isoxml">
<preface><foreword>
<requirement id="A" unnumbered="true">
<title>A New Requirement</title>
<label>/ogc/recommendation/wfs/2</label>
@@ -923,11 +923,11 @@
</html>
OUTPUT
end
it "processes recommendation" do
- expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<iso-standard xmlns="http://riboseinc.com/isoxml">
<preface><foreword>
<recommendation id="_" obligation="shall,could">
<label>/ogc/recommendation/wfs/2</label>
<inherit>/ss/584/2015/level/1</inherit>
@@ -1006,8 +1006,56 @@
</div>
</body>
</html>
OUTPUT
end
+
+ it "processes pseudocode" do
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
+<itu-standard xmlns="http://riboseinc.com/isoxml">
+ <bibdata>
+ <language>en</language>
+ </bibdata>
+ <preface><foreword>
+ <figure id="_" class="pseudocode"><name>Label</name><p id="_"> <strong>A</strong><br/>
+ <smallcap>B</smallcap></p>
+<p id="_"> <em>C</em></p></figure>
+</preface></itu-standard>
+INPUT
+ #{HTML_HDR}
+ <br/>
+ <div>
+ <h1 class="ForewordTitle">Foreword</h1>
+ <div id="_" class="pseudocode"><p id="_">  <b>A</b><br/>
+         <span style="font-variant:small-caps;">B</span></p>
+ <p id="_">  <i>C</i></p><p class="SourceTitle" style="text-align:center;">Label</p></div>
+ </div>
+ <p class="zzSTDTitle1"/>
+ </div>
+ </body>
+</html>
+OUTPUT
+ end
+
+ it "processes pseudocode (Word)" do
+ FileUtils.rm_f "test.doc"
+ IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", false)
+<itu-standard xmlns="http://riboseinc.com/isoxml">
+ <bibdata>
+ <language>en</language>
+ </bibdata>
+ <preface><foreword>
+ <figure id="_" class="pseudocode"><name>Label</name><p id="_"> <strong>A</strong><br/>
+ <smallcap>B</smallcap></p>
+<p id="_"> <em>C</em></p></figure>
+</preface></itu-standard>
+INPUT
+ expect(xmlpp( File.read("test.doc").gsub(%r{^.*<h1 class="ForewordTitle">Foreword</h1>}m, "").gsub(%r{</div>.*}m, "</div>"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
+ <div class="pseudocode"><a name="_" id="_"></a><p class="pseudocode"><a name="_" id="_"></a>  <b>A</b><br/>
+         <span style="font-variant:small-caps;">B</span></p>
+ <p class="pseudocode" style="page-break-after:avoid;"><a name="_" id="_"></a>  <i>C</i></p><p class="SourceTitle" style="text-align:center;">Label</p></div>
+OUTPUT
+ end
+
end