metanorma-iec 1.3.3 → 1.3.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,7 +16,7 @@ module IsoDoc
16
16
  unpublished(docstatus.text) and
17
17
  set(:stageabbr, docstatus["abbreviation"])
18
18
  end
19
- revdate = isoxml.at(ns("//version/revision-date"))
19
+ revdate = isoxml.at(ns("//bibdata/version/revision-date"))
20
20
  set(:revdate, revdate&.text)
21
21
  end
22
22
 
@@ -13,7 +13,7 @@ module IsoDoc
13
13
  super
14
14
  end
15
15
 
16
- def pdf_stylesheet(docxml)
16
+ def pdf_stylesheet(_docxml)
17
17
  "iec.international-standard.xsl"
18
18
  end
19
19
  end
@@ -7,8 +7,8 @@ module IsoDoc
7
7
  def clause(docxml)
8
8
  docxml.xpath(ns("//clause[not(ancestor::annex)] | "\
9
9
  "//definitions | //references | "\
10
- "//preface/introduction[clause]")).
11
- each do |f|
10
+ "//preface/introduction[clause]"))
11
+ .each do |f|
12
12
  clause1(f)
13
13
  end
14
14
  docxml.xpath(ns("//terms")).each do |f|
@@ -16,27 +16,28 @@ module IsoDoc
16
16
  end
17
17
  end
18
18
 
19
- def termclause1(f)
20
- return clause1(f) unless @is_iev
21
- return if @suppressheadingnumbers || f["unnumbered"]
22
- lbl = @xrefs.anchor(f['id'], :label, true) or return
23
- prefix_name(f, " ", "#{lbl}#{clausedelim}", "title")
19
+ def termclause1(elem)
20
+ return clause1(elem) unless @is_iev
21
+ return if @suppressheadingnumbers || elem["unnumbered"]
22
+
23
+ lbl = @xrefs.anchor(elem["id"], :label, true) or return
24
+ prefix_name(elem, " ", "#{lbl}#{clausedelim}", "title")
24
25
  end
25
26
 
26
- def clause1(f)
27
- IsoDoc::PresentationXMLConvert.instance_method(:clause1).bind(self).
28
- call(f)
27
+ def clause1(elem)
28
+ IsoDoc::PresentationXMLConvert.instance_method(:clause1).bind(self)
29
+ .call(elem)
29
30
  end
30
31
 
31
- def bibdata_i18n(b)
32
+ def bibdata_i18n(bib)
32
33
  fr = IsoDoc::Iec::I18n.new("fr", "Latn")
33
34
  en = IsoDoc::Iec::I18n.new("en", "Latn")
34
35
  [{ lang: "en", i18n: en }, { lang: "fr", i18n: fr }].each do |v|
35
- hash_translate(b, v[:i18n].get["doctype_dict"], "./ext/doctype", v[:lang])
36
- hash_translate(b, v[:i18n].get["stage_dict"], "./status/stage", v[:lang])
37
- hash_translate(b, v[:i18n].get["substage_dict"], "./status/substage", v[:lang])
38
- hash_translate(b, v[:i18n].get["function_dict"], "./ext/function", v[:lang])
39
- hash_translate(b, v[:i18n].get["horizontal_dict"], "./ext/horizontal", v[:lang])
36
+ { doctype_dict: "./ext/doctype", stage_dict: "./status/stage",
37
+ substage_dict: "./status/substage", function_dict: "./ext/function",
38
+ horizontal_dict: "./ext/horizontal" }.each do |lbl, xpath|
39
+ hash_translate(bib, v[:i18n].get[lbl.to_s], xpath, v[:lang])
40
+ end
40
41
  end
41
42
  end
42
43
 
@@ -44,4 +45,3 @@ module IsoDoc
44
45
  end
45
46
  end
46
47
  end
47
-
@@ -11,10 +11,16 @@ module IsoDoc
11
11
  @libdir = File.dirname(__FILE__)
12
12
  end
13
13
 
14
+ def font_choice(options)
15
+ if options[:script] == "Hans" then '"Source Han Sans",serif'
16
+ else '"Arial",sans-serif'
17
+ end
18
+ end
19
+
14
20
  def default_fonts(options)
15
21
  {
16
- bodyfont: (options[:script] == "Hans" ? '"Source Han Sans",serif' : '"Arial",sans-serif'),
17
- headerfont: (options[:script] == "Hans" ? '"Source Han Sans",sans-serif' : '"Arial",sans-serif'),
22
+ bodyfont: font_choice(options),
23
+ headerfont: font_choice(options),
18
24
  monospacefont: '"Courier New",monospace',
19
25
  normalfontsize: "10.0pt",
20
26
  footnotefontsize: "8.0pt",
@@ -23,7 +29,7 @@ module IsoDoc
23
29
  }
24
30
  end
25
31
 
26
- def default_file_locations(options)
32
+ def default_file_locations(_options)
27
33
  @libdir = File.dirname(__FILE__)
