metanorma-iso 1.3.20 → 1.3.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macos.yml +10 -10
  3. data/.github/workflows/ubuntu.yml +11 -11
  4. data/.github/workflows/windows.yml +11 -12
  5. data/Gemfile +2 -0
  6. data/README.adoc +3 -2
  7. data/lib/asciidoctor/iso/base.rb +17 -1
  8. data/lib/asciidoctor/iso/biblio.rng +131 -46
  9. data/lib/asciidoctor/iso/cleanup.rb +19 -2
  10. data/lib/asciidoctor/iso/front.rb +116 -17
  11. data/lib/asciidoctor/iso/isodoc.rng +32 -4
  12. data/lib/asciidoctor/iso/isostandard-amd.rng +98 -0
  13. data/lib/asciidoctor/iso/isostandard.rng +10 -0
  14. data/lib/asciidoctor/iso/macros.rb +21 -0
  15. data/lib/asciidoctor/iso/section.rb +18 -32
  16. data/lib/asciidoctor/iso/term_lookup_cleanup.rb +90 -0
  17. data/lib/asciidoctor/iso/validate.rb +41 -21
  18. data/lib/asciidoctor/iso/validate_section.rb +2 -2
  19. data/lib/asciidoctor/iso/validate_style.rb +1 -1
  20. data/lib/isodoc/iso/base_convert.rb +57 -41
  21. data/lib/isodoc/iso/html/header.html +5 -5
  22. data/lib/isodoc/iso/html/html_iso_titlepage.html +18 -18
  23. data/lib/isodoc/iso/html/isodoc.scss +28 -28
  24. data/lib/isodoc/iso/html/scripts.html +23 -21
  25. data/lib/isodoc/iso/html/style-human.scss +259 -423
  26. data/lib/isodoc/iso/html/style-iso.scss +151 -382
  27. data/lib/isodoc/iso/html/word_iso_titlepage.html +23 -2
  28. data/lib/isodoc/iso/html/wordstyle.scss +66 -39
  29. data/lib/isodoc/iso/html_convert.rb +7 -9
  30. data/lib/isodoc/iso/iso.international-standard.xsl +4386 -0
  31. data/lib/isodoc/iso/metadata.rb +48 -22
  32. data/lib/isodoc/iso/pdf_convert.rb +32 -0
  33. data/lib/metanorma-iso.rb +1 -0
  34. data/lib/metanorma/iso/processor.rb +13 -1
  35. data/lib/metanorma/iso/version.rb +1 -1
  36. data/spec/asciidoctor-iso/amd_spec.rb +318 -0
  37. data/spec/asciidoctor-iso/base_spec.rb +37 -17
  38. data/spec/asciidoctor-iso/blocks_spec.rb +21 -9
  39. data/spec/asciidoctor-iso/cleanup_spec.rb +203 -175
  40. data/spec/asciidoctor-iso/inline_spec.rb +2 -1
  41. data/spec/asciidoctor-iso/macros_spec.rb +273 -0
  42. data/spec/asciidoctor-iso/refs_spec.rb +7 -4
  43. data/spec/asciidoctor-iso/section_spec.rb +8 -8
  44. data/spec/asciidoctor-iso/validate_spec.rb +1 -1
  45. data/spec/assets/iso.xml +64 -1
  46. data/spec/isodoc/blocks_spec.rb +115 -0
  47. data/spec/isodoc/i18n_spec.rb +12 -20
  48. data/spec/isodoc/inline_spec.rb +2 -2
  49. data/spec/isodoc/iso_spec.rb +1 -1
  50. data/spec/isodoc/metadata_spec.rb +13 -4
  51. data/spec/isodoc/postproc_spec.rb +13 -112
  52. data/spec/isodoc/ref_spec.rb +4 -4
  53. data/spec/isodoc/section_spec.rb +8 -12
  54. data/spec/isodoc/table_spec.rb +24 -24
  55. data/spec/isodoc/terms_spec.rb +2 -2
  56. data/spec/isodoc/xref_spec.rb +19 -19
  57. data/spec/metanorma/processor_spec.rb +2 -2
  58. data/spec/spec_helper.rb +13 -1
  59. metadata +9 -3
  60. data/asciidoctor-iso.gemspec.old +0 -50
@@ -127,7 +127,7 @@ RSpec.describe Asciidoctor::ISO do
127
127
  #{BLANK_HDR}
128
128
  <sections>
129
129
 
