metanorma-standoc 1.5.1 → 1.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +62 -0
  3. data/lib/asciidoctor/standoc/base.rb +7 -2
  4. data/lib/asciidoctor/standoc/basicdoc.rng +23 -0
  5. data/lib/asciidoctor/standoc/cleanup.rb +32 -12
  6. data/lib/asciidoctor/standoc/cleanup_amend.rb +54 -0
  7. data/lib/asciidoctor/standoc/cleanup_block.rb +0 -2
  8. data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +14 -0
  9. data/lib/asciidoctor/standoc/cleanup_footnotes.rb +11 -3
  10. data/lib/asciidoctor/standoc/cleanup_inline.rb +62 -1
  11. data/lib/asciidoctor/standoc/cleanup_ref.rb +6 -5
  12. data/lib/asciidoctor/standoc/cleanup_section.rb +19 -3
  13. data/lib/asciidoctor/standoc/cleanup_terms.rb +2 -2
  14. data/lib/asciidoctor/standoc/converter.rb +4 -2
  15. data/lib/asciidoctor/standoc/front.rb +9 -3
  16. data/lib/asciidoctor/standoc/front_contributor.rb +58 -18
  17. data/lib/asciidoctor/standoc/inline.rb +21 -31
  18. data/lib/asciidoctor/standoc/isodoc.rng +125 -58
  19. data/lib/asciidoctor/standoc/log.rb +10 -1
  20. data/lib/asciidoctor/standoc/macros.rb +44 -33
  21. data/lib/asciidoctor/standoc/ref.rb +39 -44
  22. data/lib/asciidoctor/standoc/ref_sect.rb +12 -5
  23. data/lib/asciidoctor/standoc/section.rb +11 -10
  24. data/lib/asciidoctor/standoc/table.rb +3 -2
  25. data/lib/asciidoctor/standoc/utils.rb +2 -1
  26. data/lib/asciidoctor/standoc/validate.rb +30 -18
  27. data/lib/asciidoctor/standoc/validate_section.rb +1 -1
  28. data/lib/asciidoctor/standoc/views/datamodel/model_representation.adoc.erb +10 -10
  29. data/lib/liquid/custom_blocks/key_iterator.rb +21 -0
  30. data/lib/liquid/custom_blocks/with_json_nested_context.rb +18 -0
  31. data/lib/liquid/custom_blocks/with_yaml_nested_context.rb +19 -0
  32. data/lib/liquid/custom_filters/values.rb +7 -0
  33. data/lib/metanorma/standoc.rb +0 -5
  34. data/lib/metanorma/standoc/version.rb +20 -1
  35. data/metanorma-standoc.gemspec +4 -4
  36. data/spec/asciidoctor-standoc/base_spec.rb +248 -10
  37. data/spec/asciidoctor-standoc/blocks_spec.rb +263 -144
  38. data/spec/asciidoctor-standoc/cleanup_spec.rb +199 -50
  39. data/spec/asciidoctor-standoc/inline_spec.rb +132 -5
  40. data/spec/asciidoctor-standoc/isobib_cache_spec.rb +13 -27
  41. data/spec/asciidoctor-standoc/macros_json2text_spec.rb +10 -0
  42. data/spec/asciidoctor-standoc/macros_spec.rb +43 -23
  43. data/spec/asciidoctor-standoc/macros_yaml2text_spec.rb +6 -561
  44. data/spec/asciidoctor-standoc/refs_dl_spec.rb +5 -3
  45. data/spec/asciidoctor-standoc/refs_spec.rb +268 -57
  46. data/spec/asciidoctor-standoc/section_spec.rb +0 -1
  47. data/spec/asciidoctor-standoc/table_spec.rb +119 -113
  48. data/spec/asciidoctor-standoc/validate_spec.rb +27 -1
  49. data/spec/examples/codes_table.html +1365 -1365
  50. data/spec/fixtures/macros_datamodel/address_class_profile.xml +46 -46
  51. data/spec/fixtures/macros_datamodel/address_component_profile.xml +21 -21
  52. data/spec/fixtures/macros_datamodel/blank_definition_profile.xml +21 -21
  53. data/spec/spec_helper.rb +115 -109
  54. data/spec/support/shared_examples/structured_data_2_text_preprocessor.rb +781 -0
  55. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +54 -238
  56. data/spec/vcr_cassettes/isobib_get_123.yml +14 -60
  57. data/spec/vcr_cassettes/isobib_get_123_1.yml +24 -116
  58. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +361 -0
  59. data/spec/vcr_cassettes/isobib_get_123_2001.yml +14 -60
  60. data/spec/vcr_cassettes/isobib_get_124.yml +11 -57
  61. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +8 -8
  62. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +39 -37
  63. metadata +42 -11
  64. data/.github/workflows/macos.yml +0 -46
  65. data/.github/workflows/ubuntu.yml +0 -49
  66. data/.github/workflows/windows.yml +0 -53
  67. data/lib/asciidoctor/standoc/macros_yaml2text.rb +0 -165
  68. data/lib/metanorma/standoc/latexml_requirement.rb +0 -62
  69. data/lib/metanorma/standoc/requirement.rb +0 -13