28
34
  {
29
35
  wordstylesheet: html_doc_path("wordstyle.scss"),
@@ -70,7 +76,7 @@ module IsoDoc
70
76
  toc += word_toc_entry(1, header_strip(h))
71
77
  end
72
78
  toc.sub(/(<p class="MsoToc1">)/,
73
- %{\\1#{WORD_TOC_TABLE_PREFACE1}}) + WORD_TOC_SUFFIX1
79
+ %{\\1#{WORD_TOC_TABLE_PREFACE1}}) + WORD_TOC_SUFFIX1
74
80
  end
75
81
 
76
82
  def make_FigureWordToC(docxml)
@@ -79,11 +85,21 @@ module IsoDoc
79
85
  toc += word_toc_entry(1, header_strip(h))
80
86
  end
81
87
  toc.sub(/(<p class="MsoToc1">)/,
82
- %{\\1#{WORD_TOC_FIGURE_PREFACE1}}) + WORD_TOC_SUFFIX1
88
+ %{\\1#{WORD_TOC_FIGURE_PREFACE1}}) + WORD_TOC_SUFFIX1
89
+ end
90
+
91
+ def word_toc_preface(level)
92
+ <<~TOC.freeze
93
+ <span lang="EN-GB"><span
94
+ style='mso-element:field-begin'></span><span
95
+ style='mso-spacerun:yes'>&#xA0;</span>TOC
96
+ \\o &quot;1-#{level}&quot; \\h \\z \\u <span
97
+ style='mso-element:field-separator'></span></span>
98
+ TOC
83
99
  end
84
100
 
85
- def header_strip(h)
86
- h = h.to_s.gsub(/<\/?p[^>]*>/, "")
101
+ def header_strip(hdr)
102
+ hdr = hdr.to_s.gsub(/<\/?p[^>]*>/, "")
87
103
  super
88
104
  end
89
105
 
@@ -93,10 +109,11 @@ module IsoDoc
93
109
  super
94
110
  end
95
111
 
96
- def make_tr_attr(td, row, totalrows, header)
112
+ def make_tr_attr(cell, row, totalrows, header)
97
113
  ret = super
98
- css_class = (td.name == "th" || header) ? "TABLE-col-heading" : "TABLE-cell"
99
- ret.merge( "class": css_class )
114
+ css_class =
115
+ cell.name == "th" || header ? "TABLE-col-heading" : "TABLE-cell"
116
+ ret.merge("class": css_class)
100
117
  end
101
118
 
102
119
  def tr_parse(node, out, ord, totalrows, header)
@@ -122,7 +139,8 @@ module IsoDoc
122
139
 
123
140
  def word_table_cleanup1(docxml, style)
124
141
  %w(td th).each do |tdh|
125
- docxml.xpath("//#{tdh}[@class = '#{style}'][not(descendant::p)]").each do |td|
142
+ docxml.xpath("//#{tdh}[@class = '#{style}'][not(descendant::p)]")
143
+ .each do |td|
126
144
  p = Nokogiri::XML::Element.new("p", docxml)
127
145
  td.children.each { |c| c.parent = p }
128
146
  p.parent = td
@@ -148,7 +166,7 @@ module IsoDoc
148
166
  end
149
167
 
150
168
  # Incredibly, the numbered boilerplate list in IEC is NOT A LIST,
151
- # and it violates numbering conventions for ordered lists
169
+ # and it violates numbering conventions for ordered lists
152
170
  # (arabic not alpha)
153
171
  BOILERPLATE_PARAS = "//div[@class = 'boilerplate_legal']//li/p".freeze
154
172
 
@@ -156,7 +174,8 @@ module IsoDoc
156
174
  docxml.xpath(BOILERPLATE_PARAS).each_with_index do |l, i|
157
175
  l["class"] = "FOREWORD"
158
176
  l.children.first.add_previous_sibling(
159
- %{#{i+1})<span style="mso-tab-count:1">&#xA0; </span>})
177
+ %{#{i + 1})<span style="mso-tab-count:1">&#xA0; </span>},
178
+ )
160
179
  end
161
180
  docxml.xpath("//div[@class = 'boilerplate_legal']//li").each do |l|
162
181
  l.replace(l.children)
@@ -166,24 +185,55 @@ module IsoDoc
166
185
  end
167
186
 
168
187
  def authority_cleanup(docxml)
169
- auth = docxml.at("//div[@id = 'boilerplate-feedback' or @class = 'boilerplate-feedback']")
188
+ auth = docxml.at("//div[@id = 'boilerplate-feedback' or "\
189
+ "@class = 'boilerplate-feedback']")
170
190
  auth&.remove
171
191
  super
172
192
  end
173
193
 
174
- def make_body1(body, _docxml)
194
+ def make_body1(body, _docxml); end
195
+
196
+ def word_cover(docxml); end
197
+
198
+ def style_cleanup(docxml); end
199
+
200
+ def bibliography_attrs
201
+ { class: "Section3" }
202
+ end
203
+
204
+ def termref_attrs
205
+ {}
206
+ end
207
+
208
+ def figure_name_attrs(_node)
209
+ { class: "FigureTitle", style: "text-align:center;" }
210
+ end
211
+
212
+ def table_title_attrs(_node)
213
+ { class: "TableTitle", style: "text-align:center;" }
175
214
  end
176
215
 
177
- def word_cover(docxml)
216
+ def para_class(_node)
217
+ classtype = nil
218
+ classtype = "MsoCommentText" if in_comment
219
+ classtype = "Sourcecode" if @annotation
220
+ classtype
221
+ end
222
+
223
+ def annex_name(_annex, name, div)
224
+ return if name.nil?
225
+
226
+ div.h1 **{ class: "Annex" } do |t|
227
+ name.children.each { |c2| parse(c2, t) }
228
+ end
178
229
  end
179
230
 
180
231
  def formula_parse1(node, out)
181
232
  out.div **attr_code(class: "formula") do |div|
182
- div.p **attr_code(class: "formula") do |p|
233
+ div.p **attr_code(class: "formula") do |_p|
183
234
  insert_tab(div, 1)
184
235
  parse(node.at(ns("./stem")), div)
185
- lbl = node&.at(ns("./name"))&.text
186
- unless lbl.nil?
236
+ if lbl = node&.at(ns("./name"))&.text
187
237
  insert_tab(div, 1)
188
238
  div << "(#{lbl})"
189
239
  end
@@ -1,6 +1,6 @@
1
1
  module Metanorma
2
2
  module Iec
3
- VERSION = "1.3.3".freeze
3
+ VERSION = "1.3.7".freeze
4
4
  end
5
5
  end
6
6
 
@@ -25,9 +25,9 @@ Gem::Specification.new do |spec|
25
25
  spec.require_paths = ["lib"]
26
26
  spec.files = `git ls-files`.split("\n")
27
27
  spec.test_files = `git ls-files -- {spec}/*`.split("\n")
28
- spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
28
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
29
29
 
30
- spec.add_dependency "metanorma-iso", "~> 1.8.0"
30
+ spec.add_dependency "metanorma-iso", "~> 1.9.0"
31
31
  spec.add_dependency "ruby-jing"
32
32
 
33
33
  spec.add_development_dependency "byebug"
@@ -1,7 +1,5 @@
1
1
  require "spec_helper"
2
2
 
3
- OPTIONS = [backend: :iec, header_footer: true].freeze
4
-
5
3
  RSpec.describe Asciidoctor::Iec do
6
4
  before(:all) do
7
5
  @blank_hdr = blank_hdr_gen
@@ -179,7 +179,7 @@ RSpec.describe IsoDoc::Iec do
179
179
  INPUT
180
180
  <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
181
181
  <preface>
182
- <foreword>
182
+ <foreword displayorder="1">
183
183
  <p>
184
184
  <xref target='N1'>Clause 1, Equation (1)</xref>
185
185
  <xref target='N2'>1.1, Inequality (2)</xref>
@@ -187,7 +187,7 @@ RSpec.describe IsoDoc::Iec do
187
187
  </foreword>
188
188
  </preface>
189
189
  <sections>
190
- <clause id='intro'>
190
+ <clause id='intro' displayorder="2">
191
191
  <title depth='1'>
192
192
  1
193
193
  <tab/>
@@ -75,164 +75,156 @@ RSpec.describe IsoDoc do
75
75
  </clause>
76
76
  </bibliography>
77
77
  </iso-standard>
78
- INPUT
78
+ INPUT
79
79
 
80
- presxml = <<~OUTPUT
81
- <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
82
- <bibdata>
83
- <docnumber>1</docnumber>
84
- <language current="true">en</language>
85
- <ext>
86
- <doctype language=''>international-standard</doctype>
87
- <doctype language='fr'>Norme international</doctype>
88
- <doctype language='en'>International Standard</doctype>
89
- <horizontal language=''>true</horizontal>
90
- <horizontal language='fr'>Norme horizontale</horizontal>
91
- <horizontal language='en'>Horizontal Standard</horizontal>
92
- <function language=''>emc</function>
93
- <function language='fr'>Publication fondamentale en CEM</function>
94
- <function language='en'>Basic EMC Publication</function>
95
- </ext>
96
- </bibdata>
97
- <preface>
98
- <foreword obligation="informative">
99
- <title>Foreword</title>
100
- <p id="A">This is a preamble</p>
101
- </foreword>
102
- <introduction id="B" obligation="informative"><title depth="1">0<tab/>Introduction</title><clause id="C" inline-header="false" obligation="informative">
103
- <title depth="2">0.1<tab/>Introduction Subsection</title>
104
- </clause>
105
- <p>This is patent boilerplate</p>
106
- </introduction></preface><sections>
107
- <clause id="D" obligation="normative" type="scope">
108
- <title depth="1">1<tab/>Scope</title>
109
- <p id="E">Text</p>
110
- </clause>
111
-
112
- <clause id="H" obligation="normative"><title depth="1">3<tab/>Terms, definitions, symbols and abbreviated terms</title><terms id="I" obligation="normative">
113
- <title depth="2">3.1<tab/>Normal Terms</title>
114
- <term id="J"><name>3.1.1</name>
115
- <preferred>Term2</preferred>
116
- </term>
117
- </terms>
118
- <definitions id="K"><title>3.2</title>
119
- <dl>
120
- <dt>Symbol</dt>
121
- <dd>Definition</dd>
122
- </dl>
123
- </definitions>
124
- </clause>
125
- <definitions id="L"><title>4</title>
126
- <dl>
127
- <dt>Symbol</dt>
128
- <dd>Definition</dd>
129
- </dl>
130
- </definitions>
131
- <clause id="M" inline-header="false" obligation="normative"><title depth="1">5<tab/>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
132
- <title depth="2">5.1<tab/>Introduction</title>
133
- </clause>
134
- <clause id="O" inline-header="false" obligation="normative">
135
- <title depth="2">5.2<tab/>Clause 4.2</title>
136
- </clause></clause>
137
-
138
- </sections><annex id="P" inline-header="false" obligation="normative">
139
- <title><strong>Annex A</strong><br/>(normative)<br/><br/><strong>Annex</strong></title>
140
- <clause id="Q" inline-header="false" obligation="normative">
141
- <title depth="2">A.1<tab/>Annex A.1</title>
142
- <clause id="Q1" inline-header="false" obligation="normative">
143
- <title depth="3">A.1.1<tab/>Annex A.1a</title>
144
- </clause>
145
- </clause>
146
- <appendix id="Q2" inline-header="false" obligation="normative">
147
- <title depth="2">Appendix 1<tab/>An Appendix</title>
148
- </appendix>
149
- </annex><bibliography><references id="R" obligation="informative" normative="true">
150
- <title depth="1">2<tab/>Normative References</title>
151
- </references><clause id="S" obligation="informative">
152
- <title depth="1">Bibliography</title>
153
- <references id="T" obligation="informative" normative="false">
154
- <title depth="2">Bibliography Subsection</title>
155
- </references>
156
- </clause>
157
- </bibliography>
158
- </iso-standard>
159
- OUTPUT
160
-
161
- html = <<~OUTPUT
162
- #{HTML_HDR}
163
- <div>
164
- <h1 class="ForewordTitle">FOREWORD</h1>
165
- <div class="boilerplate_legal"/>
166
- <p id="A">This is a preamble</p>
167
- </div>
168
- <br/>
169
- <div class="Section3" id="B">
170
- <h1 class="IntroTitle">0&#160; Introduction</h1>
171
- <div id="C"><h2>0.1&#160; Introduction Subsection</h2>
172
-
173
- </div>
174
- <p>This is patent boilerplate</p>
175
- </div>
176
- #{IEC_TITLE1}
177
- <div id="D">
178
- <h1>1&#160; Scope</h1>
179
- <p id="E">Text</p>
180
- </div>
181
- <div>
182
- <h1>2&#160; Normative References</h1>
183
- </div>
184
- <div id="H"><h1>3&#160; Terms, definitions, symbols and abbreviated terms</h1>
185
- <div id="I"><h2>3.1&#160; Normal Terms</h2>
186
-
187
- <p class="TermNum" id="J">3.1.1</p>
188
- <p class="Terms" style="text-align:left;">Term2</p>
189
-
190
- </div><div id="K"><h2>3.2</h2>
191
- <dl><dt><p>Symbol</p></dt><dd>Definition</dd></dl>
192
- </div></div>
193
- <div id="L" class="Symbols">
194
- <h1>4</h1>
195
- <dl>
196
- <dt>
197
- <p>Symbol</p>
198
- </dt>
199
- <dd>Definition</dd>
200
- </dl>
201
- </div>
202
- <div id="M">
203
- <h1>5&#160; Clause 4</h1>
204
- <div id="N"><h2>5.1&#160; Introduction</h2>
205
-
206
- </div>
207
- <div id="O"><h2>5.2&#160; Clause 4.2</h2>
208
-
209
- </div>
210
- </div>
211
- <br/>
212
- <div id="P" class="Section3">
213
- <h1 class="Annex"><b>Annex A</b><br/>(normative)<br/><br/><b>Annex</b></h1>
214
- <div id="Q"><h2>A.1&#160; Annex A.1</h2>
215
-
216
- <div id="Q1"><h3>A.1.1&#160; Annex A.1a</h3>
80
+ presxml = <<~OUTPUT
81
+ <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
82
+ <bibdata>
83
+ <docnumber>1</docnumber>
84
+ <language current="true">en</language>
85
+ <ext>
86
+ <doctype language="">international-standard</doctype><doctype language="fr">Norme international</doctype><doctype language="en">International Standard</doctype>
87
+ <horizontal language="">true</horizontal><horizontal language="fr">Norme horizontale</horizontal><horizontal language="en">Horizontal Standard</horizontal>
88
+ <function language="">emc</function><function language="fr">Publication fondamentale en CEM</function><function language="en">Basic EMC Publication</function>
89
+ </ext>
90
+ </bibdata>
91
+ <preface>
92
+ <foreword obligation="informative" displayorder="1">
93
+ <title>Foreword</title>
94
+ <p id="A">This is a preamble</p>
95
+ </foreword>
96
+ <introduction id="B" obligation="informative" displayorder="2"><title depth="1">0<tab/>Introduction</title><clause id="C" inline-header="false" obligation="informative">
97
+ <title depth="2">0.1<tab/>Introduction Subsection</title>
98
+ </clause>
99
+ <p>This is patent boilerplate</p>
100
+ </introduction></preface><sections>
101
+ <clause id="D" obligation="normative" type="scope" displayorder="3">
102
+ <title depth="1">1<tab/>Scope</title>
103
+ <p id="E">Text</p>
104
+ </clause>
105
+ <clause id="H" obligation="normative" displayorder="5"><title depth="1">3<tab/>Terms, definitions, symbols and abbreviated terms</title><terms id="I" obligation="normative">
106
+ <title depth="2">3.1<tab/>Normal Terms</title>
107
+ <term id="J"><name>3.1.1</name>
108
+ <preferred>Term2</preferred>
109
+ </term>
110
+ </terms>
111
+ <definitions id="K"><title>3.2</title>
112
+ <dl>
113
+ <dt>Symbol</dt>
114
+ <dd>Definition</dd>
115
+ </dl>
116
+ </definitions>
117
+ </clause>
118
+ <definitions id="L" displayorder="6"><title>4</title>
119
+ <dl>
120
+ <dt>Symbol</dt>
121
+ <dd>Definition</dd>
122
+ </dl>
123
+ </definitions>
124
+ <clause id="M" inline-header="false" obligation="normative" displayorder="7"><title depth="1">5<tab/>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
125
+ <title depth="2">5.1<tab/>Introduction</title>
126
+ </clause>
127
+ <clause id="O" inline-header="false" obligation="normative">
128
+ <title depth="2">5.2<tab/>Clause 4.2</title>
129
+ </clause></clause>
130
+ </sections><annex id="P" inline-header="false" obligation="normative" displayorder="8">
131
+ <title><strong>Annex A</strong><br/>(normative)<br/><br/><strong>Annex</strong></title>
132
+ <clause id="Q" inline-header="false" obligation="normative">
133
+ <title depth="2">A.1<tab/>Annex A.1</title>
134
+ <clause id="Q1" inline-header="false" obligation="normative">
135
+ <title depth="3">A.1.1<tab/>Annex A.1a</title>
136
+ </clause>
137
+ </clause>
138
+ <appendix id="Q2" inline-header="false" obligation="normative">
139
+ <title depth="2">Appendix 1<tab/>An Appendix</title>
140
+ </appendix>
141
+ </annex><bibliography><references id="R" obligation="informative" normative="true" displayorder="4">
142
+ <title depth="1">2<tab/>Normative References</title>
143
+ </references><clause id="S" obligation="informative" displayorder="9">
144
+ <title depth="1">Bibliography</title>
145
+ <references id="T" obligation="informative" normative="false">
146
+ <title depth="2">Bibliography Subsection</title>
147
+ </references>
148
+ </clause>
149
+ </bibliography>
150
+ </iso-standard>
151
+ OUTPUT
217
152
 
153
+ html = <<~OUTPUT
154
+ #{HTML_HDR}
155
+ <div>
156
+ <h1 class="ForewordTitle">FOREWORD</h1>
157
+ <div class="boilerplate_legal"/>
158
+ <p id="A">This is a preamble</p>
159
+ </div>
160
+ <br/>
161
+ <div class="Section3" id="B">
162
+ <h1 class="IntroTitle">0&#160; Introduction</h1>
163
+ <div id="C"><h2>0.1&#160; Introduction Subsection</h2>
164
+
165
+ </div>
166
+ <p>This is patent boilerplate</p>
167
+ </div>
168
+ #{IEC_TITLE1}
169
+ <div id="D">
170
+ <h1>1&#160; Scope</h1>
171
+ <p id="E">Text</p>
172
+ </div>
173
+ <div>
174
+ <h1>2&#160; Normative References</h1>
175
+ </div>
176
+ <div id="H"><h1>3&#160; Terms, definitions, symbols and abbreviated terms</h1>
177
+ <div id="I"><h2>3.1&#160; Normal Terms</h2>
178
+
179
+ <p class="TermNum" id="J">3.1.1</p>
180
+ <p class="Terms" style="text-align:left;">Term2</p>
181
+
182
+ </div><div id="K"><h2>3.2</h2>
183
+ <dl><dt><p>Symbol</p></dt><dd>Definition</dd></dl>
184
+ </div></div>
185
+ <div id="L" class="Symbols">
186
+ <h1>4</h1>
187
+ <dl>
188
+ <dt>
189
+ <p>Symbol</p>
190
+ </dt>
191
+ <dd>Definition</dd>
192
+ </dl>
193
+ </div>
194
+ <div id="M">
195
+ <h1>5&#160; Clause 4</h1>
196
+ <div id="N"><h2>5.1&#160; Introduction</h2>
197
+
198
+ </div>
199
+ <div id="O"><h2>5.2&#160; Clause 4.2</h2>
200
+
201
+ </div>
202
+ </div>
203
+ <br/>
204
+ <div id="P" class="Section3">
205
+ <h1 class="Annex"><b>Annex A</b><br/>(normative)<br/><br/><b>Annex</b></h1>
206
+ <div id="Q"><h2>A.1&#160; Annex A.1</h2>
207
+
208
+ <div id="Q1"><h3>A.1.1&#160; Annex A.1a</h3>
209
+
210
+ </div>
211
+ </div>
212
+ <div id="Q2"><h2>Appendix 1&#160; An Appendix</h2>
213
+
214
+ </div>
215
+ </div>
216
+ <br/>
217
+ <div>
218
+ <h1 class="Section3">Bibliography</h1>
219
+ <div>
220
+ <h2 class="Section3">Bibliography Subsection</h2>
221
+ </div>
222
+ </div>
218
223
  </div>
219
- </div>
220
- <div id="Q2"><h2>Appendix 1&#160; An Appendix</h2>
221
-
222
- </div>
223
- </div>
224
- <br/>
225
- <div>
226
- <h1 class="Section3">Bibliography</h1>
227
- <div>
228
- <h2 class="Section3">Bibliography Subsection</h2>
229
- </div>
230
- </div>
231
- </div>
232
- </body>
233
- </html>
224
+ </body>
225
+ </html>
234
226
  OUTPUT
235
- expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({}).convert("test", input, true).sub(%r{<localized-strings>.*</localized-strings>}m, ""))).to be_equivalent_to xmlpp(presxml)
227
+ expect((IsoDoc::Iec::PresentationXMLConvert.new({}).convert("test", input, true).sub(%r{<localized-strings>.*</localized-strings>}m, ""))).to be_equivalent_to xmlpp(presxml)
236
228
  expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
237
229
  end
238
230
 
@@ -304,141 +296,70 @@ RSpec.describe IsoDoc do
304
296
  </clause>
305
297
  </bibliography>
306
298
  </iso-standard>
307
- INPUT
308
- <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
309
- <bibdata>
310
- <language current="true">tlh</language>
311
- </bibdata>
312
- <preface>
313
- <foreword obligation='informative'>
314
- <title>Foreword</title>
315
- <p id='A'>This is a preamble</p>
316
- </foreword>
317
- <introduction id='B' obligation='informative'>
318
- <title depth='1'>
319
- 0
320
- <tab/>
321
- Introduction
322
- </title>
323
- <clause id='C' inline-header='false' obligation='informative'>
324
- <title depth='2'>
325
- 0.1
326
- <tab/>
327
- Introduction Subsection
328
- </title>
329
- </clause>
330
- <p>This is patent boilerplate</p>
331
- </introduction>
332
- </preface>
333
- <sections>
334
- <clause id='D' obligation='normative' type="scope">
335
- <title depth='1'>
336
- 1
337
- <tab/>
338
- Scope
339
- </title>
340
- <p id='E'>Text</p>
341
- </clause>
342
- <clause id='H' obligation='normative'>
343
- <title depth='1'>
344
- 3
345
- <tab/>
346
- Terms, definitions, symbols and abbreviated terms
347
- </title>
348
- <terms id='I' obligation='normative'>
349
- <title depth='2'>
350
- 3.1
351
- <tab/>
352
- Normal Terms
353
- </title>
354
- <term id='J'>
355
- <name>3.1.1</name>
356
- <preferred>Term2</preferred>
357
- </term>
358
- </terms>
359
- <definitions id='K'>
360
- <title>3.2</title>
361
- <dl>
362
- <dt>Symbol</dt>
363
- <dd>Definition</dd>
364
- </dl>
365
- </definitions>
366
- </clause>
367
- <definitions id='L'>
368
- <title>4</title>
369
- <dl>
370
- <dt>Symbol</dt>
371
- <dd>Definition</dd>
372
- </dl>
373
- </definitions>
374
- <clause id='M' inline-header='false' obligation='normative'>
375
- <title depth='1'>
376
- 5
377
- <tab/>
378
- Clause 4
379
- </title>
380
- <clause id='N' inline-header='false' obligation='normative'>
381
- <title depth='2'>
382
- 5.1
383
- <tab/>
384
- Introduction
385
- </title>
386
- </clause>
387
- <clause id='O' inline-header='false' obligation='normative'>
388
- <title depth='2'>
389
- 5.2
390
- <tab/>
391
- Clause 4.2
392
- </title>
393
- </clause>
394
- </clause>
395
- </sections>
396
- <annex id='P' inline-header='false' obligation='normative'>
397
- <title>
398
- <strong>Annex A</strong>
399
- <br/>
400
- (normative)
401
- <br/>
402
- <br/>
403
- <strong>Annex</strong>
404
- </title>
405
- <clause id='Q' inline-header='false' obligation='normative'>
406
- <title depth='2'>
407
- A.1
408
- <tab/>
409
- Annex A.1
410
- </title>
411
- <clause id='Q1' inline-header='false' obligation='normative'>
412
- <title depth='3'>
413
- A.1.1
414
- <tab/>
415
- Annex A.1a
416
- </title>
417
- </clause>
418
- </clause>
419
- <appendix id='Q2' inline-header='false' obligation='normative'>
420
- <title depth='2'>
421
- Appendix 1
422
- <tab/>
423
- An Appendix
424
- </title>
425
- </appendix>
426
- </annex>
427
- <bibliography>
428
- <references id='R' obligation='informative' normative='true'>
429
- <title depth='1'>
430
- 2
431
- <tab/>
432
- Normative References
433
- </title>
434
- </references>
435
- <clause id='S' obligation='informative'>
436
- <title depth='1'>Bibliography</title>
437
- <references id='T' obligation='informative' normative='false'>
438
- <title depth='2'>Bibliography Subsection</title>
439
- </references>
440
- </clause>
441
- </bibliography>
299
+ INPUT
300
+ <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
301
+ <bibdata>
302
+ <language current="true">tlh</language>
303
+ </bibdata>
304
+ <preface>
305
+ <foreword obligation="informative" displayorder="1">
306
+ <title>Foreword</title>
307
+ <p id="A">This is a preamble</p>
308
+ </foreword>
309
+ <introduction id="B" obligation="informative" displayorder="2"><title depth="1">0<tab/>Introduction</title><clause id="C" inline-header="false" obligation="informative">
310
+ <title depth="2">0.1<tab/>Introduction Subsection</title>
311
+ </clause>
312
+ <p>This is patent boilerplate</p>
313
+ </introduction></preface><sections>
314
+ <clause id="D" obligation="normative" type="scope" displayorder="3">
315
+ <title depth="1">1<tab/>Scope</title>
316
+ <p id="E">Text</p>
317
+ </clause>
318
+ <clause id="H" obligation="normative" displayorder="5"><title depth="1">3<tab/>Terms, definitions, symbols and abbreviated terms</title><terms id="I" obligation="normative">
319
+ <title depth="2">3.1<tab/>Normal Terms</title>
320
+ <term id="J"><name>3.1.1</name>
321
+ <preferred>Term2</preferred>
322
+ </term>
323
+ </terms>
324
+ <definitions id="K"><title>3.2</title>
325
+ <dl>
326
+ <dt>Symbol</dt>
327
+ <dd>Definition</dd>
328
+ </dl>
329
+ </definitions>
330
+ </clause>
331
+ <definitions id="L" displayorder="6"><title>4</title>
332
+ <dl>
333
+ <dt>Symbol</dt>
334
+ <dd>Definition</dd>
335
+ </dl>
336
+ </definitions>
337
+ <clause id="M" inline-header="false" obligation="normative" displayorder="7"><title depth="1">5<tab/>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
338
+ <title depth="2">5.1<tab/>Introduction</title>
339
+ </clause>
340
+ <clause id="O" inline-header="false" obligation="normative">
341
+ <title depth="2">5.2<tab/>Clause 4.2</title>
342
+ </clause></clause>
343
+ </sections><annex id="P" inline-header="false" obligation="normative" displayorder="8">
344
+ <title><strong>Annex A</strong><br/>(normative)<br/><br/><strong>Annex</strong></title>
345
+ <clause id="Q" inline-header="false" obligation="normative">
346
+ <title depth="2">A.1<tab/>Annex A.1</title>
347
+ <clause id="Q1" inline-header="false" obligation="normative">
348
+ <title depth="3">A.1.1<tab/>Annex A.1a</title>
349
+ </clause>
350
+ </clause>
351
+ <appendix id="Q2" inline-header="false" obligation="normative">
352
+ <title depth="2">Appendix 1<tab/>An Appendix</title>
353
+ </appendix>
354
+ </annex><bibliography><references id="R" obligation="informative" normative="true" displayorder="4">
355
+ <title depth="1">2<tab/>Normative References</title>
356
+ </references><clause id="S" obligation="informative" displayorder="9">
357
+ <title depth="1">Bibliography</title>
358
+ <references id="T" obligation="informative" normative="false">
359
+ <title depth="2">Bibliography Subsection</title>
360
+ </references>
361
+ </clause>
362
+ </bibliography>
442
363
  </iso-standard>
443
364
  OUTPUT
444
365
  end
@@ -516,163 +437,156 @@ RSpec.describe IsoDoc do
516
437
  </clause>
517
438
  </bibliography>
518
439
  </iso-standard>
519
- INPUT
520
-
521
- presxml = <<~OUTPUT
522
- <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
523
- <bibdata>
524
- <language current="true">fr</language>
525
- <ext>
526
- <doctype language=''>international-standard</doctype>
527
- <doctype language='fr'>Norme international</doctype>
528
- <doctype language='en'>International Standard</doctype>
529
- <horizontal language=''>false</horizontal>
530
- <function language=''>emc</function>
531
- <function language='fr'>Publication fondamentale en CEM</function>
532
- <function language='en'>Basic EMC Publication</function>
533
- </ext>
534
- </bibdata>
535
- <preface>
536
- <foreword obligation="informative">
537
- <title>Foreword</title>
538
- <p id="A">This is a preamble</p>
539
- </foreword>
540
- <introduction id="B" obligation="informative"><title depth="1">0<tab/>Introduction</title><clause id="C" inline-header="false" obligation="informative">
541
- <title depth="2">0.1<tab/>Introduction Subsection</title>
542
- </clause>
543
- <p>This is patent boilerplate</p>
544
- </introduction></preface><sections>
545
- <clause id="D" obligation="normative" type="scope">
546
- <title depth="1">1<tab/>Scope</title>
547
- <p id="E">Text</p>
548
- </clause>
549
-
550
- <clause id="H" obligation="normative"><title depth="1">3<tab/>Terms, definitions, symbols and abbreviated terms</title><terms id="I" obligation="normative">
551
- <title depth="2">3.1<tab/>Normal Terms</title>
552
- <term id="J"><name>3.1.1</name>
553
- <preferred>Term2</preferred>
554
- </term>
555
- </terms>
556
- <definitions id="K"><title>3.2</title>
557
- <dl>
558
- <dt>Symbol</dt>
559
- <dd>Definition</dd>
560
- </dl>
561
- </definitions>
562
- </clause>
563
- <definitions id="L"><title>4</title>
564
- <dl>
565
- <dt>Symbol</dt>
566
- <dd>Definition</dd>
567
- </dl>
568
- </definitions>
569
- <clause id="M" inline-header="false" obligation="normative"><title depth="1">5<tab/>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
570
- <title depth="2">5.1<tab/>Introduction</title>
571
- </clause>
572
- <clause id="O" inline-header="false" obligation="normative">
573
- <title depth="2">5.2<tab/>Clause 4.2</title>
574
- </clause></clause>
575
-
576
- </sections><annex id="P" inline-header="false" obligation="normative">
577
- <title><strong>Annexe A</strong><br/>(normative)<br/><br/><strong>Annex</strong></title>
578
- <clause id="Q" inline-header="false" obligation="normative">
579
- <title depth="2">A.1<tab/>Annex A.1</title>
580
- <clause id="Q1" inline-header="false" obligation="normative">
581
- <title depth="3">A.1.1<tab/>Annex A.1a</title>
582
- </clause>
583
- </clause>
584
- <appendix id="Q2" inline-header="false" obligation="normative">
585
- <title depth="2">Appendice 1<tab/>An Appendix</title>
586
- </appendix>
587
- </annex><bibliography><references id="R" obligation="informative" normative="true">
588
- <title depth="1">2<tab/>Normative References</title>
589
- </references><clause id="S" obligation="informative">
590
- <title depth="1">Bibliography</title>
591
- <references id="T" obligation="informative" normative="false">
592
- <title depth="2">Bibliography Subsection</title>
593
- </references>
594
- </clause>
595
- </bibliography>
596
- </iso-standard>
597
- OUTPUT
598
-
599
- html = <<~OUTPUT
600
- #{HTML_HDR.sub(/INTERNATIONAL ELECTROTECHNICAL COMMISSION/, "COMMISSION ELECTROTECHNIQUE INTERNATIONALE").
601
- gsub(/"en"/, '"fr"')}
602
- <div>
603
- <h1 class="ForewordTitle">AVANT-PROPOS</h1>
604
- <div class="boilerplate_legal"/>
605
- <p id="A">This is a preamble</p>
606
- </div>
607
- <br/>
608
- <div class="Section3" id="B">
609
- <h1 class="IntroTitle">0&#160; Introduction</h1>
610
- <div id="C"><h2>0.1&#160; Introduction Subsection</h2>
440
+ INPUT
611
441
 
612
- </div>
613
- <p>This is patent boilerplate</p>
614
- </div>
615
- #{IEC_TITLE1}
616
- <div id="D">
617
- <h1>1&#160; Scope</h1>
618
- <p id="E">Text</p>
619
- </div>
620
- <div>
621
- <h1>2&#160; Normative References</h1>
622
- </div>
623
- <div id="H"><h1>3&#160; Terms, definitions, symbols and abbreviated terms</h1>
624
- <div id="I"><h2>3.1&#160; Normal Terms</h2>
442
+ presxml = <<~OUTPUT
443
+ <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
444
+ <bibdata>
445
+ <language current="true">fr</language>
446
+ <ext>
447
+ <doctype language="">international-standard</doctype><doctype language="fr">Norme international</doctype><doctype language="en">International Standard</doctype>
448
+ <horizontal language="">false</horizontal>
449
+ <function language="">emc</function><function language="fr">Publication fondamentale en CEM</function><function language="en">Basic EMC Publication</function>
450
+ </ext>
451
+ </bibdata>
452
+ <preface>
453
+ <foreword obligation="informative" displayorder="1">
454
+ <title>Foreword</title>
455
+ <p id="A">This is a preamble</p>
456
+ </foreword>
457
+ <introduction id="B" obligation="informative" displayorder="2"><title depth="1">0<tab/>Introduction</title><clause id="C" inline-header="false" obligation="informative">
458
+ <title depth="2">0.1<tab/>Introduction Subsection</title>
459
+ </clause>
460
+ <p>This is patent boilerplate</p>
461
+ </introduction></preface><sections>
462
+ <clause id="D" obligation="normative" type="scope" displayorder="3">
463
+ <title depth="1">1<tab/>Scope</title>
464
+ <p id="E">Text</p>
465
+ </clause>
466
+ <clause id="H" obligation="normative" displayorder="5"><title depth="1">3<tab/>Terms, definitions, symbols and abbreviated terms</title><terms id="I" obligation="normative">
467
+ <title depth="2">3.1<tab/>Normal Terms</title>
468
+ <term id="J"><name>3.1.1</name>
469
+ <preferred>Term2</preferred>
470
+ </term>
471
+ </terms>
472
+ <definitions id="K"><title>3.2</title>
473
+ <dl>
474
+ <dt>Symbol</dt>
475
+ <dd>Definition</dd>
476
+ </dl>
477
+ </definitions>
478
+ </clause>
479
+ <definitions id="L" displayorder="6"><title>4</title>
480
+ <dl>
481
+ <dt>Symbol</dt>
482
+ <dd>Definition</dd>
483
+ </dl>
484
+ </definitions>
485
+ <clause id="M" inline-header="false" obligation="normative" displayorder="7"><title depth="1">5<tab/>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
486
+ <title depth="2">5.1<tab/>Introduction</title>
487
+ </clause>
488
+ <clause id="O" inline-header="false" obligation="normative">
489
+ <title depth="2">5.2<tab/>Clause 4.2</title>
490
+ </clause></clause>
491
+ </sections><annex id="P" inline-header="false" obligation="normative" displayorder="8">
492
+ <title><strong>Annexe A</strong><br/>(normative)<br/><br/><strong>Annex</strong></title>
493
+ <clause id="Q" inline-header="false" obligation="normative">
494
+ <title depth="2">A.1<tab/>Annex A.1</title>
495
+ <clause id="Q1" inline-header="false" obligation="normative">
496
+ <title depth="3">A.1.1<tab/>Annex A.1a</title>
497
+ </clause>
498
+ </clause>
499
+ <appendix id="Q2" inline-header="false" obligation="normative">
500
+ <title depth="2">Appendice 1<tab/>An Appendix</title>
501
+ </appendix>
502
+ </annex><bibliography><references id="R" obligation="informative" normative="true" displayorder="4">
503
+ <title depth="1">2<tab/>Normative References</title>
504
+ </references><clause id="S" obligation="informative" displayorder="9">
505
+ <title depth="1">Bibliography</title>
506
+ <references id="T" obligation="informative" normative="false">
507
+ <title depth="2">Bibliography Subsection</title>
508
+ </references>
509
+ </clause>
510
+ </bibliography>
511
+ </iso-standard>
512
+ OUTPUT
625
513
 
626
- <p class="TermNum" id="J">3.1.1</p>
627
- <p class="Terms" style="text-align:left;">Term2</p>
514
+ html = <<~OUTPUT
515
+ #{HTML_HDR.sub(/INTERNATIONAL ELECTROTECHNICAL COMMISSION/, 'COMMISSION ELECTROTECHNIQUE INTERNATIONALE')
516
+ .gsub(/"en"/, '"fr"')}
517
+ <div>
518
+ <h1 class="ForewordTitle">AVANT-PROPOS</h1>
519
+ <div class="boilerplate_legal"/>
520
+ <p id="A">This is a preamble</p>
521
+ </div>
522
+ <br/>
523
+ <div class="Section3" id="B">
524
+ <h1 class="IntroTitle">0&#160; Introduction</h1>
525
+ <div id="C"><h2>0.1&#160; Introduction Subsection</h2>
628
526
 
629
- </div><div id="K"><h2>3.2</h2>
630
- <dl><dt><p>Symbol</p></dt><dd>Definition</dd></dl>
631
- </div></div>
632
- <div id="L" class="Symbols">
633
- <h1>4</h1>
634
- <dl>
635
- <dt>
636
- <p>Symbol</p>
637
- </dt>
638
- <dd>Definition</dd>
639
- </dl>
640
- </div>
641
- <div id="M">
642
- <h1>5&#160; Clause 4</h1>
643
- <div id="N"><h2>5.1&#160; Introduction</h2>
527
+ </div>
528
+ <p>This is patent boilerplate</p>
529
+ </div>
530
+ #{IEC_TITLE1}
531
+ <div id="D">
532
+ <h1>1&#160; Scope</h1>
533
+ <p id="E">Text</p>
534
+ </div>
535
+ <div>
536
+ <h1>2&#160; Normative References</h1>
537
+ </div>
538
+ <div id="H"><h1>3&#160; Terms, definitions, symbols and abbreviated terms</h1>
539
+ <div id="I"><h2>3.1&#160; Normal Terms</h2>
540
+
541
+ <p class="TermNum" id="J">3.1.1</p>
542
+ <p class="Terms" style="text-align:left;">Term2</p>
543
+
544
+ </div><div id="K"><h2>3.2</h2>
545
+ <dl><dt><p>Symbol</p></dt><dd>Definition</dd></dl>
546
+ </div></div>
547
+ <div id="L" class="Symbols">
548
+ <h1>4</h1>
549
+ <dl>
550
+ <dt>
551
+ <p>Symbol</p>
552
+ </dt>
553
+ <dd>Definition</dd>
554
+ </dl>
555
+ </div>
556
+ <div id="M">
557
+ <h1>5&#160; Clause 4</h1>
558
+ <div id="N"><h2>5.1&#160; Introduction</h2>
644
559
 
645
- </div>
646
- <div id="O"><h2>5.2&#160; Clause 4.2</h2>
560
+ </div>
561
+ <div id="O"><h2>5.2&#160; Clause 4.2</h2>
647
562
 
648
- </div>
649
- </div>
650
- <br/>
651
- <div id="P" class="Section3">
652
- <h1 class="Annex"><b>Annexe A</b><br/>(normative)<br/><br/><b>Annex</b></h1>
653
- <div id="Q"><h2>A.1&#160; Annex A.1</h2>
563
+ </div>
564
+ </div>
565
+ <br/>
566
+ <div id="P" class="Section3">
567
+ <h1 class="Annex"><b>Annexe A</b><br/>(normative)<br/><br/><b>Annex</b></h1>
568
+ <div id="Q"><h2>A.1&#160; Annex A.1</h2>
654
569
 
655
- <div id="Q1"><h3>A.1.1&#160; Annex A.1a</h3>
570
+ <div id="Q1"><h3>A.1.1&#160; Annex A.1a</h3>
656
571
 
572
+ </div>
657
573
  </div>
658
- </div>
659
- <div id="Q2"><h2>Appendice 1&#160; An Appendix</h2>
574
+ <div id="Q2"><h2>Appendice 1&#160; An Appendix</h2>
660
575
 
661
- </div>
662
- </div>
663
- <br/>
664
- <div>
665
- <h1 class="Section3">Bibliography</h1>
576
+ </div>
577
+ </div>
578
+ <br/>
666
579
  <div>
667
- <h2 class="Section3">Bibliography Subsection</h2>
580
+ <h1 class="Section3">Bibliography</h1>
581
+ <div>
582
+ <h2 class="Section3">Bibliography Subsection</h2>
583
+ </div>
668
584
  </div>
669
585
  </div>
670
- </div>
671
- </body>
672
- </html>
586
+ </body>
587
+ </html>
673
588
  OUTPUT
674
589
  expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({}).convert("test", input, true).sub(%r{<localized-strings>.*</localized-strings>}m, ""))).to be_equivalent_to xmlpp(presxml)
675
590
  expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
676
591
  end
677
-
678
592
  end