130
- </sections><bibliography><references id="_" obligation="informative">
130
+ </sections><bibliography><references id="_" obligation="informative" normative="true">
131
131
  <title>Normative References</title>
132
132
  <p id="_">The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
133
133
  <bibitem id="ISO712">
@@ -137,6 +137,7 @@ RSpec.describe Asciidoctor::ISO do
137
137
  <bibitem id="ISO713">
138
138
  <formattedref format="application/x-isodoc+xml">Reference</formattedref>
139
139
  <docidentifier>ISO713</docidentifier>
140
+ <docnumber>713</docnumber>
140
141
  </bibitem>
141
142
  </references>
142
143
  </bibliography>
@@ -18,4 +18,277 @@ RSpec.describe Asciidoctor::ISO do
18
18
  OUTPUT
19
19
  end
20
20
 
21
+ describe 'term inline macros' do
22
+ subject(:convert) do
23
+ xmlpp(
24
+ strip_guid(
25
+ Asciidoctor.convert(
26
+ input, backend: :iso, header_footer: true)))
27
+ end
28
+ let(:input) do
29
+ <<~XML
30
+ #{ASCIIDOC_BLANK_HDR}
31
+ == Terms and Definitions
32
+
33
+ === name2
34
+
35
+ == Main
36
+
37
+ term:[name,name2]
38
+ XML
39
+ end
40
+ let(:output) do
41
+ <<~XML
42
+ #{BLANK_HDR}
43
+ <sections>
44
+ <terms id='_' obligation='normative'>
45
+ <title>Terms and definitions</title>
46
+ <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
47
+ <p id='_'>
48
+ ISO and IEC maintain terminological databases for use in standardization
49
+ at the following addresses:
50
+ </p>
51
+ <ul id='_'>
52
+ <li>
53
+ <p id='_'>
54
+ ISO Online browsing platform: available at
55
+ <link target='http://www.iso.org/obp'/>
56
+ </p>
57
+ </li>
58
+ <li>
59
+ <p id='_'>
60
+ IEC Electropedia: available at
61
+ <link target='http://www.electropedia.org'/>
62
+ </p>
63
+ </li>
64
+ </ul>
65
+ <term id='term-name2'>
66
+ <preferred>name2</preferred>
67
+ </term>
68
+ </terms>
69
+ <clause id='_' inline-header='false' obligation='normative'>
70
+ <title>Main</title>
71
+ <p id='_'>
72
+ <em>name</em>
73
+ (
74
+ <xref target='term-name2'/>
75
+ )
76
+ </p>
77
+ </clause>
78
+ </sections>
79
+ </iso-standard>
80
+ XML
81
+ end
82
+
83
+ it 'converts macro into the correct xml' do
84
+ expect(convert).to(be_equivalent_to(xmlpp(output)))
85
+ end
86
+
87
+ context 'default params' do
88
+ let(:input) do
89
+ <<~XML
90
+ #{ASCIIDOC_BLANK_HDR}
91
+
92
+ == Terms and Definitions
93
+
94
+ === name
95
+
96
+ == Main
97
+
98
+ term:[name]
99
+ XML
100
+ end
101
+ let(:output) do
102
+ <<~XML
103
+ #{BLANK_HDR}
104
+ <sections>
105
+ <terms id='_' obligation='normative'>
106
+ <title>Terms and definitions</title>
107
+ <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
108
+ <p id='_'>
109
+ ISO and IEC maintain terminological databases for use in standardization
110
+ at the following addresses:
111
+ </p>
112
+ <ul id='_'>
113
+ <li>
114
+ <p id='_'>
115
+ ISO Online browsing platform: available at
116
+ <link target='http://www.iso.org/obp' />
117
+ </p>
118
+ </li>
119
+ <li>
120
+ <p id='_'>
121
+ IEC Electropedia: available at
122
+ <link target='http://www.electropedia.org' />
123
+ </p>
124
+ </li>
125
+ </ul>
126
+ <term id='term-name'>
127
+ <preferred>name</preferred>
128
+ </term>
129
+ </terms>
130
+ <clause id='_' inline-header='false' obligation='normative'>
131
+ <title>Main</title>
132
+ <p id='_'>
133
+ <em>name</em>
134
+ (
135
+ <xref target='term-name' />
136
+ )
137
+ </p>
138
+ </clause>
139
+ </sections>
140
+ </iso-standard>
141
+ XML
142
+ end
143
+
144
+ it 'uses `name` as termref name' do
145
+ expect(convert).to(be_equivalent_to(xmlpp(output)))
146
+ end
147
+ end
148
+
149
+ context 'multiply exising ids in document' do
150
+ let(:input) do
151
+ <<~XML
152
+ #{ASCIIDOC_BLANK_HDR}
153
+
154
+ == Terms and Definitions
155
+
156
+ === name
157
+ === name2
158
+
159
+ [[term-name]]
160
+ == Main
161
+
162
+ paragraph
163
+
164
+ [[term-name2]]
165
+ == Second
166
+
167
+ term:[name]
168
+ term:[name2]
169
+ XML
170
+ end
171
+ let(:output) do
172
+ <<~XML
173
+ #{BLANK_HDR}
174
+ <sections>
175
+ <terms id='_' obligation='normative'>
176
+ <title>Terms and definitions</title>
177
+ <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
178
+ <p id='_'>
179
+ ISO and IEC maintain terminological databases for use in standardization
180
+ at the following addresses:
181
+ </p>
182
+ <ul id='_'>
183
+ <li>
184
+ <p id='_'>
185
+ ISO Online browsing platform: available at
186
+ <link target='http://www.iso.org/obp' />
187
+ </p>
188
+ </li>
189
+ <li>
190
+ <p id='_'>
191
+ IEC Electropedia: available at
192
+ <link target='http://www.electropedia.org' />
193
+ </p>
194
+ </li>
195
+ </ul>
196
+ <term id='term-name-1'>
197
+ <preferred>name</preferred>
198
+ </term>
199
+ <term id='term-name2-1'>
200
+ <preferred>name2</preferred>
201
+ </term>
202
+ </terms>
203
+ <clause id='term-name' inline-header='false' obligation='normative'>
204
+ <title>Main</title>
205
+ <p id='_'>paragraph</p>
206
+ </clause>
207
+ <clause id='term-name2' inline-header='false' obligation='normative'>
208
+ <title>Second</title>
209
+ <p id='_'>
210
+ <em>name</em>
211
+ (
212
+ <xref target='term-name-1' />
213
+ )
214
+ <em>name2</em>
215
+ (
216
+ <xref target='term-name2-1' />
217
+ )
218
+ </p>
219
+ </clause>
220
+ </sections>
221
+ </iso-standard>
222
+ XML
223
+ end
224
+
225
+ it 'generates unique ids which dont match existing ids' do
226
+ expect(convert).to(be_equivalent_to(xmlpp(output)))
227
+ end
228
+ end
229
+
230
+ context 'when missing actual ref' do
231
+ let(:input) do
232
+ <<~XML
233
+ #{ASCIIDOC_BLANK_HDR}
234
+
235
+ == Terms and Definitions
236
+
237
+ === name
238
+
239
+ paragraph
240
+
241
+ term:[name]
242
+ term:[missing]
243
+ XML
244
+ end
245
+ let(:output) do
246
+ <<~XML
247
+ #{BLANK_HDR}
248
+ <sections>
249
+ <terms id='_' obligation='normative'>
250
+ <title>Terms and definitions</title>
251
+ <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
252
+ <p id='_'>
253
+ ISO and IEC maintain terminological databases for use in standardization
254
+ at the following addresses:
255
+ </p>
256
+ <ul id='_'>
257
+ <li>
258
+ <p id='_'>
259
+ ISO Online browsing platform: available at
260
+ <link target='http://www.iso.org/obp'/>
261
+ </p>
262
+ </li>
263
+ <li>
264
+ <p id='_'>
265
+ IEC Electropedia: available at
266
+ <link target='http://www.electropedia.org'/>
267
+ </p>
268
+ </li>
269
+ </ul>
270
+ <term id='term-name'>
271
+ <preferred>name</preferred>
272
+ <definition>
273
+ <p id='_'>paragraph</p>
274
+ <p id='_'>
275
+ <em>name</em>
276
+ (
277
+ <xref target='term-name'/>
278
+ )
279
+ missing
280
+ </p>
281
+ </definition>
282
+ </term>
283
+ </terms>
284
+ </sections>
285
+ </iso-standard>
286
+ XML
287
+ end
288
+
289
+ it 'generates unique ids which dont match existing ids' do
290
+ expect(convert).to(be_equivalent_to(xmlpp(output)))
291
+ end
292
+ end
293
+ end
21
294
  end
