metanorma-iec 2.0.8 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,12 +10,14 @@ module IsoDoc
10
10
  @meta = Metadata.new(lang, script, labels)
11
11
  end
12
12
 
13
- def xref_init(lang, script, klass, labels, options)
14
- @xrefs = Xref.new(lang, script, HtmlConvert.new(language: lang, script: script), labels, options)
13
+ def xref_init(lang, script, _klass, labels, options)
14
+ @xrefs = Xref.new(lang, script,
15
+ HtmlConvert.new(language: lang, script: script),
16
+ labels, options)
15
17
  end
16
18
 
17
- def i18n_init(lang, script, i18nyaml = nil)
18
- @i18n = I18n.new(lang, script, i18nyaml || @i18nyaml)
19
+ def i18n_init(lang, script, i18nyaml = nil)
20
+ @i18n = I18n.new(lang, script, i18nyaml: i18nyaml || @i18nyaml)
19
21
  end
20
22
 
21
23
  def convert1(docxml, filename, dir)
@@ -26,4 +28,3 @@ module IsoDoc
26
28
  end
27
29
  end
28
30
  end
29
-
@@ -7,8 +7,8 @@ module IsoDoc
7
7
  def i18n_init(lang, script, i18nyaml = nil)
8
8
  super
9
9
  @i18n_lg = {}
10
- @i18n_lg["en"] = I18n.new("en", "Latn", i18nyaml || @i18nyaml)
11
- @i18n_lg["fr"] = I18n.new("fr", "Latn", i18nyaml || @i18nyaml)
10
+ @i18n_lg["en"] = I18n.new("en", "Latn", i18nyaml: i18nyaml || @i18nyaml)
11
+ @i18n_lg["fr"] = I18n.new("fr", "Latn", i18nyaml: i18nyaml || @i18nyaml)
12
12
  @i18n_lg["default"] = @i18n
13
13
  end
14
14
 
@@ -89,7 +89,7 @@ module IsoDoc
89
89
  fr = docxml.at(ns("//term[@language = 'fr'][@tag = '#{en['tag']}']"))
90
90
  merge_fr_into_en_term1(en, fr) if fr
91
91
  end
92
- @xrefs.parse docxml
92
+ @xrefs.parse_inclusions(clauses: true).parse docxml
93
93
  docxml.xpath(ns("//term/name")).each(&:remove)
94
94
  term(docxml)
95
95
  end
@@ -17,10 +17,14 @@ module IsoDoc
17
17
  super
18
18
  return unless @is_iev
19
19
 
20
+ if @parse_settings.empty? || @parse_settings[:clauses]
20
21
  terms_iev_names(docxml)
22
+ end
23
+ if @parse_settings.empty?
21
24
  middle_section_asset_names(docxml)
22
25
  termnote_anchor_names(docxml)
23
26
  termexample_anchor_names(docxml)
27
+ end
24
28
  end
25
29
 
26
30
  def terms_iev_names(docxml)
@@ -851,17 +851,46 @@
851
851
  </define>
852
852
  <define name="bplace">
853
853
  <element name="place">
854
- <optional>
855
- <attribute name="uri">
856
- <data type="anyURI"/>
857
- </attribute>
858
- </optional>
859
- <optional>
860
- <attribute name="region"/>
861
- </optional>
854
+ <choice>
855
+ <text/>
856
+ <group>
857
+ <ref name="bibliocity"/>
858
+ <zeroOrMore>
859
+ <ref name="biblioregion"/>
860
+ </zeroOrMore>
861
+ <zeroOrMore>
862
+ <ref name="bibliocountry"/>
863
+ </zeroOrMore>
864
+ </group>
865
+ </choice>
866
+ </element>
867
+ </define>
868
+ <define name="bibliocity">
869
+ <element name="city">
862
870
  <text/>
863
871
  </element>
864
872
  </define>