@@ -86,172 +86,149 @@ RSpec.describe Asciidoctor::Standoc do
86
86
 
87
87
  INPUT
88
88
  #{BLANK_HDR}
89
- <sections>
90
- <formula id="ABC" inequality="true" number="3" keep-with-next="true" keep-lines-together="true">
91
- <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>r</mi><mo>=</mo><mn>1</mn><mi>%</mi><mi>r</mi><mo>=</mo><mn>1</mn><mi>%</mi></math></stem>
92
- </formula>
93
-
94
- <formula id="_" unnumbered="true">
95
- <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub> <mrow> <mrow> <mi mathvariant="bold-italic">F</mi> </mrow> </mrow> <mrow> <mrow> <mi mathvariant="bold-italic">Α</mi> </mrow> </mrow> </msub> </math></stem>
96
- </formula>
97
- <formula id="_" subsequence="A">
98
- <stem type="MathML">
99
- <math xmlns="http://www.w3.org/1998/Math/MathML">
100
- <mrow>
101
- <mi>M</mi>
102
- <mo>=</mo>
103
- <mrow>
104
- <mo>[</mo>
105
- <mtable columnspacing="5pt" displaystyle="true" rowspacing="0pt">
106
- <mtr>
107
- <mtd columnalign="center">
89
+ <sections>
90
+ <formula id='ABC' number='3' keep-with-next='true' keep-lines-together='true' inequality='true'>
91
+ <stem type='MathML'>
92
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
93
+ <mi>r</mi>
94
+ <mo>=</mo>
95
+ <mn>1</mn>
96
+ <mi>%</mi>
97
+ <mi>r</mi>
98
+ <mo>=</mo>
99
+ <mn>1</mn>
100
+ <mi>%</mi>
101
+ </math>
102
+ </stem>
103
+ </formula>
104
+ <formula id='_' unnumbered='true'>
105
+ <stem type='MathML'>
106
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
107
+ <msub>
108
108
  <mrow>
109
- <mo>-</mo>
110
109
  <mrow>
111
- <mi>sin</mi>
112
- <mo>⁡</mo>
113
- <msub>
114
- <mi>λ</mi>
115
- <mn>0</mn>
116
- </msub>
110
+ <mi mathvariant='bold-italic'>F</mi>
117
111
  </mrow>
118
112
  </mrow>
119
- </mtd>
120
- <mtd columnalign="center">
121
113
  <mrow>
122
- <mi>cos</mi>
123
- <mo>⁡</mo>
124
- <msub>
125
- <mi>λ</mi>
126
- <mn>0</mn>
127
- </msub>
128
- </mrow>
129
- </mtd>
130
- <mtd columnalign="center">
131
- <mn>0</mn>
132
- </mtd>
133
- </mtr>
134
- <mtr>
135
- <mtd columnalign="center">
136
- <mrow>
137
- <mo>-</mo>
138
114
  <mrow>
139
- <mrow>
140
- <mi>sin</mi>
141
- <mo>⁡</mo>
115
+ <mi mathvariant='bold-italic'>Α</mi>
116
+ </mrow>
117
+ </mrow>
118
+ </msub>
119
+ </math>
120
+ </stem>
121
+ </formula>
122
+ <formula id='_' subsequence='A'>
123
+ <stem type='MathML'>
124
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
125
+ <mrow>
126
+ <mi>M</mi>
127
+ <mo>=</mo>
128
+ <mo>[</mo>
129
+ <mtable>
130
+ <mtr>
131
+ <mtd>
132
+ <mrow>
133
+ <mo>−</mo>
134
+ <mi>sin</mi>
135
+ </mrow>
136
+ <msub>
137
+ <mi>λ</mi>
138
+ <mn>0</mn>
139
+ </msub>
140
+ </mtd>
141
+ <mtd>
142
+ <mi>cos</mi>
143
+ <msub>
144
+ <mi>λ</mi>
145
+ <mn>0</mn>
146
+ </msub>
147
+ </mtd>
148
+ <mtd>
149
+ <mn>0</mn>
150
+ </mtd>
151
+ </mtr>
152
+ <mtr>
153
+ <mtd>
154
+ <mrow>
155
+ <mo>−</mo>
156
+ <mi>sin</mi>
157
+ </mrow>
142
158
  <msub>
143
159
  <mi>φ</mi>
144
160
  <mn>0</mn>
145
161
  </msub>
146
- </mrow>
147
- <mo>⁢</mo>
148
- <mrow>
149
162
  <mi>cos</mi>
150
- <mo>⁡</mo>
151
163
  <msub>
152
164
  <mi>λ</mi>
153
165
  <mn>0</mn>
154
166
  </msub>
155
- </mrow>
156
- </mrow>
157
- </mrow>
158
- </mtd>
159
- <mtd columnalign="center">
160
- <mrow>
161
- <mo>-</mo>
162
- <mrow>
163
- <mrow>
167
+ </mtd>
168
+ <mtd>
169
+ <mrow>
170
+ <mo>−</mo>
171
+ <mi>sin</mi>
172
+ </mrow>
173
+ <msub>
174
+ <mi>φ</mi>
175
+ <mn>0</mn>
176
+ </msub>
164
177
  <mi>sin</mi>
165
- <mo>⁡</mo>
178
+ <msub>
179
+ <mi>λ</mi>
180
+ <mn>0</mn>
181
+ </msub>
182
+ </mtd>
183
+ <mtd>
184
+ <mi>cos</mi>
185
+ <msub>
186
+ <mi>φ</mi>
187
+ <mn>0</mn>
188
+ </msub>
189
+ </mtd>
190
+ </mtr>
191
+ <mtr>
192
+ <mtd>
193
+ <mi>cos</mi>
194
+ <msub>
195
+ <mi>φ</mi>
196
+ <mn>0</mn>
197
+ </msub>
198
+ <mi>cos</mi>
199
+ <msub>
200
+ <mi>λ</mi>
201
+ <mn>0</mn>
202
+ </msub>
203
+ </mtd>
204
+ <mtd>
205
+ <mi>cos</mi>
166
206
  <msub>
167
207
  <mi>φ</mi>
168
208
  <mn>0</mn>
169
209
  </msub>
170
- </mrow>
171
- <mo>⁢</mo>
172
- <mrow>
173
210
  <mi>sin</mi>
174
- <mo>⁡</mo>
175
211
  <msub>
176
212
  <mi>λ</mi>
177
213
  <mn>0</mn>
178
214
  </msub>
179
- </mrow>
180
- </mrow>
181
- </mrow>
182
- </mtd>
183
- <mtd columnalign="center">
184
- <mrow>
185
- <mi>cos</mi>
186
- <mo>⁡</mo>
187
- <msub>
188
- <mi>φ</mi>
189
- <mn>0</mn>
190
- </msub>
191
- </mrow>
192
- </mtd>
193
- </mtr>
194
- <mtr>
195
- <mtd columnalign="center">
196
- <mrow>
197
- <mrow>
198
- <mi>cos</mi>
199
- <mo>⁡</mo>
200
- <msub>
201
- <mi>φ</mi>
202
- <mn>0</mn>
203
- </msub>
204
- </mrow>
205
- <mo>⁢</mo>
206
- <mrow>
207
- <mi>cos</mi>
208
- <mo>⁡</mo>
209
- <msub>
210
- <mi>λ</mi>
211
- <mn>0</mn>
212
- </msub>
213
- </mrow>
214
- </mrow>
215
- </mtd>
216
- <mtd columnalign="center">
217
- <mrow>
218
- <mrow>
219
- <mi>cos</mi>
220
- <mo>⁡</mo>
221
- <msub>
222
- <mi>φ</mi>
223
- <mn>0</mn>
224
- </msub>
225
- </mrow>
226
- <mo>⁢</mo>
227
- <mrow>
228
- <mi>sin</mi>
229
- <mo>⁡</mo>
230
- <msub>
231
- <mi>λ</mi>
232
- <mn>0</mn>
233
- </msub>
234
- </mrow>
235
- </mrow>
236
- </mtd>
237
- <mtd columnalign="center">
238
- <mrow>
239
- <mi>sin</mi>
240
- <mo>⁡</mo>
241
- <msub>
242
- <mi>φ</mi>
243
- <mn>0</mn>
244
- </msub>
245
- </mrow>
246
- </mtd>
247
- </mtr>
248
- </mtable>
249
- <mo>]</mo>
250
- </mrow>
251
- </mrow>
252
- </math></stem>
253
- </formula>
254
- </sections></standard-document>
215
+ </mtd>
216
+ <mtd>
217
+ <mi>sin</mi>
218
+ <msub>
219
+ <mi>φ</mi>
220
+ <mn>0</mn>
221
+ </msub>
222
+ </mtd>
223
+ </mtr>
224
+ </mtable>
225
+ <mo>]</mo>
226
+ </mrow>
227
+ </math>
228
+ </stem>
229
+ </formula>
230
+ </sections>
231
+ </standard-document>
255
232
  OUTPUT