@@ -15,12 +15,13 @@ RSpec.describe Asciidoctor::ISO do
15
15
  INPUT
16
16
  #{BLANK_HDR}
17
17
  <sections>
18
- </sections><bibliography><references id="_" obligation="informative">
18
+ </sections><bibliography><references id="_" obligation="informative" normative="true">
19
19
  <title>Normative References</title>
20
20
  <p id="_">The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
21
21
  <bibitem id="iso123" type="standard">
22
22
  <title format="text/plain">Standard</title>
23
23
  <docidentifier>ISO 123:—</docidentifier>
24
+ <docnumber>123</docnumber>
24
25
  <date type="published">
25
26
  <on>–</on>
26
27
  </date>
@@ -63,12 +64,13 @@ RSpec.describe Asciidoctor::ISO do
63
64
  </p>
64
65
  </clause>
65
66
  </sections>
66
- <bibliography><references id="_" obligation="informative">
67
+ <bibliography><references id="_" obligation="informative" normative="true">
67
68
  <title>Normative References</title>
68
69
  <p id="_">The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
69
70
  <bibitem id="iso123" type="standard">
70
71
  <title format="text/plain">Standard</title>
71
72
  <docidentifier>ISO 123:1066 (all parts)</docidentifier>
73
+ <docnumber>123</docnumber>
72
74
  <date type="published">