873
+ <define name="biblioregion">
874
+ <element name="region">
875
+ <ref name="RegionType"/>
876
+ </element>
877
+ </define>
878
+ <define name="bibliocountry">
879
+ <element name="country">
880
+ <ref name="RegionType"/>
881
+ </element>
882
+ </define>
883
+ <define name="RegionType">
884
+ <optional>
885
+ <attribute name="iso"/>
886
+ </optional>
887
+ <optional>
888
+ <attribute name="recommended">
889
+ <data type="boolean"/>
890
+ </attribute>
891
+ </optional>
892
+ <text/>
893
+ </define>
865
894
  <define name="bprice">
866
895
  <element name="price">
867
896
  <attribute name="currency"/>
@@ -14,6 +14,7 @@
14
14
  <value>international-workshop-agreement</value>
15
15
  <value>guide</value>
16
16
  <value>industry-technical-agreement</value>
17
+ <value>system-reference-delivrabble</value>
17
18
  </choice>
18
19
  </define>
19
20
  <define name="BibDataExtensionType">
@@ -32,6 +32,43 @@
32
32
  <ref name="DocumentType"/>
33
33
  </element>
34
34
  </define>
35
+ <define name="admonition">
36
+ <element name="admonition">
37
+ <attribute name="type">
38
+ <ref name="AdmonitionType"/>
39
+ </attribute>
40
+ <optional>
41
+ <attribute name="class"/>
42
+ </optional>
43
+ <attribute name="id">
44
+ <data type="ID"/>
45
+ </attribute>
46
+ <optional>
47
+ <attribute name="uri">
48
+ <data type="anyURI"/>
49
+ </attribute>
50
+ </optional>
51
+ <optional>
52
+ <attribute name="coverpage">
53
+ <data type="boolean"/>
54
+ </attribute>
55
+ </optional>
56
+ <optional>
57
+ <attribute name="notag">
58
+ <data type="boolean"/>
59
+ </attribute>
60
+ </optional>
61
+ <optional>
62
+ <ref name="tname"/>
63
+ </optional>
64
+ <zeroOrMore>
65
+ <ref name="paragraph-with-footnote"/>
66
+ </zeroOrMore>
67
+ <zeroOrMore>
68
+ <ref name="note"/>
69
+ </zeroOrMore>
70
+ </element>
71
+ </define>
35
72
  <define name="index">
36
73
  <element name="index">
37
74
  <optional>
@@ -851,6 +888,16 @@
851
888
  <ref name="MultilingualRenderingType"/>
852
889
  </attribute>
853
890
  </optional>
891
+ <optional>
892
+ <attribute name="coverpage">
893
+ <data type="boolean"/>
894
+ </attribute>
895
+ </optional>
896
+ <optional>
897
+ <attribute name="notag">
898
+ <data type="boolean"/>
899
+ </attribute>
900
+ </optional>
854
901
  <oneOrMore>
855
902
  <choice>
856
903
  <ref name="paragraph"/>
@@ -1178,6 +1225,7 @@
1178
1225
  <ref name="concept"/>
1179
1226
  <ref name="add"/>
1180
1227
  <ref name="del"/>
1228
+ <ref name="span"/>
1181
1229
  </choice>
1182
1230
  </define>
1183
1231
  <define name="add">
@@ -1204,6 +1252,14 @@
1204
1252
  </choice>
1205
1253
  </element>
1206
1254
  </define>
1255
+ <define name="span">
1256
+ <element name="span">
1257
+ <attribute name="class"/>
1258
+ <oneOrMore>
1259
+ <ref name="TextElement"/>
1260
+ </oneOrMore>
1261
+ </element>
1262
+ </define>
1207
1263
  <define name="concept">
1208
1264
  <element name="concept">
1209
1265
  <optional>
@@ -1,6 +1,6 @@
1
1
  module Metanorma
2
2
  module Iec