256
233
  end
257
234
 
@@ -296,7 +273,7 @@ RSpec.describe Asciidoctor::Standoc do
296
273
  For further information on the Foreword, see *ISO/IEC Directives, Part 2, 2016, Clause 12.*
297
274
  ****
298
275
  INPUT
299
- <standard-document xmlns="https://www.metanorma.org/ns/standoc">
276
+ <standard-document xmlns="https://www.metanorma.org/ns/standoc" type="semantic" version="#{Metanorma::Standoc::VERSION}">
300
277
  <bibdata type="standard">
301
278
  <title language="en" format="text/plain">Document title</title>
302
279
 
@@ -1253,9 +1230,16 @@ RSpec.describe Asciidoctor::Standoc do
1253
1230
  <recommendation id="ABC" obligation="permission,recommendation" filename="reqt1.rq"><label>/ogc/recommendation/wfs/2</label><subject>user</subject>
1254
1231
  <classification><tag>control-class</tag><value>Technical</value></classification><classification><tag>priority</tag><value>P0</value></classification><classification><tag>family</tag><value>System &amp; Communications Protection</value></classification><classification><tag>family</tag><value>System and Communications Protocols</value></classification>
1255
1232
  <description><p id="_">I recommend <em>this</em>.</p>
1256
- </description><specification exclude="false" type="tabular" keep-with-next="true" keep-lines-together="true"><p id="_">This is the object of the recommendation:</p><table id="_"> <tbody> <tr> <td align="left">Object</td> <td align="left">Value</td> </tr> <tr> <td align="left">Mission</td> <td align="left">Accomplished</td> </tr> </tbody></table></specification><description>
1233
+ </description><specification exclude="false" type="tabular" keep-with-next="true" keep-lines-together="true"><p id="_">This is the object of the recommendation:</p><table id="_"> <tbody> <tr> <td valign="top" align="left">Object</td> <td valign="top" align="left">Value</td> </tr> <tr> <td valign="top" align="left">Mission</td> <td valign="top" align="left">Accomplished</td> </tr> </tbody></table></specification><description>
1257
1234
  <p id="_">As for the measurement targets,</p>