73
75
  <on>1066</on>
74
76
  </date>
@@ -98,7 +100,7 @@ RSpec.describe Asciidoctor::ISO do
98
100
  #{BLANK_HDR}
99
101
  <sections>
100
102
 
101
- </sections><bibliography><references id="_" obligation="informative">
103
+ </sections><bibliography><references id="_" obligation="informative" normative="true">
102
104
  <title>Normative References</title>
103
105
  <p id="_">The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
104
106
  <bibitem id="iso123">
@@ -106,6 +108,7 @@ RSpec.describe Asciidoctor::ISO do
106
108
  <em>Standard</em>
107
109
  </formattedref>
108
110
  <docidentifier>XYZ 123:1066 (all parts)</docidentifier>
111
+ <docnumber>123:1066 (all parts)</docnumber>
109
112
  </bibitem>
110
113
  </references>
111
114
  </bibliography>
@@ -124,7 +127,7 @@ RSpec.describe Asciidoctor::ISO do
124
127
  #{BLANK_HDR}
125
128
  <sections>
126
129
 
127
- </sections><bibliography><references id="_" obligation="informative">
130
+ </sections><bibliography><references id="_" obligation="informative" normative="false">
128
131
  <title>Bibliography</title>
129
132
  <bibitem id="iso123">
130
133
  <formattedref format="application/x-isodoc+xml">
@@ -84,7 +84,7 @@ standardization at the following addresses:

84
84
  <link target="http://www.electropedia.org"/>
85
85
  </p> </li> </ul>
86
86
 
87
- <term id="_">
87
+ <term id="term-term1">
88
88
  <preferred>Term1</preferred>
89
89
  </term>
90
90
  </terms>
@@ -109,7 +109,7 @@ standardization at the following addresses:

109
109
  </li>
110
110
  </ul>
111
111
  <title>Normal Terms</title>
112
- <term id="_">
112
+ <term id="term-term2">
113
113
  <preferred>Term2</preferred>
114
114
  </term>
115
115
  </terms>
@@ -133,12 +133,12 @@ standardization at the following addresses:

133
133
  </clause>
134
134
  <appendix id="_" inline-header="false" obligation="normative">
135
135
  <title>Appendix 1</title>
136
- </appendix></annex><bibliography><references id="_" obligation="informative">
136
+ </appendix></annex><bibliography><references id="_" obligation="informative" normative="true">
137
137
  <title>Normative References</title>
138
138
  <p id="_">There are no normative references in this document.</p>
139
139
  </references><clause id="_" obligation="informative">
140
140
  <title>Bibliography</title>
141
- <references id="_" obligation="informative">
141
+ <references id="_" obligation="informative" normative="false">
142
142
  <title>Bibliography Subsection</title>
143
143
  </references>
144
144
  </clause>
@@ -247,7 +247,7 @@ standardization at the following addresses:

247
247
  <p id="_">Foreword</p>
248
248
  </foreword></preface><sections>
249
249
  <terms id="_" obligation="normative">
250
- <title>Terms and definitions</title><p id="_">For the purposes of this document, the terms and definitions
250
+ <title>Terms and definitions</title><p id="_">For the purposes of this document, the terms and definitions
251
251
  given in <eref bibitemid="iso1234"/> and <eref bibitemid="iso5678"/> and the following apply.</p>
252
252
  <p id="_">ISO and IEC maintain terminological databases for use in
253
253
  standardization at the following addresses:</p>