3
- VERSION = "2.0.8".freeze
3
+ VERSION = "2.1.0".freeze
4
4
  end
5
5
  end
6
6
 
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.test_files = `git ls-files -- {spec}/*`.split("\n")
28
28
  spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
29
29
 
30
- spec.add_dependency "metanorma-iso", "~> 2.0.0"
30
+ spec.add_dependency "metanorma-iso", "~> 2.1.0"
31
31
  spec.add_dependency "ruby-jing"
32
32
 
33
33
  spec.add_development_dependency "debug"
@@ -1,219 +1,163 @@
1
1
  require "spec_helper"
2
2
 
3
3
  RSpec.describe IsoDoc::Iec do
4
-
5
- it "processes admonitions" do
6
- expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
7
- <iso-standard xmlns="http://riboseinc.com/isoxml">
8
- <preface><foreword>
9
- <admonition id="_70234f78-64e5-4dfc-8b6f-f3f037348b6a" type="caution">
10
- <p id="_e94663cc-2473-4ccc-9a72-983a74d989f2">Only use paddy or parboiled rice for the determination of husked rice yield.</p>
11
- <p id="_e94663cc-2473-4ccc-9a72-983a74d989f3">Para 2.</p>
12
- </admonition>
13
- </foreword></preface>
14
- </iso-standard>
15
- INPUT
16
- #{HTML_HDR}
17
- <div>
18
- <h1 class='ForewordTitle'>FOREWORD</h1>
19
- <div class='boilerplate_legal'/>
20
- <div id='_70234f78-64e5-4dfc-8b6f-f3f037348b6a' class='Admonition'>
21
- <p>
22
- CAUTION &#8212; Only use paddy or parboiled rice for the
23
- determination of husked rice yield.
24
- </p>
25
- <p id='_e94663cc-2473-4ccc-9a72-983a74d989f3'>Para 2.</p>
26
- </div>
27
- </div>
28
- #{IEC_TITLE1}
29
- </div>
30
- </body>
31
- </html>
32
- OUTPUT
33
- end
34
-
35
- it "processes admonitions with titles" do
36
- expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
37
- <iso-standard xmlns="http://riboseinc.com/isoxml">
38
- <preface><foreword>
39
- <admonition id="_70234f78-64e5-4dfc-8b6f-f3f037348b6a" type="caution">
40
- <name>Title</name>
41
- <ul>
42
- <li>List</li>
43
- </ul>
44
- <p id="_e94663cc-2473-4ccc-9a72-983a74d989f2">Only use paddy or parboiled rice for the determination of husked rice yield.</p>
45
- </admonition>
46
- </foreword></preface>
47
- </iso-standard>
48
- INPUT
49
- #{HTML_HDR}
50
- <div>
51
- <h1 class='ForewordTitle'>FOREWORD</h1>
52
- <div class='boilerplate_legal'/>
53
- <div id='_70234f78-64e5-4dfc-8b6f-f3f037348b6a' class='Admonition'>
54
- <p>Title &#8212; </p>
55
- <ul>
56
- <li>List</li>
57
- </ul>
58
- <p id='_e94663cc-2473-4ccc-9a72-983a74d989f2'>Only use paddy or parboiled rice for the determination of husked rice yield.</p>
59
- </div>
60
- </div>
61
- #{IEC_TITLE1}
62
- </div>
63
- </body>
64
- </html>
65
- OUTPUT
66
- end
67
-
68
4
  it "processes formulae (Word)" do