1258
- </description><measurement-target exclude="false"><p id="_">The measurement target shall be measured as:</p><formula id="_"> <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mfrac><mi>r</mi><mn>1</mn></mfrac><mo>=</mo><mn>0</mn></math></stem></formula></measurement-target>
1235
+ </description><measurement-target exclude="false"><p id="_">The measurement target shall be measured as:</p><formula id="_"> <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mfrac>
1236
+ <mrow>
1237
+ <mi>r</mi>
1238
+ </mrow>
1239
+ <mrow>
1240
+ <mn>1</mn>
1241
+ </mrow>
1242
+ </mfrac><mo>=</mo><mn>0</mn></math></stem></formula></measurement-target>
1259
1243
  <verification exclude="false"><p id="_">The following code will be run for verification:</p><sourcecode lang="CoreRoot" id="_">CoreRoot(success): HttpResponse
1260
1244
  if (success)
1261
1245
  recommendation(label: success-response)
@@ -1268,4 +1252,139 @@ end</sourcecode></verification>
1268
1252
  expect(xmlpp(strip_guid(Asciidoctor.convert(input, backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(output)
1269
1253
  end
1270
1254
 
1255
+ it "processes delete change clauses" do
1256
+ input = <<~"INPUT"
1257
+ #{ASCIIDOC_BLANK_HDR}
1258
+ [change="modify",locality="page=27",path="//table[2]",path_end="//table[2]/following-sibling:example[1]",title="Change"]
1259
+ ==== Change Clause
1260
+ _This table contains information on polygon cells which are not included in ISO 10303-52. Remove table 2 completely and replace with:_
1261
+ INPUT
1262
+ output = <<~"OUTPUT"
1263
+ #{BLANK_HDR}
1264
+ <sections>
1265
+ <clause id='_' inline-header='false' obligation='normative'>
1266
+ <title>Change Clause</title>
1267
+ <amend id='_' change='modify' path='//table[2]' path_end='//table[2]/following-sibling:example[1]' title='Change'>
1268
+ <description>
1269
+ <p id='_'>
1270
+ <em>
1271
+ This table contains information on polygon cells which are not
1272
+ included in ISO 10303-52. Remove table 2 completely and replace
1273
+ with:
1274
+ </em>
1275
+ </p>
1276
+ </description>
1277
+ </amend>
1278
+ </clause>
1279
+ </sections>
1280
+ </standard-document>
1281
+ OUTPUT
1282
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(output)
1283
+
1284
+ end
1285
+
1286
+ it "processes modify change clauses" do
1287
+ input = <<~"INPUT"
1288
+ #{ASCIIDOC_BLANK_HDR}
1289
+ [change="modify",locality="page=27",path="//table[2]",path_end="//table[2]/following-sibling:example[1]",title="Change"]
1290
+ ==== Change Clause
1291
+
1292
+ autonumber:table[2]
1293
+ autonumber:note[7]
1294
+
1295
+ _This table contains information on polygon cells which are not included in ISO 10303-52. Remove table 2 completely and replace with:_
1296
+
1297
+ ____
1298
+ .Edges of triangle and quadrilateral cells
1299
+ |===
1300
+ 2+^.^h| triangle 2+^.^h| quadrilateral
1301
+ ^.^| edge ^.^| vertices ^.^| edge ^.^| vertices
1302
+ ^.^| 1 ^.^| 1, 2 ^.^| 1 ^.^| 1, 2
1303
+ ^.^| 2 ^.^| 2, 3 ^.^| 2 ^.^| 2, 3
1304
+ ^.^| 3 ^.^| 3, 1 ^.^| 3 ^.^| 3, 4
1305
+ | | ^.^| 4 ^.^| 4, 1
1306
+ |===
1307
+
1308
+ ====
1309
+ This is not generalised further.
1310
+ ====
1311
+
1312
+ ____
1313
+
1314
+ Any further exceptions can be ignored.
1315
+ INPUT
1316
+
1317
+ output = <<~"OUTPUT"
1318
+ #{BLANK_HDR}
1319
+ <sections>
1320
+ <clause id='_' inline-header='false' obligation='normative'>
1321
+ <title>Change Clause</title>
1322
+ <amend id='_' change='modify' path='//table[2]' path_end='//table[2]/following-sibling:example[1]' title='Change'>
1323
+ <autonumber type='table'>2</autonumber>
1324
+ <autonumber type='note'>7</autonumber>
1325
+ <description>
1326
+ <p id='_'>
1327
+ <em>
1328
+ This table contains information on polygon cells which are not
1329
+ included in ISO 10303-52. Remove table 2 completely and replace
1330
+ with:
1331
+ </em>
1332
+ </p>
1333
+ </description>
1334
+ <newcontent id='_'>
1335
+ <table id='_'>
1336
+ <name>Edges of triangle and quadrilateral cells</name>
1337
+ <tbody>
1338
+ <tr>
1339
+ <th colspan='2' valign='middle' align='center'>triangle</th>
1340
+ <th colspan='2' valign='middle' align='center'>quadrilateral</th>
1341
+ </tr>
1342
+ <tr>
1343
+ <td valign='middle' align='center'>edge</td>
1344
+ <td valign='middle' align='center'>vertices</td>
1345
+ <td valign='middle' align='center'>edge</td>
1346
+ <td valign='middle' align='center'>vertices</td>
1347
+ </tr>
1348
+ <tr>
1349
+ <td valign='middle' align='center'>1</td>
1350
+ <td valign='middle' align='center'>1, 2</td>
1351
+ <td valign='middle' align='center'>1</td>
1352
+ <td valign='middle' align='center'>1, 2</td>
1353
+ </tr>
1354
+ <tr>
1355
+ <td valign='middle' align='center'>2</td>
1356
+ <td valign='middle' align='center'>2, 3</td>
1357
+ <td valign='middle' align='center'>2</td>
1358
+ <td valign='middle' align='center'>2, 3</td>
1359
+ </tr>
1360
+ <tr>
1361
+ <td valign='middle' align='center'>3</td>
1362
+ <td valign='middle' align='center'>3, 1</td>
1363
+ <td valign='middle' align='center'>3</td>
1364
+ <td valign='middle' align='center'>3, 4</td>
1365
+ </tr>
1366
+ <tr>
1367
+ <td valign='top' align='left'/>
1368
+ <td valign='top' align='left'/>
1369
+ <td valign='middle' align='center'>4</td>
1370
+ <td valign='middle' align='center'>4, 1</td>
1371
+ </tr>
1372
+ </tbody>
1373
+ </table>
1374
+ <example id='_'>
1375
+ <p id='_'>This is not generalised further.</p>
1376
+ </example>
1377
+ </newcontent>
1378
+ <description>
1379
+ <p id='_'>Any further exceptions can be ignored.</p>
1380
+ </description>
1381
+ </amend>
1382
+ </clause>
1383
+ </sections>
1384
+ </standard-document>
1385
+ OUTPUT
1386
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(output)
1387
+ end
1388
+
1389
+
1271
1390
  end