@@ -259,7 +259,7 @@ standardization at the following addresses:

259
259
  <link target="http://www.electropedia.org"/>
260
260
  </p> </li> </ul>
261
261
 
262
- <term id="_">
262
+ <term id="term-term1">
263
263
  <preferred>Term1</preferred>
264
264
  </term>
265
265
  </terms></sections>
@@ -296,13 +296,13 @@ standardization at the following addresses:

296
296
  <ul id='_'>
297
297
  <li>
298
298
  <p id='_'>
299
- ISO Online browsing platform: available at
299
+ ISO Online browsing platform: available at
300
300
  <link target='http://www.iso.org/obp'/>
301
301
  </p>
302
302
  </li>
303
303
  <li>
304
304
  <p id='_'>
305
- IEC Electropedia: available at
305
+ IEC Electropedia: available at
306
306
  <link target='http://www.electropedia.org'/>
307
307
  </p>
308
308
  </li>
@@ -238,7 +238,7 @@ it "warns that term source is not a real reference" do
238
238
  [.source]
239
239
  <<iso123>>
240
240
  INPUT
241
- expect(File.read("test.err")).to include "iso123 is not a real reference"
241
+ expect(File.read("test.err")).to include "iso123 does not have a corresponding anchor ID in the bibliography"
242
242
  end
243
243
 
244
244
  it "warns that undated reference has locality" do
@@ -1,4 +1,67 @@
1
- <iso-standard xmlns="http://riboseinc.com/isoxml">
1
+ <iso-standard xmlns="https://www.metanorma.org/ns/iso">
2
+ <bibdata type="standard">
3
+ <title type="title-intro" language="en" format="text/plain">Cereals and pulses</title>
4
+ <title type="title-main" language="en" format="text/plain">Specifications and test methods</title>
5
+ <title type="main" language="en" format="text/plain">Specifications and test methods</title>
6
+ <title type="title-part" language="en" format="text/plain">Rice</title>
7
+ <title type="title-intro" language="fr" format="text/plain">Céréales et légumineuses</title>
8
+ <title type="title-main" language="fr" format="text/plain">Spécification et méthodes d'essai</title>
9
+ <title type="title-part" language="fr" format="text/plain">Riz</title>
10
+ <docidentifier type="iso">ISO/PreCD3 17301-1</docidentifier>
11
+ <docidentifier type="iso-tc">17301</docidentifier>
12
+ <docnumber>1730</docnumber>
13
+ <date type="published"><on>2011</on></date>
14
+ <date type="accessed"><on>2012</on></date>
15
+ <date type="created"><from>2010</from><to>2011</to></date>
16
+ <date type="activated"><on>2013</on></date>
17
+ <date type="obsoleted"><on>2014</on></date>
18
+ <edition>2</edition>
19
+ <version>
20
+ <revision-date>2016-05-01</revision-date>
21
+ <draft>0.4</draft>
22
+ </version>
23
+ <contributor>
24
+ <role type="author"/>
25
+ <organization>
26
+ <name>International Organization for Standardization</name>
27
+ <abbreviation>ISO</abbreviation>
28
+ </organization>
29
+ </contributor>
30
+ <contributor>
31
+ <role type="publisher"/>
32
+ <organization>
33
+ <name>International Organization for Standardization</name>
34
+ <abbreviation>ISO</abbreviation>
35
+ </organization>
36
+ </contributor>
37
+ <language>en</language>
38
+ <script>Latn</script>
39
+ <status>
40
+ <stage abbreviation="CD">35</stage>
41
+ <substage abbreviation="3CD">20</substage>
42
+ <iteration>3</iteration>
43
+ </status>
44
+ <copyright>
45
+ <from>2016</from>
46
+ <owner>
47
+ <organization>
48
+ <abbreviation>ISO</abbreviation>
49
+ </organization>
50
+ </owner>
51
+ </copyright>
52
+ <ext>
53
+ <doctype>international-standard</doctype>
54
+ <editorialgroup>
55
+ <technical-committee number="34">Food products</technical-committee>
56
+ <subcommittee number="4">Cereals and pulses</subcommittee>
57
+ <workgroup number="3">Rice Group</workgroup>
58
+ <secretariat>GB</secretariat>
59
+ </editorialgroup>
60
+ <structuredidentifier>
61
+ <project-number part="1">ISO/PreCD3 17301</project-number>
62
+ </structuredidentifier>
63
+ </ext>
64
+ </bibdata>
2
65
  <foreword>
3
66
  <note>
4
67
  <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>