69
- expect(xmlpp(IsoDoc::Iec::WordConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
70
- <iso-standard xmlns="http://riboseinc.com/isoxml">
71
- <preface><foreword>
72
- <formula id="_be9158af-7e93-4ee2-90c5-26d31c181934" unnumbered="true">
73
- <stem type="AsciiMath">r = 1 %</stem>
74
- <dl id="_e4fe94fe-1cde-49d9-b1ad-743293b7e21d">
75
- <dt>
76
- <stem type="AsciiMath">r</stem>
77
- </dt>
78
- <dd>
79
- <p id="_1b99995d-ff03-40f5-8f2e-ab9665a69b77">is the repeatability limit.</p>
80
- </dd>
81
- </dl>
82
- <note id="_83083c7a-6c85-43db-a9fa-4d8edd0c9fc0">
83
- <name>NOTE</name>
84
- <p id="_511aaa98-4116-42af-8e5b-c87cdf5bfdc8">[durationUnits] is essentially a duration statement without the "P" prefix. "P" is unnecessary because between "G" and "U" duration is always expressed.</p>
85
- </note>
86
- </formula>
87
- <formula id="_be9158af-7e93-4ee2-90c5-26d31c181935"><name>1</name>
88
- <stem type="AsciiMath">r = 1 %</stem>
89
- </formula>
90
- </foreword></preface>
91
- </iso-standard>
5
+ input = <<~INPUT
6
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
7
+ <preface><foreword>
8
+ <formula id="_be9158af-7e93-4ee2-90c5-26d31c181934" unnumbered="true">
9
+ <stem type="AsciiMath">r = 1 %</stem>
10
+ <dl id="_e4fe94fe-1cde-49d9-b1ad-743293b7e21d">
11
+ <dt>
12
+ <stem type="AsciiMath">r</stem>
13
+ </dt>
14
+ <dd>
15
+ <p id="_1b99995d-ff03-40f5-8f2e-ab9665a69b77">is the repeatability limit.</p>
16
+ </dd>
17
+ </dl>
18
+ <note id="_83083c7a-6c85-43db-a9fa-4d8edd0c9fc0">
19
+ <name>NOTE</name>
20
+ <p id="_511aaa98-4116-42af-8e5b-c87cdf5bfdc8">[durationUnits] is essentially a duration statement without the "P" prefix. "P" is unnecessary because between "G" and "U" duration is always expressed.</p>
21
+ </note>
22
+ </formula>
23
+ <formula id="_be9158af-7e93-4ee2-90c5-26d31c181935"><name>1</name>
24
+ <stem type="AsciiMath">r = 1 %</stem>
25
+ </formula>
26
+ </foreword></preface>
27
+ </iso-standard>
92
28
  INPUT
93
- <html xmlns:epub='http://www.idpf.org/2007/ops' lang='en'>
94
- <head>
95
- <style>
96
- </style>
97
- <style>
98
- </style>
99
- </head>
100
- <body lang='EN-US' link='blue' vlink='#954F72'>
101
- <div class='WordSection2'>
102
- <p>
103
- <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
104
- </p>
105
- #{IEC_TITLE}
106
- <div>
107
- <h1 class='ForewordTitle'>FOREWORD</h1>
108
- <div class='boilerplate_legal'/>
109
- <div id='_be9158af-7e93-4ee2-90c5-26d31c181934'><div class='formula'>
110
- <p class='formula'>
111
- <span style='mso-tab-count:1'>&#160; </span>
112
- <span class='stem'>(#(r = 1 %)#)</span>
113
- </p>
114
- </div>
115
- <span class='zzMoveToFollowing'>
116
- where
117
- <span class='stem'>(#(r)#)</span>
118
- </span>
119
- <p id='_1b99995d-ff03-40f5-8f2e-ab9665a69b77'>is the repeatability limit.</p>
120
- <div id='_83083c7a-6c85-43db-a9fa-4d8edd0c9fc0' class='Note'>
121
- <p class='Note'>
122
- <span class='note_label'>NOTE</span>
123
- <span style='mso-tab-count:1'>&#160; </span>
124
- [durationUnits] is essentially a duration statement without the "P"
125
- prefix. "P" is unnecessary because between "G" and "U" duration is
126
- always expressed.
127
- </p>
128
- </div>
129
- </div>
130
- <div id='_be9158af-7e93-4ee2-90c5-26d31c181935'><div class='formula'>
131
- <p class='formula'>
132
- <span style='mso-tab-count:1'>&#160; </span>
133
- <span class='stem'>(#(r = 1 %)#)</span>
134
- <span style='mso-tab-count:1'>&#160; </span>
135
- (1)
29
+ output = <<~OUTPUT
30
+ <html xmlns:epub='http://www.idpf.org/2007/ops' lang='en'>
31
+ <head>
32
+ <style>
33
+ </style>
34
+ <style>
35
+ </style>
36
+ </head>
37
+ <body lang='EN-US' link='blue' vlink='#954F72'>
38
+ <div class='WordSection2'>
39
+ <p>
40
+ <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
41
+ </p>
42
+ #{IEC_TITLE}
43
+ <div>
44
+ <h1 class='ForewordTitle'>FOREWORD</h1>
45
+ <div class='boilerplate_legal'/>
46
+ <div id='_be9158af-7e93-4ee2-90c5-26d31c181934'><div class='formula'>
47
+ <p class='formula'>
48
+ <span style='mso-tab-count:1'>&#160; </span>
49
+ <span class='stem'>(#(r = 1 %)#)</span>
50
+ </p>
51
+ </div>
52
+ <span class='zzMoveToFollowing'>
53
+ where#{' '}
54
+ <span class='stem'>(#(r)#)</span>
55
+ </span>
56
+ <p id='_1b99995d-ff03-40f5-8f2e-ab9665a69b77'>is the repeatability limit.</p>
57
+ <div id='_83083c7a-6c85-43db-a9fa-4d8edd0c9fc0' class='Note'>
58
+ <p class='Note'>
59
+ <span class='note_label'>NOTE</span>
60
+ <span style='mso-tab-count:1'>&#160; </span>
61
+ [durationUnits] is essentially a duration statement without the "P"
62
+ prefix. "P" is unnecessary because between "G" and "U" duration is
63
+ always expressed.
64
+ </p>
65
+ </div>
66
+ </div>
67
+ <div id='_be9158af-7e93-4ee2-90c5-26d31c181935'><div class='formula'>
68
+ <p class='formula'>
69
+ <span style='mso-tab-count:1'>&#160; </span>
70
+ <span class='stem'>(#(r = 1 %)#)</span>
71
+ <span style='mso-tab-count:1'>&#160; </span>
72
+ (1)
73
+ </p>
74
+ </div>
75
+ </div>
76
+ </div>
77
+ <p>&#160;</p>
78
+ </div>
79
+ <p>
80
+ <br clear='all' class='section'/>
136
81
  </p>
137
- </div>
138
- </div>
139
- </div>
140
- <p>&#160;</p>
141
- </div>
142
- <p>
143
- <br clear='all' class='section'/>
144
- </p>
145
- <div class='WordSection3'>
146
- #{IEC_TITLE1}
147
- </div>
148
- <br clear='all' style='page-break-before:left;mso-break-type:section-break'/>
149
- <div class='colophon'/>
150
- </body>
151
- </html>
82
+ <div class='WordSection3'>
83
+ #{IEC_TITLE1}
84
+ </div>
85
+ <br clear='all' style='page-break-before:left;mso-break-type:section-break'/>
86
+ <div class='colophon'/>
87
+ </body>
88
+ </html>
152
89
  OUTPUT
90
+ expect(xmlpp(IsoDoc::Iec::WordConvert.new({})
91
+ .convert("test", input, true)))
92
+ .to be_equivalent_to xmlpp(output)
153
93
  end
154
94
 
155
- it "cross-references formulae" do
156
- expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true).gsub(%r{^.*<body}m, "<body").gsub(%r{</body>.*}m, "</body>"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
157
- <iso-standard xmlns="http://riboseinc.com/isoxml">
158
- <preface>
159
- <foreword>
160
- <p>
161
- <xref target="N1"/>
162
- <xref target="N2"/>
163
- </p>
164
- </foreword>
165
- </preface>
166
- <sections>
167
- <clause id="intro"><title>First</title>
168
- <formula id="N1">
169
- <stem type="AsciiMath">r = 1 %</stem>
170
- </formula>
171
- <clause id="xyz"><title>Preparatory</title>
172
- <formula id="N2" inequality="true">
173
- <stem type="AsciiMath">r = 1 %</stem>
174
- </formula>
175
- <xref target="N2"/>
176
- </clause>
177
- </sections>
178
- </iso-standard>
95
+ it "cross-references formulae" do
96
+ input = <<~INPUT
97
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
98
+ <preface>
99
+ <foreword>
100
+ <p>
101
+ <xref target="N1"/>
102
+ <xref target="N2"/>
103
+ </p>
104
+ </foreword>
105
+ </preface>
106
+ <sections>
107
+ <clause id="intro"><title>First</title>
108
+ <formula id="N1">
109
+ <stem type="AsciiMath">r = 1 %</stem>
110
+ </formula>
111
+ <clause id="xyz"><title>Preparatory</title>
112
+ <formula id="N2" inequality="true">
113
+ <stem type="AsciiMath">r = 1 %</stem>
114
+ </formula>
115
+ <xref target="N2"/>
116
+ </clause>
117
+ </sections>
118
+ </iso-standard>
179
119
  INPUT
180
- <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
181
- <preface>
182
- <foreword displayorder="1">
183
- <p>
184
- <xref target='N1'>Clause 1, Equation (1)</xref>
185
- <xref target='N2'>1.1, Inequality (2)</xref>
186
- </p>
187
- </foreword>
188
- </preface>
189
- <sections>
190
- <clause id='intro' displayorder="2">
191
- <title depth='1'>
192
- 1
193
- <tab/>
194
- First
195
- </title>
196
- <formula id='N1'>
197
- <name>1</name>
198
- <stem type='AsciiMath'>r = 1 %</stem>
199
- </formula>
200
- <clause id='xyz'>
201
- <title depth='2'>
202
- 1.1
120
+ output = <<~OUTPUT
121
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
122
+ <preface>
123
+ <foreword displayorder="1">
124
+ <p>
125
+ <xref target='N1'>Clause 1, Equation (1)</xref>
126
+ <xref target='N2'>1.1, Inequality (2)</xref>
127
+ </p>
128
+ </foreword>
129
+ </preface>
130
+ <sections>
131
+ <clause id='intro' displayorder="2">
132
+ <title depth='1'>
133
+ 1
203
134
  <tab/>
204
- Preparatory
135
+ First
205
136
  </title>
206
- <formula id='N2' inequality='true'>
207
- <name>2</name>
137
+ <formula id='N1'>
138
+ <name>1</name>
208
139
  <stem type='AsciiMath'>r = 1 %</stem>
209
140
  </formula>
210
- <xref target='N2'>Inequality (2)</xref>
141
+ <clause id='xyz'>
142
+ <title depth='2'>
143
+ 1.1
144
+ <tab/>
145
+ Preparatory
146
+ </title>
147
+ <formula id='N2' inequality='true'>
148
+ <name>2</name>
149
+ <stem type='AsciiMath'>r = 1 %</stem>
150
+ </formula>
151
+ <xref target='N2'>Inequality (2)</xref>
152
+ </clause>
211
153
  </clause>
212
- </clause>
213
- </sections>
214
- </iso-standard>
154
+ </sections>
155
+ </iso-standard>
215
156
  OUTPUT
216
- end
217
-
218
-
157
+ expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({})
158
+ .convert("test", input, true)
159
+ .gsub(%r{^.*<body}m, "<body")
160
+ .gsub(%r{</body>.*}m, "</body>")))
161
+ .to be_equivalent_to xmlpp(output)
162
+ end
219
163
  end