metanorma-iec 1.3.4 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/lib/isodoc/iec/base_convert.rb +20 -14
- data/lib/isodoc/iec/html_convert.rb +6 -6
- data/lib/isodoc/iec/iec.international-standard.xsl +67 -11
- data/lib/isodoc/iec/metadata.rb +1 -1
- data/lib/isodoc/iec/pdf_convert.rb +1 -1
- data/lib/isodoc/iec/presentation_xml_convert.rb +17 -17
- data/lib/isodoc/iec/word_convert.rb +69 -19
- data/lib/metanorma/iec/version.rb +1 -1
- data/metanorma-iec.gemspec +1 -1
- data/spec/asciidoctor/blocks_spec.rb +0 -2
- data/spec/isodoc/blocks_spec.rb +2 -2
- data/spec/isodoc/i18n_spec.rb +346 -432
- data/spec/isodoc/iev_spec.rb +508 -519
- data/spec/isodoc/inline_spec.rb +2 -2
- data/spec/isodoc/ref_spec.rb +6 -6
- data/spec/isodoc/section_spec.rb +334 -339
- data/spec/isodoc/terms_spec.rb +1 -1
- metadata +3 -3
@@ -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
|
17
|
-
headerfont: (options
|
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(
|
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}}) +
|
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}}) +
|
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'> </span>TOC
|
96
|
+
\\o "1-#{level}" \\h \\z \\u <span
|
97
|
+
style='mso-element:field-separator'></span></span>
|
98
|
+
TOC
|
83
99
|
end
|
84
100
|
|
85
|
-
def header_strip(
|
86
|
-
|
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(
|
112
|
+
def make_tr_attr(cell, row, totalrows, header)
|
97
113
|
ret = super
|
98
|
-
css_class =
|
99
|
-
|
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)]")
|
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">  </span>}
|
177
|
+
%{#{i + 1})<span style="mso-tab-count:1">  </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
|
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
|
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 |
|
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
|
data/metanorma-iec.gemspec
CHANGED
@@ -25,7 +25,7 @@ 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.
|
28
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
29
29
|
|
30
30
|
spec.add_dependency "metanorma-iso", "~> 1.8.0"
|
31
31
|
spec.add_dependency "ruby-jing"
|
data/spec/isodoc/blocks_spec.rb
CHANGED
@@ -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/>
|
data/spec/isodoc/i18n_spec.rb
CHANGED
@@ -75,164 +75,156 @@ RSpec.describe IsoDoc do
|
|
75
75
|
</clause>
|
76
76
|
</bibliography>
|
77
77
|
</iso-standard>
|
78
|
-
|
78
|
+
INPUT
|
79
79
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
<
|
92
|
-
<
|
93
|
-
<
|
94
|
-
<
|
95
|
-
</
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
<
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
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  Introduction</h1>
|
171
|
-
<div id="C"><h2>0.1  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  Scope</h1>
|
179
|
-
<p id="E">Text</p>
|
180
|
-
</div>
|
181
|
-
<div>
|
182
|
-
<h1>2  Normative References</h1>
|
183
|
-
</div>
|
184
|
-
<div id="H"><h1>3  Terms, definitions, symbols and abbreviated terms</h1>
|
185
|
-
<div id="I"><h2>3.1  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  Clause 4</h1>
|
204
|
-
<div id="N"><h2>5.1  Introduction</h2>
|
205
|
-
|
206
|
-
</div>
|
207
|
-
<div id="O"><h2>5.2  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  Annex A.1</h2>
|
215
|
-
|
216
|
-
<div id="Q1"><h3>A.1.1  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  Introduction</h1>
|
163
|
+
<div id="C"><h2>0.1  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  Scope</h1>
|
171
|
+
<p id="E">Text</p>
|
172
|
+
</div>
|
173
|
+
<div>
|
174
|
+
<h1>2  Normative References</h1>
|
175
|
+
</div>
|
176
|
+
<div id="H"><h1>3  Terms, definitions, symbols and abbreviated terms</h1>
|
177
|
+
<div id="I"><h2>3.1  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  Clause 4</h1>
|
196
|
+
<div id="N"><h2>5.1  Introduction</h2>
|
197
|
+
|
198
|
+
</div>
|
199
|
+
<div id="O"><h2>5.2  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  Annex A.1</h2>
|
207
|
+
|
208
|
+
<div id="Q1"><h3>A.1.1  Annex A.1a</h3>
|
209
|
+
|
210
|
+
</div>
|
211
|
+
</div>
|
212
|
+
<div id="Q2"><h2>Appendix 1  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
|
-
</
|
220
|
-
|
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
|
-
|
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
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
<
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
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
|
-
|
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  Introduction</h1>
|
610
|
-
<div id="C"><h2>0.1  Introduction Subsection</h2>
|
440
|
+
INPUT
|
611
441
|
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
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
|
-
|
627
|
-
|
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  Introduction</h1>
|
525
|
+
<div id="C"><h2>0.1  Introduction Subsection</h2>
|
628
526
|
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
<
|
634
|
-
|
635
|
-
<
|
636
|
-
|
637
|
-
|
638
|
-
<
|
639
|
-
</
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
527
|
+
</div>
|
528
|
+
<p>This is patent boilerplate</p>
|
529
|
+
</div>
|
530
|
+
#{IEC_TITLE1}
|
531
|
+
<div id="D">
|
532
|
+
<h1>1  Scope</h1>
|
533
|
+
<p id="E">Text</p>
|
534
|
+
</div>
|
535
|
+
<div>
|
536
|
+
<h1>2  Normative References</h1>
|
537
|
+
</div>
|
538
|
+
<div id="H"><h1>3  Terms, definitions, symbols and abbreviated terms</h1>
|
539
|
+
<div id="I"><h2>3.1  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  Clause 4</h1>
|
558
|
+
<div id="N"><h2>5.1  Introduction</h2>
|
644
559
|
|
645
|
-
|
646
|
-
|
560
|
+
</div>
|
561
|
+
<div id="O"><h2>5.2  Clause 4.2</h2>
|
647
562
|
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
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  Annex A.1</h2>
|
654
569
|
|
655
|
-
|
570
|
+
<div id="Q1"><h3>A.1.1  Annex A.1a</h3>
|
656
571
|
|
572
|
+
</div>
|
657
573
|
</div>
|
658
|
-
|
659
|
-
<div id="Q2"><h2>Appendice 1  An Appendix</h2>
|
574
|
+
<div id="Q2"><h2>Appendice 1  An Appendix</h2>
|
660
575
|
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
<div>
|
665
|
-
<h1 class="Section3">Bibliography</h1>
|
576
|
+
</div>
|
577
|
+
</div>
|
578
|
+
<br/>
|
666
579
|
<div>
|
667
|
-
<
|
580
|
+
<h1 class="Section3">Bibliography</h1>
|
581
|
+
<div>
|
582
|
+
<h2 class="Section3">Bibliography Subsection</h2>
|
583
|
+
</div>
|
668
584
|
</div>
|
669
585
|
</div>
|
670
|
-
</
|
671
|
-
</
|
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
|