spec/isodoc/i18n_spec.rb in isodoc-1.1.4 vs spec/isodoc/i18n_spec.rb in isodoc-1.2.0
- old
+ new
@@ -1,24 +1,24 @@
require "spec_helper"
RSpec.describe IsoDoc do
it "processes English" do
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
+ input = <<~"INPUT"
<iso-standard xmlns="http://riboseinc.com/isoxml">
<bibdata>
<language>en</language>
</bibdata>
<preface>
<foreword obligation="informative">
<title>Foreword</title>
- <p id="A">This is a preamble</p>
+ <p id="A">See <xref target="M"/></p>
</foreword>
<introduction id="B" obligation="informative"><title>Introduction</title><clause id="C" inline-header="false" obligation="informative">
<title>Introduction Subsection</title>
</clause>
</introduction></preface><sections>
- <clause id="D" obligation="normative">
+ <clause id="D" obligation="normative" type="scope">
<title>Scope</title>
<p id="E">Text</p>
</clause>
<clause id="H" obligation="normative"><title>Terms, definitions, symbols and abbreviated terms</title><terms id="I" obligation="normative">
@@ -64,15 +64,106 @@
</references>
</clause>
</bibliography>
</iso-standard>
INPUT
+
+ presxml = <<~"PRESXML"
+ <iso-standard xmlns='http://riboseinc.com/isoxml'>
+ <bibdata>
+ <language>en</language>
+ </bibdata>
+ <preface>
+ <foreword obligation='informative'>
+ <title>Foreword</title>
+ <p id='A'>See <xref target='M'>Clause 5</xref></p>
+ </foreword>
+ <introduction id='B' obligation='informative'>
+ <title>Introduction</title>
+ <clause id='C' inline-header='false' obligation='informative'>
+ <title depth='2'>Introduction Subsection</title>
+ </clause>
+ </introduction>
+ </preface>
+ <sections>
+ <clause id='D' obligation='normative' type="scope">
+ <title depth='1'>1.<tab/>Scope</title>
+ <p id='E'>Text</p>
+ </clause>
+ <clause id='H' obligation='normative'>
+ <title depth='1'>3.<tab/>Terms, definitions, symbols and abbreviated terms</title>
+ <terms id='I' obligation='normative'>
+ <title depth='2'>3.1.<tab/>Normal Terms</title>
+ <term id='J'>
+ <name>3.1.1.</name>
+ <preferred>Term2</preferred>
+ </term>
+ </terms>
+ <definitions id='K'>
+ <title>3.2.</title>
+ <dl>
+ <dt>Symbol</dt>
+ <dd>Definition</dd>
+ </dl>
+ </definitions>
+ </clause>
+ <definitions id='L'>
+ <title>4.</title>
+ <dl>
+ <dt>Symbol</dt>
+ <dd>Definition</dd>
+ </dl>
+ </definitions>
+ <clause id='M' inline-header='false' obligation='normative'>
+ <title depth='1'>5.<tab/>Clause 4</title>
+ <clause id='N' inline-header='false' obligation='normative'>
+ <title depth='2'>5.1.<tab/>Introduction</title>
+ </clause>
+ <clause id='O' inline-header='false' obligation='normative'>
+ <title depth='2'>5.2.<tab/>Clause 4.2</title>
+ </clause>
+ </clause>
+ </sections>
+ <annex id='P' inline-header='false' obligation='normative'>
+ <title>
+ <strong>Annex A</strong>
+ <br/>
+ (normative)
+ <br/>
+ <br/>
+ <strong>Annex</strong>
+ </title>
+ <clause id='Q' inline-header='false' obligation='normative'>
+ <title depth='2'>A.1.<tab/>Annex A.1</title>
+ <clause id='Q1' inline-header='false' obligation='normative'>
+ <title depth='3'>A.1.1.<tab/>Annex A.1a</title>
+ </clause>
+ </clause>
+ </annex>
+ <bibliography>
+ <references id='R' obligation='informative' normative='true'>
+ <title depth='1'>2.<tab/>Normative References</title>
+ </references>
+ <clause id='S' obligation='informative'>
+ <title depth="1">Bibliography</title>
+ <references id='T' obligation='informative' normative='false'>
+ <title depth="2">Bibliography Subsection</title>
+ </references>
+ </clause>
+ </bibliography>
+ </iso-standard>
+PRESXML
+
+ output = <<~"OUTPUT"
#{HTML_HDR}
<br/>
<div>
<h1 class="ForewordTitle">Foreword</h1>
- <p id="A">This is a preamble</p>
+ <p id='A'>
+ See
+ <a href='#M'>Clause 5</a>
+</p>
</div>
<br/>
<div class="Section3" id="B">
<h1 class="IntroTitle">Introduction</h1>
<div id="C">
@@ -83,23 +174,23 @@
<div id="D">
<h1>1.  Scope</h1>
<p id="E">Text</p>
</div>
<div>
- <h1>2.  Normative references</h1>
+ <h1>2.  Normative References</h1>
</div>
<div id="H"><h1>3.  Terms, definitions, symbols and abbreviated terms</h1>
<div id="I">
<h2>3.1.  Normal Terms</h2>
<p class="TermNum" id="J">3.1.1.</p>
<p class="Terms" style="text-align:left;">Term2</p>
- </div><div id="K"><h2>3.2.  Symbols and abbreviated terms</h2>
+ </div><div id="K"><h2>3.2.</h2>
<dl><dt><p>Symbol</p></dt><dd>Definition</dd></dl>
</div></div>
<div id="L" class="Symbols">
- <h1>4.  Symbols and abbreviated terms</h1>
+ <h1>4.</h1>
<dl>
<dt>
<p>Symbol</p>
</dt>
<dd>Definition</dd>
@@ -133,28 +224,30 @@
</div>
</div>
</body>
</html>
OUTPUT
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(output)
end
it "defaults to English" do
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<iso-standard xmlns="http://riboseinc.com/isoxml">
<bibdata>
<language>tlh</language>
</bibdata>
<preface>
<foreword obligation="informative">
<title>Foreword</title>
- <p id="A">This is a preamble</p>
+ <p id="A">See <xref target="M"/></p>
</foreword>
<introduction id="B" obligation="informative"><title>Introduction</title><clause id="C" inline-header="false" obligation="informative">
<title>Introduction Subsection</title>
</clause>
</introduction></preface><sections>
- <clause id="D" obligation="normative">
+ <clause id="D" obligation="normative" type="scope">
<title>Scope</title>
<p id="E">Text</p>
</clause>
<clause id="H" obligation="normative"><title>Terms, definitions, symbols and abbreviated terms</title><terms id="I" obligation="normative">
@@ -200,97 +293,113 @@
</references>
</clause>
</bibliography>
</iso-standard>
INPUT
- #{HTML_HDR.gsub(/ lang="en">/, ' lang="tlh">')}
- <br/>
- <div>
- <h1 class="ForewordTitle">Foreword</h1>
- <p id="A">This is a preamble</p>
- </div>
- <br/>
- <div class="Section3" id="B">
- <h1 class="IntroTitle">Introduction</h1>
- <div id="C">
- <h2>Introduction Subsection</h2>
- </div>
- </div>
- <p class="zzSTDTitle1"/>
- <div id="D">
- <h1>1.  Scope</h1>
- <p id="E">Text</p>
- </div>
- <div>
- <h1>2.  Normative references</h1>
- </div>
- <div id="H"><h1>3.  Terms, definitions, symbols and abbreviated terms</h1>
- <div id="I">
- <h2>3.1.  Normal Terms</h2>
- <p class="TermNum" id="J">3.1.1.</p>
- <p class="Terms" style="text-align:left;">Term2</p>
-
- </div><div id="K"><h2>3.2.  Symbols and abbreviated terms</h2>
- <dl><dt><p>Symbol</p></dt><dd>Definition</dd></dl>
- </div></div>
- <div id="L" class="Symbols">
- <h1>4.  Symbols and abbreviated terms</h1>
- <dl>
- <dt>
- <p>Symbol</p>
- </dt>
- <dd>Definition</dd>
- </dl>
- </div>
- <div id="M">
- <h1>5.  Clause 4</h1>
- <div id="N">
- <h2>5.1.  Introduction</h2>
- </div>
- <div id="O">
- <h2>5.2.  Clause 4.2</h2>
- </div>
- </div>
- <br/>
- <div id="P" class="Section3">
- <h1 class="Annex"><b>Annex A</b><br/>(normative)<br/><br/><b>Annex</b></h1>
- <div id="Q">
- <h2>A.1.  Annex A.1</h2>
- <div id="Q1">
- <h3>A.1.1.  Annex A.1a</h3>
- </div>
- </div>
- </div>
- <br/>
- <div>
- <h1 class="Section3">Bibliography</h1>
- <div>
- <h2 class="Section3">Bibliography Subsection</h2>
- </div>
- </div>
- </div>
- </body>
- </html>
+ <?xml version='1.0'?>
+ <iso-standard xmlns='http://riboseinc.com/isoxml'>
+ <bibdata>
+ <language>tlh</language>
+ </bibdata>
+ <preface>
+ <foreword obligation='informative'>
+ <title>Foreword</title>
+ <p id='A'>See <xref target='M'>Clause 5</xref></p>
+ </foreword>
+ <introduction id='B' obligation='informative'>
+ <title>Introduction</title>
+ <clause id='C' inline-header='false' obligation='informative'>
+ <title depth='2'>Introduction Subsection</title>
+ </clause>
+ </introduction>
+ </preface>
+ <sections>
+ <clause id='D' obligation='normative' type="scope">
+ <title depth='1'>1.<tab/>Scope</title>
+ <p id='E'>Text</p>
+ </clause>
+ <clause id='H' obligation='normative'>
+ <title depth='1'>3.<tab/>Terms, definitions, symbols and abbreviated terms</title>
+ <terms id='I' obligation='normative'>
+ <title depth='2'>3.1.<tab/>Normal Terms</title>
+ <term id='J'>
+ <name>3.1.1.</name>
+ <preferred>Term2</preferred>
+ </term>
+ </terms>
+ <definitions id='K'>
+ <title>3.2.</title>
+ <dl>
+ <dt>Symbol</dt>
+ <dd>Definition</dd>
+ </dl>
+ </definitions>
+ </clause>
+ <definitions id='L'>
+ <title>4.</title>
+ <dl>
+ <dt>Symbol</dt>
+ <dd>Definition</dd>
+ </dl>
+ </definitions>
+ <clause id='M' inline-header='false' obligation='normative'>
+ <title depth='1'>5.<tab/>Clause 4</title>
+ <clause id='N' inline-header='false' obligation='normative'>
+ <title depth='2'>5.1.<tab/>Introduction</title>
+ </clause>
+ <clause id='O' inline-header='false' obligation='normative'>
+ <title depth='2'>5.2.<tab/>Clause 4.2</title>
+ </clause>
+ </clause>
+ </sections>
+ <annex id='P' inline-header='false' obligation='normative'>
+ <title>
+ <strong>Annex A</strong>
+ <br/>
+ (normative)
+ <br/>
+ <br/>
+ <strong>Annex</strong>
+ </title>
+ <clause id='Q' inline-header='false' obligation='normative'>
+ <title depth='2'>A.1.<tab/>Annex A.1</title>
+ <clause id='Q1' inline-header='false' obligation='normative'>
+ <title depth='3'>A.1.1.<tab/>Annex A.1a</title>
+ </clause>
+ </clause>
+ </annex>
+ <bibliography>
+ <references id='R' obligation='informative' normative='true'>
+ <title depth='1'>2.<tab/>Normative References</title>
+ </references>
+ <clause id='S' obligation='informative'>
+ <title depth="1">Bibliography</title>
+ <references id='T' obligation='informative' normative='false'>
+ <title depth="2">Bibliography Subsection</title>
+ </references>
+ </clause>
+ </bibliography>
+ </iso-standard>
OUTPUT
end
it "processes French" do
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
+ input = <<~"INPUT"
<iso-standard xmlns="http://riboseinc.com/isoxml">
<bibdata>
<language>fr</language>
</bibdata>
<preface>
<foreword obligation="informative">
<title>Foreword</title>
- <p id="A">This is a preamble</p>
+ <p id="A">See <xref target="M"/></p>
</foreword>
<introduction id="B" obligation="informative"><title>Introduction</title><clause id="C" inline-header="false" obligation="informative">
<title>Introduction Subsection</title>
</clause>
</introduction></preface><sections>
- <clause id="D" obligation="normative">
+ <clause id="D" obligation="normative" type="scope">
<title>Scope</title>
<p id="E">Text</p>
</clause>
<clause id="H" obligation="normative"><title>Terms, definitions, symbols and abbreviated terms</title><terms id="I" obligation="normative">
@@ -328,50 +437,141 @@
</clause>
</clause>
</annex><bibliography><references id="R" obligation="informative" normative="true">
<title>Normative References</title>
</references><clause id="S" obligation="informative">
- <title>Bibliography</title>
+ <title>Bibliographie</title>
<references id="T" obligation="informative" normative="false">
<title>Bibliography Subsection</title>
</references>
</clause>
</bibliography>
</iso-standard>
INPUT
+
+ presxml = <<~"PRESXML"
+ <iso-standard xmlns='http://riboseinc.com/isoxml'>
+ <bibdata>
+ <language>fr</language>
+ </bibdata>
+ <preface>
+ <foreword obligation='informative'>
+ <title>Foreword</title>
+ <p id='A'>See <xref target='M'>Article 5</xref></p>
+ </foreword>
+ <introduction id='B' obligation='informative'>
+ <title>Introduction</title>
+ <clause id='C' inline-header='false' obligation='informative'>
+ <title depth='2'>Introduction Subsection</title>
+ </clause>
+ </introduction>
+ </preface>
+ <sections>
+ <clause id='D' obligation='normative' type="scope">
+ <title depth='1'>1.<tab/>Scope</title>
+ <p id='E'>Text</p>
+ </clause>
+ <clause id='H' obligation='normative'>
+ <title depth='1'>3.<tab/>Terms, definitions, symbols and abbreviated terms</title>
+ <terms id='I' obligation='normative'>
+ <title depth='2'>3.1.<tab/>Normal Terms</title>
+ <term id='J'>
+ <name>3.1.1.</name>
+ <preferred>Term2</preferred>
+ </term>
+ </terms>
+ <definitions id='K'>
+ <title>3.2.</title>
+ <dl>
+ <dt>Symbol</dt>
+ <dd>Definition</dd>
+ </dl>
+ </definitions>
+ </clause>
+ <definitions id='L'>
+ <title>4.</title>
+ <dl>
+ <dt>Symbol</dt>
+ <dd>Definition</dd>
+ </dl>
+ </definitions>
+ <clause id='M' inline-header='false' obligation='normative'>
+ <title depth='1'>5.<tab/>Clause 4</title>
+ <clause id='N' inline-header='false' obligation='normative'>
+ <title depth='2'>5.1.<tab/>Introduction</title>
+ </clause>
+ <clause id='O' inline-header='false' obligation='normative'>
+ <title depth='2'>5.2.<tab/>Clause 4.2</title>
+ </clause>
+ </clause>
+ </sections>
+ <annex id='P' inline-header='false' obligation='normative'>
+ <title>
+ <strong>Annexe A</strong>
+ <br/>
+ (normative)
+ <br/>
+ <br/>
+ <strong>Annex</strong>
+ </title>
+ <clause id='Q' inline-header='false' obligation='normative'>
+ <title depth='2'>A.1.<tab/>Annex A.1</title>
+ <clause id='Q1' inline-header='false' obligation='normative'>
+ <title depth='3'>A.1.1.<tab/>Annex A.1a</title>
+ </clause>
+ </clause>
+ </annex>
+ <bibliography>
+ <references id='R' obligation='informative' normative='true'>
+ <title depth='1'>2.<tab/>Normative References</title>
+ </references>
+ <clause id='S' obligation='informative'>
+ <title depth="1">Bibliographie</title>
+ <references id='T' obligation='informative' normative='false'>
+ <title depth="2">Bibliography Subsection</title>
+ </references>
+ </clause>
+ </bibliography>
+ </iso-standard>
+ PRESXML
+
+ output = <<~"OUTPUT"
#{HTML_HDR.gsub(/ lang="en">/, ' lang="fr">')}
<br/>
<div>
- <h1 class="ForewordTitle">Avant-propos</h1>
- <p id="A">This is a preamble</p>
+ <h1 class="ForewordTitle">Foreword</h1>
+ <p id='A'>
+ See
+ <a href='#M'>Article 5</a>
+</p>
</div>
<br/>
<div class="Section3" id="B">
<h1 class="IntroTitle">Introduction</h1>
<div id="C">
<h2>Introduction Subsection</h2>
</div>
</div>
<p class="zzSTDTitle1"/>
<div id="D">
- <h1>1.  Domaine d'application</h1>
+ <h1>1.  Scope</h1>
<p id="E">Text</p>
</div>
<div>
- <h1>2.  Références normatives</h1>
+ <h1>2.  Normative References</h1>
</div>
- <div id="H"><h1>3.  Terms, définitions, symboles et termes abrégés</h1>
+ <div id="H"><h1>3.  Terms, definitions, symbols and abbreviated terms</h1>
<div id="I">
<h2>3.1.  Normal Terms</h2>
<p class="TermNum" id="J">3.1.1.</p>
<p class="Terms" style="text-align:left;">Term2</p>
- </div><div id="K"><h2>3.2.  Symboles et termes abrégés</h2>
+ </div><div id="K"><h2>3.2.</h2>
<dl><dt><p>Symbol</p></dt><dd>Definition</dd></dl>
</div></div>
<div id="L" class="Symbols">
- <h1>4.  Symboles et termes abrégés</h1>
+ <h1>4.</h1>
<dl>
<dt>
<p>Symbol</p>
</dt>
<dd>Definition</dd>
@@ -405,29 +605,31 @@
</div>
</div>
</body>
</html>
OUTPUT
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(output)
end
it "processes Simplified Chinese" do
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
+ input = <<~"INPUT"
<iso-standard xmlns="http://riboseinc.com/isoxml">
<bibdata>
<language>zh</language>
<script>Hans</script>
</bibdata>
<preface>
<foreword obligation="informative">
<title>Foreword</title>
- <p id="A">This is a preamble</p>
+ <p id="A">See <xref target="M"/></p>
</foreword>
<introduction id="B" obligation="informative"><title>Introduction</title><clause id="C" inline-header="false" obligation="informative">
<title>Introduction Subsection</title>
</clause>
</introduction></preface><sections>
- <clause id="D" obligation="normative">
+ <clause id="D" obligation="normative" type="scope">
<title>Scope</title>
<p id="E"><eref type="inline" bibitemid="ISO712"><locality type="table"><referenceFrom>1</referenceFrom><referenceTo>1</referenceTo></locality></eref></p>
</clause>
<clause id="H" obligation="normative"><title>Terms, definitions, symbols and abbreviated terms</title><terms id="I" obligation="normative">
@@ -483,80 +685,447 @@
</references>
</clause>
</bibliography>
</iso-standard>
INPUT
+
+ presxml = <<~"PRESXML"
+ <iso-standard xmlns='http://riboseinc.com/isoxml'>
+ <bibdata>
+ <language>zh</language>
+ <script>Hans</script>
+ </bibdata>
+ <preface>
+ <foreword obligation='informative'>
+ <title>Foreword</title>
+ <p id='A'>See <xref target='M'>条5</xref></p>
+ </foreword>
+ <introduction id='B' obligation='informative'>
+ <title>Introduction</title>
+ <clause id='C' inline-header='false' obligation='informative'>
+ <title depth='2'>Introduction Subsection</title>
+ </clause>
+ </introduction>
+ </preface>
+ <sections>
+ <clause id='D' obligation='normative' type="scope">
+ <title depth='1'>1.<tab/>Scope</title>
+ <p id='E'>
+ <eref type='inline' bibitemid='ISO712'><locality type='table'><referenceFrom>1</referenceFrom><referenceTo>1</referenceTo></locality>ISO 712、第1–1表</eref></p>
+ </clause>
+ <clause id='H' obligation='normative'>
+ <title depth='1'>3.<tab/>Terms, definitions, symbols and abbreviated terms</title>
+ <terms id='I' obligation='normative'>
+ <title depth='2'>3.1.<tab/>Normal Terms</title>
+ <term id='J'>
+ <name>3.1.1.</name>
+ <preferred>Term2</preferred>
+ </term>
+ </terms>
+ <definitions id='K'>
+ <title>3.2.</title>
+ <dl>
+ <dt>Symbol</dt>
+ <dd>Definition</dd>
+ </dl>
+ </definitions>
+ </clause>
+ <definitions id='L'>
+ <title>4.</title>
+ <dl>
+ <dt>Symbol</dt>
+ <dd>Definition</dd>
+ </dl>
+ </definitions>
+ <clause id='M' inline-header='false' obligation='normative'>
+ <title depth='1'>5.<tab/>Clause 4</title>
+ <clause id='N' inline-header='false' obligation='normative'>
+ <title depth='2'>5.1.<tab/>Introduction</title>
+ </clause>
+ <clause id='O' inline-header='false' obligation='normative'>
+ <title depth='2'>5.2.<tab/>Clause 4.2</title>
+ </clause>
+ </clause>
+ </sections>
+ <annex id='P' inline-header='false' obligation='normative'>
+ <title>
+ <strong>附件A</strong>
+ <br/>
+ (规范性附录)
+ <br/>
+ <br/>
+ <strong>Annex</strong>
+ </title>
+ <clause id='Q' inline-header='false' obligation='normative'>
+ <title depth='2'>A.1.<tab/>Annex A.1</title>
+ <clause id='Q1' inline-header='false' obligation='normative'>
+ <title depth='3'>A.1.1.<tab/>Annex A.1a</title>
+ </clause>
+ </clause>
+ </annex>
+ <bibliography>
+ <references id='R' obligation='informative' normative='true'>
+ <title depth='1'>2.<tab/>Normative References</title>
+ <bibitem id='ISO712' type='standard'>
+ <title format='text/plain'>Cereals and cereal products</title>
+ <docidentifier>ISO 712</docidentifier>
+ <contributor>
+ <role type='publisher'/>
+ <organization>
+ <abbreviation>ISO</abbreviation>
+ </organization>
+ </contributor>
+ </bibitem>
+ </references>
+ <clause id='S' obligation='informative'>
+ <title depth="1">Bibliography</title>
+ <references id='T' obligation='informative' normative='false'>
+ <title depth="2">Bibliography Subsection</title>
+ </references>
+ </clause>
+ </bibliography>
+ </iso-standard>
+ PRESXML
+
+ output = <<~"OUTPUT"
#{HTML_HDR.gsub(/ lang="en">/, ' lang="zh">')}
<br/>
<div>
- <h1 class="ForewordTitle">前言</h1>
- <p id="A">This is a preamble</p>
+ <h1 class="ForewordTitle">Foreword</h1>
+ <p id='A'>
+ See
+ <a href='#M'>条5</a>
+</p>
</div>
<br/>
<div class="Section3" id="B">
- <h1 class="IntroTitle">引言</h1>
+ <h1 class="IntroTitle">Introduction</h1>
<div id="C">
<h2>Introduction Subsection</h2>
</div>
</div>
<p class="zzSTDTitle1"/>
<div id="D">
- <h1>1.  范围</h1>
+ <h1>1. Scope</h1>
<p id="E">
- <a href="#ISO712">ISO 712、第1–<referenceto>1</referenceto>表</a>
+ <a href='#ISO712'>ISO 712、第1–1表</a>
</p>
</div>
<div>
- <h1>2.  规范性引用文件</h1>
- <p id="ISO712" class="NormRef">ISO 712, <i> Cereals and cereal products</i></p>
+ <h1>2. Normative References</h1>
+ <p id="ISO712" class="NormRef">ISO 712, <i>Cereals and cereal products</i></p>
</div>
- <div id="H"><h1>3.  术语、定义、符号、代号和缩略语</h1>
+ <div id="H"><h1>3. Terms, definitions, symbols and abbreviated terms</h1>
<div id="I">
- <h2>3.1.  Normal Terms</h2>
+ <h2>3.1. Normal Terms</h2>
<p class="TermNum" id="J">3.1.1.</p>
<p class="Terms" style="text-align:left;">Term2</p>
- </div><div id="K"><h2>3.2.  符号、代号和缩略语</h2>
+ </div><div id="K"><h2>3.2.</h2>
<dl><dt><p>Symbol</p></dt><dd>Definition</dd></dl>
</div></div>
<div id="L" class="Symbols">
- <h1>4.  符号、代号和缩略语</h1>
+ <h1>4.</h1>
<dl>
<dt>
<p>Symbol</p>
</dt>
<dd>Definition</dd>
</dl>
</div>
<div id="M">
- <h1>5.  Clause 4</h1>
+ <h1>5. Clause 4</h1>
<div id="N">
- <h2>5.1.  Introduction</h2>
+ <h2>5.1. Introduction</h2>
</div>
<div id="O">
- <h2>5.2.  Clause 4.2</h2>
+ <h2>5.2. Clause 4.2</h2>
</div>
</div>
<br/>
<div id="P" class="Section3">
- <h1 class="Annex">附件A<br/>(规范性附录)<br/><br/><b>Annex</b></h1>
+ <h1 class="Annex"><b>附件A</b><br/>(规范性附录)<br/><br/><b>Annex</b></h1>
<div id="Q">
- <h2>A.1.  Annex A.1</h2>
+ <h2>A.1. Annex A.1</h2>
<div id="Q1">
- <h3>A.1.1.  Annex A.1a</h3>
+ <h3>A.1.1. Annex A.1a</h3>
</div>
</div>
</div>
<br/>
<div>
- <h1 class="Section3">参考文献</h1>
+ <h1 class="Section3">Bibliography</h1>
<div>
<h2 class="Section3">Bibliography Subsection</h2>
</div>
</div>
</div>
</body>
</html>
OUTPUT
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(output)
end
+ it "processes i18n file" do
+ input = <<~"INPUT"
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
+ <bibdata>
+ <language>eo</language>
+ <script>Latn</script>
+ </bibdata>
+ <preface>
+ <foreword obligation="informative">
+ <title>Foreword</title>
+ <p id="A">See <xref target="M"/></p>
+ </foreword>
+ <introduction id="B" obligation="informative"><title>Introduction</title><clause id="C" inline-header="false" obligation="informative">
+ <title>Introduction Subsection</title>
+ </clause>
+ </introduction></preface><sections>
+ <clause id="D" obligation="normative" type="scope">
+ <title>Scope</title>
+ <p id="E"><eref type="inline" bibitemid="ISO712"><locality type="table"><referenceFrom>1</referenceFrom><referenceTo>1</referenceTo></locality></eref></p>
+ </clause>
+
+ <clause id="H" obligation="normative"><title>Terms, definitions, symbols and abbreviated terms</title><terms id="I" obligation="normative">
+ <title>Normal Terms</title>
+ <term id="J">
+ <preferred>Term2</preferred>
+ </term>
+ </terms>
+ <definitions id="K">
+ <dl>
+ <dt>Symbol</dt>
+ <dd>Definition</dd>
+ </dl>
+ </definitions>
+ </clause>
+ <definitions id="L">
+ <dl>
+ <dt>Symbol</dt>
+ <dd>Definition</dd>
+ </dl>
+ </definitions>
+ <clause id="M" inline-header="false" obligation="normative"><title>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
+ <title>Introduction</title>
+ </clause>
+ <clause id="O" inline-header="false" obligation="normative">
+ <title>Clause 4.2</title>
+ </clause></clause>
+
+ </sections><annex id="P" inline-header="false" obligation="normative">
+ <title>Annex</title>
+ <clause id="Q" inline-header="false" obligation="normative">
+ <title>Annex A.1</title>
+ <clause id="Q1" inline-header="false" obligation="normative">
+ <title>Annex A.1a</title>
+ </clause>
+ </clause>
+ </annex><bibliography><references id="R" obligation="informative" normative="true">
+ <title>Normative References</title>
+ <bibitem id="ISO712" type="standard">
+ <title format="text/plain">Cereals and cereal products</title>
+ <docidentifier>ISO 712</docidentifier>
+ <contributor>
+ <role type="publisher"/>
+ <organization>
+ <abbreviation>ISO</abbreviation>
+ </organization>
+ </contributor>
+</bibitem>
+ </references><clause id="S" obligation="informative">
+ <title>Bibliography</title>
+ <references id="T" obligation="informative" normative="false">
+ <title>Bibliography Subsection</title>
+ </references>
+ </clause>
+ </bibliography>
+ </iso-standard>
+ INPUT
+
+ presxml = <<~OUTPUT
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
+ <bibdata>
+ <language>eo</language>
+ <script>Latn</script>
+ </bibdata>
+ <preface>
+ <foreword obligation="informative">
+ <title>Foreword</title>
+ <p id='A'>See <xref target='M'>klaŭzo 5</xref></p>
+ </foreword>
+ <introduction id="B" obligation="informative"><title>Introduction</title><clause id="C" inline-header="false" obligation="informative">
+ <title depth="2">Introduction Subsection</title>
+ </clause>
+ </introduction></preface><sections>
+ <clause id="D" obligation="normative" type="scope">
+ <title depth="1">1.<tab/>Scope</title>
+ <p id="E"><eref type="inline" bibitemid="ISO712"><locality type="table"><referenceFrom>1</referenceFrom><referenceTo>1</referenceTo></locality>ISO 712, Tabelo 1–1</eref></p>
+ </clause>
+
+ <clause id="H" obligation="normative"><title depth="1">3.<tab/>Terms, definitions, symbols and abbreviated terms</title><terms id="I" obligation="normative">
+ <title depth="2">3.1.<tab/>Normal Terms</title>
+ <term id="J"><name>3.1.1.</name>
+ <preferred>Term2</preferred>
+ </term>
+ </terms>
+ <definitions id="K"><title>3.2.</title>
+ <dl>
+ <dt>Symbol</dt>
+ <dd>Definition</dd>
+ </dl>
+ </definitions>
+ </clause>
+ <definitions id="L"><title>4.</title>
+ <dl>
+ <dt>Symbol</dt>
+ <dd>Definition</dd>
+ </dl>
+ </definitions>
+ <clause id="M" inline-header="false" obligation="normative"><title depth="1">5.<tab/>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
+ <title depth="2">5.1.<tab/>Introduction</title>
+ </clause>
+ <clause id="O" inline-header="false" obligation="normative">
+ <title depth="2">5.2.<tab/>Clause 4.2</title>
+ </clause></clause>
+
+ </sections><annex id="P" inline-header="false" obligation="normative">
+ <title><strong>Aldono A</strong><br/>(normative)<br/><br/><strong>Annex</strong></title>
+ <clause id="Q" inline-header="false" obligation="normative">
+ <title depth="2">A.1.<tab/>Annex A.1</title>
+ <clause id="Q1" inline-header="false" obligation="normative">
+ <title depth="3">A.1.1.<tab/>Annex A.1a</title>
+ </clause>
+ </clause>
+ </annex><bibliography><references id="R" obligation="informative" normative="true">
+ <title depth="1">2.<tab/>Normative References</title>
+ <bibitem id="ISO712" type="standard">
+ <title format="text/plain">Cereals and cereal products</title>
+ <docidentifier>ISO 712</docidentifier>
+ <contributor>
+ <role type="publisher"/>
+ <organization>
+ <abbreviation>ISO</abbreviation>
+ </organization>
+ </contributor>
+ </bibitem>
+ </references><clause id="S" obligation="informative">
+ <title depth="1">Bibliography</title>
+ <references id="T" obligation="informative" normative="false">
+ <title depth="2">Bibliography Subsection</title>
+ </references>
+ </clause>
+ </bibliography>
+ </iso-standard>
+ OUTPUT
+
+ output = <<~OUTPUT
+ <html lang='eo'>
+ <head/>
+ <body lang='eo'>
+ <div class='title-section'>
+ <p> </p>
+ </div>
+ <br/>
+ <div class='prefatory-section'>
+ <p> </p>
+ </div>
+ <br/>
+ <div class='main-section'>
+ <br/>
+ <div>
+ <h1 class='ForewordTitle'>Foreword</h1>
+ <p id='A'>
+ See
+ <a href='#M'>klaŭzo 5</a>
+</p>
+ </div>
+ <br/>
+ <div class='Section3' id='B'>
+ <h1 class='IntroTitle'>Introduction</h1>
+ <div id='C'>
+ <h2>Introduction Subsection</h2>
+ </div>
+ </div>
+ <p class='zzSTDTitle1'/>
+ <div id='D'>
+ <h1>1.  Scope</h1>
+ <p id='E'>
+ <a href='#ISO712'>ISO 712, Tabelo 1–1</a>
+ </p>
+ </div>
+ <div>
+ <h1>2.  Normative References</h1>
+ <p id='ISO712' class='NormRef'>
+ ISO 712,
+ <i>Cereals and cereal products</i>
+ </p>
+ </div>
+ <div id='H'>
+ <h1>3.  Terms, definitions, symbols and abbreviated terms</h1>
+ <div id='I'>
+ <h2>3.1.  Normal Terms</h2>
+ <p class='TermNum' id='J'>3.1.1.</p>
+ <p class='Terms' style='text-align:left;'>Term2</p>
+ </div>
+ <div id='K'>
+ <h2>3.2.</h2>
+ <dl>
+ <dt>
+ <p>Symbol</p>
+ </dt>
+ <dd>Definition</dd>
+ </dl>
+ </div>
+ </div>
+ <div id='L' class='Symbols'>
+ <h1>4.</h1>
+ <dl>
+ <dt>
+ <p>Symbol</p>
+ </dt>
+ <dd>Definition</dd>
+ </dl>
+ </div>
+ <div id='M'>
+ <h1>5.  Clause 4</h1>
+ <div id='N'>
+ <h2>5.1.  Introduction</h2>
+ </div>
+ <div id='O'>
+ <h2>5.2.  Clause 4.2</h2>
+ </div>
+ </div>
+ <br/>
+ <div id='P' class='Section3'>
+ <h1 class='Annex'>
+ <b>Aldono A</b>
+ <br/>
+ (normative)
+ <br/>
+ <br/>
+ <b>Annex</b>
+ </h1>
+ <div id='Q'>
+ <h2>A.1.  Annex A.1</h2>
+ <div id='Q1'>
+ <h3>A.1.1.  Annex A.1a</h3>
+ </div>
+ </div>
+ </div>
+ <br/>
+ <div>
+ <h1 class='Section3'>Bibliography</h1>
+ <div>
+ <h2 class='Section3'>Bibliography Subsection</h2>
+ </div>
+ </div>
+ </div>
+ </body>
+ </html>
+ OUTPUT
+
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({i18nyaml: "spec/assets/i18n.yaml"}).convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
+ expect(xmlpp(IsoDoc::HtmlConvert.new({i18nyaml: "spec/assets/i18n.yaml"}).convert("test", presxml, true))).to be_equivalent_to xmlpp(output)
+ end
end