metanorma-standoc 2.2.6 → 2.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/lib/metanorma/standoc/base.rb +3 -5
  3. data/lib/metanorma/standoc/biblio.rng +5 -0
  4. data/lib/metanorma/standoc/cleanup.rb +17 -17
  5. data/lib/metanorma/standoc/cleanup_amend.rb +2 -2
  6. data/lib/metanorma/standoc/cleanup_biblio.rb +2 -1
  7. data/lib/metanorma/standoc/cleanup_maths.rb +12 -4
  8. data/lib/metanorma/standoc/cleanup_section.rb +19 -9
  9. data/lib/metanorma/standoc/cleanup_symbols.rb +14 -7
  10. data/lib/metanorma/standoc/cleanup_text.rb +10 -4
  11. data/lib/metanorma/standoc/cleanup_toc.rb +1 -2
  12. data/lib/metanorma/standoc/cleanup_xref.rb +55 -14
  13. data/lib/metanorma/standoc/inline.rb +27 -12
  14. data/lib/metanorma/standoc/isodoc.rng +46 -12
  15. data/lib/metanorma/standoc/ref_utility.rb +1 -0
  16. data/lib/metanorma/standoc/render.rb +10 -1
  17. data/lib/metanorma/standoc/section.rb +10 -3
  18. data/lib/metanorma/standoc/utils.rb +6 -1
  19. data/lib/metanorma/standoc/validate.rb +1 -1
  20. data/lib/metanorma/standoc/version.rb +1 -1
  21. data/metanorma-standoc.gemspec +5 -2
  22. metadata +4 -128
  23. data/.github/workflows/automerge.yml +0 -31
  24. data/.github/workflows/rake.yml +0 -15
  25. data/.github/workflows/release.yml +0 -24
  26. data/Rakefile +0 -8
  27. data/bin/rspec +0 -18
  28. data/spec/assets/a1.adoc +0 -8
  29. data/spec/assets/a2.adoc +0 -10
  30. data/spec/assets/a3.adoc +0 -9
  31. data/spec/assets/a3a.adoc +0 -7
  32. data/spec/assets/a4.adoc +0 -4
  33. data/spec/assets/boilerplate.xml +0 -4
  34. data/spec/assets/codes.yml +0 -695
  35. data/spec/assets/correct.png +0 -0
  36. data/spec/assets/corrupt.png +0 -0
  37. data/spec/assets/header.html +0 -7
  38. data/spec/assets/html-override.css +0 -1
  39. data/spec/assets/html.scss +0 -13
  40. data/spec/assets/htmlcover.html +0 -4
  41. data/spec/assets/htmlintro.html +0 -5
  42. data/spec/assets/i18n.yaml +0 -17
  43. data/spec/assets/iso.adoc +0 -10
  44. data/spec/assets/iso.headless.html +0 -33
  45. data/spec/assets/iso.xml +0 -8
  46. data/spec/assets/iso123.rxl +0 -107
  47. data/spec/assets/rice_image1.png +0 -0
  48. data/spec/assets/scripts.html +0 -3
  49. data/spec/assets/std.css +0 -2
  50. data/spec/assets/word-override.css +0 -1
  51. data/spec/assets/word.scss +0 -13
  52. data/spec/assets/wordcover.html +0 -3
  53. data/spec/assets/wordintro.html +0 -4
  54. data/spec/assets/xref_error.adoc +0 -8
  55. data/spec/examples/103_01_02.html +0 -247
  56. data/spec/examples/codes_table.html +0 -3174
  57. data/spec/examples/datamodel/address_class_profile.adoc +0 -5
  58. data/spec/examples/datamodel/address_class_profile.presentation.xml +0 -14
  59. data/spec/examples/datamodel/address_component_profile.adoc +0 -5
  60. data/spec/examples/datamodel/blank_definition_profile.adoc +0 -5
  61. data/spec/examples/datamodel/common_models_diagram.adoc +0 -5
  62. data/spec/examples/datamodel/models/models/AddressClassProfile.yml +0 -90
  63. data/spec/examples/datamodel/models/models/AddressComponentProfile.yml +0 -63
  64. data/spec/examples/datamodel/models/models/AddressComponentSpecification.yml +0 -15
  65. data/spec/examples/datamodel/models/models/AddressProfile.yml +0 -36
  66. data/spec/examples/datamodel/models/models/AttributeProfile.yml +0 -32
  67. data/spec/examples/datamodel/models/models/InterchangeAddressClassProfile.yml +0 -79
  68. data/spec/examples/datamodel/models/models/Localization copy.yml +0 -23
  69. data/spec/examples/datamodel/models/models/Localization.yml +0 -23
  70. data/spec/examples/datamodel/models/models/ProfileCompliantAddress.yml +0 -36
  71. data/spec/examples/datamodel/models/models/ProfileCompliantAddressComponent.yml +0 -15
  72. data/spec/examples/datamodel/models/models/Signature.yml +0 -20
  73. data/spec/examples/datamodel/models/models/SignatureBlankDefinition.yml +0 -20
  74. data/spec/examples/datamodel/models/models/TextDirectionCode copy.yml +0 -16
  75. data/spec/examples/datamodel/models/models/TextDirectionCode.yml +0 -16
  76. data/spec/examples/datamodel/models/models/Validity.yml +0 -14
  77. data/spec/examples/datamodel/models/models/iso19160-1/Address.yml +0 -22
  78. data/spec/examples/datamodel/models/models/iso19160-1/AddressComponent.yml +0 -2
  79. data/spec/examples/datamodel/models/style.uml.inc +0 -37
  80. data/spec/examples/datamodel/models/views/CommonModels.yml +0 -9
  81. data/spec/examples/datamodel/models/views/TopDown.yml +0 -62
  82. data/spec/examples/datamodel/top_down_diagram.adoc +0 -5
  83. data/spec/examples/english.yaml +0 -69
  84. data/spec/examples/iso_123_.xml +0 -46
  85. data/spec/examples/iso_123_all_parts.xml +0 -46
  86. data/spec/examples/iso_123_no_year_note.xml +0 -47
  87. data/spec/examples/iso_124_.xml +0 -42
  88. data/spec/examples/iso_216_.xml +0 -48
  89. data/spec/examples/iso_iec_12382_.xml +0 -49
  90. data/spec/examples/rice.adoc +0 -715
  91. data/spec/examples/rice.preview.html +0 -1877
  92. data/spec/examples/rice.sh +0 -4
  93. data/spec/examples/rice_images/rice_image1.png +0 -0
  94. data/spec/examples/rice_images/rice_image2.png +0 -0
  95. data/spec/examples/rice_images/rice_image3_1.png +0 -0
  96. data/spec/examples/rice_images/rice_image3_2.png +0 -0
  97. data/spec/examples/rice_images/rice_image3_3.png +0 -0
  98. data/spec/fixtures/action_schemaexpg1.svg +0 -122
  99. data/spec/fixtures/datamodel_description_sections_tree.xml +0 -327
  100. data/spec/fixtures/diagram_definitions.lutaml +0 -22
  101. data/spec/fixtures/macros_datamodel/address_class_profile.xml +0 -149
  102. data/spec/fixtures/macros_datamodel/address_component_profile.xml +0 -71
  103. data/spec/fixtures/macros_datamodel/blank_definition_profile.xml +0 -51
  104. data/spec/fixtures/macros_datamodel/common_models_diagram.xml +0 -7
  105. data/spec/fixtures/macros_datamodel/top_down_diagram.xml +0 -7
  106. data/spec/fixtures/test.exp +0 -121
  107. data/spec/fixtures/test.xmi +0 -9250
  108. data/spec/metanorma/base_spec.rb +0 -1125
  109. data/spec/metanorma/biblio_spec.rb +0 -1012
  110. data/spec/metanorma/blank_spec.rb +0 -37
  111. data/spec/metanorma/blocks_spec.rb +0 -1784
  112. data/spec/metanorma/cleanup_blocks_spec.rb +0 -1099
  113. data/spec/metanorma/cleanup_sections_spec.rb +0 -1849
  114. data/spec/metanorma/cleanup_spec.rb +0 -1931
  115. data/spec/metanorma/cleanup_terms_spec.rb +0 -1543
  116. data/spec/metanorma/datamodel/attributes_table_preprocessor_spec.rb +0 -111
  117. data/spec/metanorma/datamodel/diagram_preprocessor_spec.rb +0 -72
  118. data/spec/metanorma/inline_spec.rb +0 -785
  119. data/spec/metanorma/isobib_cache_spec.rb +0 -742
  120. data/spec/metanorma/lists_spec.rb +0 -232
  121. data/spec/metanorma/macros_concept_spec.rb +0 -1052
  122. data/spec/metanorma/macros_json2text_spec.rb +0 -10
  123. data/spec/metanorma/macros_plantuml_spec.rb +0 -402
  124. data/spec/metanorma/macros_spec.rb +0 -1183
  125. data/spec/metanorma/macros_yaml2text_spec.rb +0 -10
  126. data/spec/metanorma/processor_spec.rb +0 -96
  127. data/spec/metanorma/refs_spec.rb +0 -2807
  128. data/spec/metanorma/reqt_spec.rb +0 -130
  129. data/spec/metanorma/section_spec.rb +0 -1325
  130. data/spec/metanorma/table_spec.rb +0 -474
  131. data/spec/metanorma/validate_spec.rb +0 -886
  132. data/spec/spec_helper.rb +0 -290
  133. data/spec/support/shared_examples/structured_data_2_text_preprocessor.rb +0 -781
  134. data/spec/vcr_cassettes/bsi16341.yml +0 -486
  135. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +0 -611
  136. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +0 -149
  137. data/spec/vcr_cassettes/hide_refs.yml +0 -587
  138. data/spec/vcr_cassettes/isobib_get_123.yml +0 -149
  139. data/spec/vcr_cassettes/isobib_get_123_1.yml +0 -295
  140. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +0 -385
  141. data/spec/vcr_cassettes/isobib_get_123_2.yml +0 -295
  142. data/spec/vcr_cassettes/isobib_get_123_2001.yml +0 -149
  143. data/spec/vcr_cassettes/isobib_get_124.yml +0 -149
  144. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +0 -367
  145. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +0 -560
  146. data/spec/vcr_cassettes/std-link.yml +0 -149
@@ -1,1099 +0,0 @@
1
- require "spec_helper"
2
- require "fileutils"
3
-
4
- RSpec.describe Metanorma::Standoc do
5
- it "processes svgmap" do
6
- FileUtils.cp "spec/fixtures/action_schemaexpg1.svg",
7
- "action_schemaexpg1.svg"
8
- FileUtils.cp "spec/fixtures/action_schemaexpg1.svg",
9
- "action_schemaexpg2.svg"
10
- input = <<~INPUT
11
- #{ASCIIDOC_BLANK_HDR}
12
-
13
- [svgmap%unnumbered,number=8,subsequence=A,keep-with-next=true,keep-lines-together=true]
14
- ====
15
- * <<ref1,Computer>>; http://www.example.com
16
- ====
17
-
18
- [[ref1]]
19
- .SVG title
20
- [.svgmap]
21
- ====
22
- image::action_schemaexpg1.svg[]
23
-
24
- * <<ref1,Computer>>; mn://action_schema
25
- * http://www.example.com[Phone]; http://www.example.com
26
- ====
27
-
28
- [[ref2]]
29
- [svgmap%unnumbered,number=8,subsequence=A,keep-with-next=true,keep-lines-together=true]
30
- ====
31
- [alt=Workmap]
32
- image::action_schemaexpg2.svg[]
33
-
34
- * <<ref1,Computer>>; mn://action_schema
35
- * http://www.example.com[Phone]; mn://basic_attribute_schema
36
- * <<express:action_schema:action_schema.basic,Coffee>>; mn://support_resource_schema
37
- ====
38
- INPUT
39
- output = <<~OUTPUT
40
- #{BLANK_HDR}
41
- <sections>
42
- <svgmap unnumbered='true' number='8' subsequence='A' keep-with-next='true' keep-lines-together='true'>
43
- <target href='http://www.example.com'>
44
- <xref target='ref1'>Computer</xref>
45
- </target>
46
- </svgmap>
47
- <figure id='ref1'>
48
- <name>SVG title</name>
49
- <svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' id='Layer_1_000000001' x='0px' y='0px' viewBox='0 0 595.28 841.89' style='enable-background:new 0 0 595.28 841.89;' xml:space='preserve'>
50
- <style/>
51
- <image/>
52
- <a xlink:href='#ref1'>
53
- <rect x='123.28' y='273.93' class='st0' width='88.05' height='41.84'/>
54
- </a>
55
- <a xlink:href='mn://basic_attribute_schema'>
56
- <rect x='324.69' y='450.52' class='st0' width='132.62' height='40.75'/>
57
- </a>
58
- <a xlink:href='mn://support_resource_schema'>
59
- <rect x='324.69' y='528.36' class='st0' width='148.16' height='40.75'/>
60
- </a>
61
- </svg>
62
- </figure>
63
- <svgmap>
64
- <figure id='ref2' unnumbered='true' number='8' subsequence='A' keep-with-next='true' keep-lines-together='true'>
65
- <svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' id='Layer_1_000000002' x='0px' y='0px' viewBox='0 0 595.28 841.89' style='enable-background:new 0 0 595.28 841.89;' xml:space='preserve'>
66
- <style/>
67
- <image/>
68
- <a xlink:href='#ref1'>
69
- <rect x='123.28' y='273.93' class='st0' width='88.05' height='41.84'/>
70
- </a>
71
- <a xlink:href='http://www.example.com'>
72
- <rect x='324.69' y='450.52' class='st0' width='132.62' height='40.75'/>
73
- </a>
74
- <a xlink:href='mn://support_resource_schema'>
75
- <rect x='324.69' y='528.36' class='st0' width='148.16' height='40.75'/>
76
- </a>
77
- </svg>
78
- </figure>
79
- <target href='mn://support_resource_schema'>
80
- <eref bibitemid='express_action_schema' citeas=''>
81
- <localityStack>
82
- <locality type='anchor'>
83
- <referenceFrom>action_schema.basic</referenceFrom>
84
- </locality>
85
- </localityStack>
86
- Coffee
87
- </eref>
88
- </target>
89
- </svgmap>
90
- </sections>
91
- <bibliography>
92
- <references hidden='true' normative='false'>
93
- <bibitem id='express_action_schema' type='internal'>
94
- <docidentifier type='repository'>express/action_schema</docidentifier>
95
- </bibitem>
96
- </references>
97
- </bibliography>
98
- </standard-document>
99
- OUTPUT
100
- expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))
101
- .gsub(%r{<image.*?</image>}m, "<image/>")
102
- .gsub(%r{<style.*?</style>}m, "<style/>"))
103
- .to be_equivalent_to xmlpp(output)
104
- end
105
-
106
- it "processes markup in sourcecode" do
107
- input = <<~INPUT
108
- #{ASCIIDOC_BLANK_HDR}
109
-
110
- [source]
111
- ----
112
- <tag/>
113
- ----
114
-
115
- [[A]]
116
- [source]
117
- ----
118
- var {{{*x*}}} : {{{<<A,recursive>>}}} <tag/>
119
- ----
120
-
121
-
122
- INPUT
123
- output = <<~OUTPUT
124
- #{BLANK_HDR}
125
- <sections>
126
- <sourcecode id='_'>&lt;tag/&gt;</sourcecode>
127
- <sourcecode id='A'>
128
- var
129
- <strong>x</strong>
130
- :
131
- <xref target='A'>recursive</xref>
132
- &lt;tag/&gt;
133
- </sourcecode>
134
- </sections>
135
- </standard-document>
136
- OUTPUT
137
- expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
138
- .to be_equivalent_to xmlpp(output)
139
- end
140
-
141
- it "processes markup in sourcecode with custom delimiters" do
142
- input = <<~INPUT
143
- = Document title
144
- Author
145
- :docfile: test.adoc
146
- :nodoc:
147
- :novalid:
148
- :no-isobib:
149
- :sourcecode-markup-start: [[[
150
- :sourcecode-markup-end: ]]]
151
-
152
- [[A]]
153
- [source]
154
- ----
155
- var [[[*x*]]] : [[[<<A,recursive>>]]]
156
- ----
157
-
158
-
159
- INPUT
160
- output = <<~OUTPUT
161
- #{BLANK_HDR}
162
- <sections>
163
- <sourcecode id='A'>
164
- var
165
- <strong>x</strong>
166
- :
167
- <xref target='A'>recursive</xref>
168
- </sourcecode>
169
- </sections>
170
- </standard-document>
171
- OUTPUT
172
- expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
173
- .to be_equivalent_to xmlpp(output)
174
- end
175
-
176
- it "moves notes inside preceding blocks, if they are not at clause end, and the blocks are not delimited" do
177
- input = <<~INPUT
178
- #{ASCIIDOC_BLANK_HDR}
179
-
180
- [stem]
181
- ++++
182
- r = 1 %
183
- r = 1 %
184
- ++++
185
-
186
- NOTE: That formula does not do much
187
-
188
- Indeed.
189
- INPUT
190
- output = <<~OUTPUT
191
- #{BLANK_HDR}
192
- <sections><formula id="_">
193
- <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>r</mi><mo>=</mo><mn>1</mn><mo>%</mo><mi>r</mi><mo>=</mo><mn>1</mn><mo>%</mo></math></stem>
194
- <note id="_">
195
- <p id="_">That formula does not do much</p>
196
- </note></formula>
197
- <p id="_">Indeed.</p></sections>
198
- </standard-document>
199
- OUTPUT
200
- expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
201
- .to be_equivalent_to xmlpp(output)
202
- end
203
-
204
- it "does not move notes inside preceding blocks, if they are marked as keep-separate" do
205
- input = <<~INPUT
206
- #{ASCIIDOC_BLANK_HDR}
207
-
208
- [stem]
209
- ++++
210
- r = 1 %
211
- r = 1 %
212
- ++++
213
-
214
- [NOTE,keep-separate=true]
215
- ====
216
- That formula does not do much
217
- ====
218
-
219
- Indeed.
220
- INPUT
221
- output = <<~OUTPUT
222
- #{BLANK_HDR}
223
- <sections><formula id="_">
224
- <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>r</mi><mo>=</mo><mn>1</mn><mo>%</mo><mi>r</mi><mo>=</mo><mn>1</mn><mo>%</mo></math></stem></formula>
225
- <note id="_">
226
- <p id="_">That formula does not do much</p>
227
- </note>
228
- <p id="_">Indeed.</p></sections>
229
- </standard-document>
230
- OUTPUT
231
- expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
232
- .to be_equivalent_to xmlpp(output)
233
- end
234
-
235
- it "does not move notes inside preceding tables, if they are marked as keep-separate" do
236
- input = <<~INPUT
237
- #{ASCIIDOC_BLANK_HDR}
238
-
239
- |===
240
- |A |B
241
-
242
- |C |D
243
- |===
244
-
245
- [NOTE,keep-separate=true]
246
- ====
247
- That formula does not do much
248
- ====
249
-
250
- |===
251
- |A |B
252
-
253
- |C |D
254
- |===
255
-
256
- [NOTE]
257
- ====
258
- That formula does not do much
259
- ====
260
-
261
- Indeed.
262
- INPUT
263
- output = <<~OUTPUT
264
- #{BLANK_HDR}
265
- <sections>
266
- <table id='_'>
267
- <thead>
268
- <tr>
269
- <th valign='top' align='left'>A</th>
270
- <th valign='top' align='left'>B</th>
271
- </tr>
272
- </thead>
273
- <tbody>
274
- <tr>
275
- <td valign='top' align='left'>C</td>
276
- <td valign='top' align='left'>D</td>
277
- </tr>
278
- </tbody>
279
- </table>
280
- <note id='_'>
281
- <p id='_'>That formula does not do much</p>
282
- </note>
283
- <table id='_'>
284
- <thead>
285
- <tr>
286
- <th valign='top' align='left'>A</th>
287
- <th valign='top' align='left'>B</th>
288
- </tr>
289
- </thead>
290
- <tbody>
291
- <tr>
292
- <td valign='top' align='left'>C</td>
293
- <td valign='top' align='left'>D</td>
294
- </tr>
295
- </tbody>
296
- <note id='_'>
297
- <p id='_'>That formula does not do much</p>
298
- </note>
299
- </table>
300
- <p id='_'>Indeed.</p>
301
- </sections>
302
- </standard-document>
303
- OUTPUT
304
- expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
305
- .to be_equivalent_to xmlpp(output)
306
- end
307
-
308
- it "does not move notes inside preceding blocks, if they are at clause end" do
309
- input = <<~INPUT
310
- #{ASCIIDOC_BLANK_HDR}
311
- [source,ruby]
312
- [1...x].each do |y|
313
- puts y
314
- end
315
-
316
- NOTE: That loop does not do much
317
- INPUT
318
- output = <<~OUTPUT
319
- #{BLANK_HDR}
320
- <sections><sourcecode id="_" lang="ruby">[1...x].each do |y|
321
- puts y
322
- end</sourcecode>
323
- <note id="_">
324
- <p id="_">That loop does not do much</p>
325
- </note></sections>
326
- </standard-document>
327
- OUTPUT
328
- expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
329
- .to be_equivalent_to xmlpp(output)
330
- end
331
-
332
- it "inserts IDs into paragraphs" do
333
- input = <<~INPUT
334
- #{ASCIIDOC_BLANK_HDR}
335
- Paragraph
336
- INPUT
337
- output = <<~OUTPUT
338
- #{BLANK_HDR}
339
- <sections>
340
- <p id="_">Paragraph</p>
341
- </sections>
342
- </standard-document>
343
- OUTPUT
344
- expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
345
- .to be_equivalent_to xmlpp(output)
346
- end
347
-
348
- it "inserts IDs into notes" do
349
- input = <<~INPUT
350
- #{ASCIIDOC_BLANK_HDR}
351
- [example]
352
- ====
353
- NOTE: This note has no ID
354
- ====
355
- INPUT
356
- output = <<~OUTPUT
357
- #{BLANK_HDR}
358
- <sections>
359
- <example id="_">
360
- <note id="_">
361
- <p id="_">This note has no ID</p>
362
- </note>
363
- </example>
364
- </sections>
365
- </standard-document>
366
- OUTPUT
367
- expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
368
- .to be_equivalent_to xmlpp(output)
369
- end
370
-
371
- it "moves table key inside table" do
372
- input = <<~INPUT
373
- #{ASCIIDOC_BLANK_HDR}
374
- |===
375
- |a |b |c
376
- |===
377
-
378
- Key
379
-
380
- a:: b
381
-
382
- |===
383
- |a |b |c
384
- |===
385
-
386
- [%key]
387
- a:: b
388
-
389
- |===
390
- |a |b |c
391
- |===
392
-
393
- a:: b
394
- INPUT
395
- output = <<~OUTPUT
396
- #{BLANK_HDR}
397
- <sections>
398
- <table id='_'>
399
- <tbody>
400
- <tr>
401
- <td valign='top' align='left'>a</td>
402
- <td valign='top' align='left'>b</td>
403
- <td valign='top' align='left'>c</td>
404
- </tr>
405
- </tbody>
406
- <dl id='_' key='true'>
407
- <dt>a</dt>
408
- <dd>
409
- <p id='_'>b</p>
410
- </dd>
411
- </dl>
412
- </table>
413
- <table id='_'>
414
- <tbody>
415
- <tr>
416
- <td valign='top' align='left'>a</td>
417
- <td valign='top' align='left'>b</td>
418
- <td valign='top' align='left'>c</td>
419
- </tr>
420
- </tbody>
421
- <dl id='_' key='true'>
422
- <dt>a</dt>
423
- <dd>
424
- <p id='_'>b</p>
425
- </dd>
426
- </dl>
427
- </table>
428
- <table id='_'>
429
- <tbody>
430
- <tr>
431
- <td valign='top' align='left'>a</td>
432
- <td valign='top' align='left'>b</td>
433
- <td valign='top' align='left'>c</td>
434
- </tr>
435
- </tbody>
436
- </table>
437
- <dl id='_'>
438
- <dt>a</dt>
439
- <dd>
440
- <p id='_'>b</p>
441
- </dd>
442
- </dl>
443
- </sections>
444
- </standard-document>
445
- OUTPUT
446
- expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
447
- .to be_equivalent_to xmlpp(output)
448
- end
449
-
450
- it "processes headerrows attribute for table without header rows" do
451
- input = <<~INPUT
452
- #{ASCIIDOC_BLANK_HDR}
453
- [headerrows=3]
454
- |===
455
- |a |b |c
456
- |a |b |c
457
- |a |b |c
458
- |a |b |c
459
- |===
460
- INPUT
461
- output = <<~OUTPUT
462
- #{BLANK_HDR}
463
- <sections>
464
- <table id="_"><thead><tr>
465
- <th valign="top" align="left">a</th>
466
- <th valign="top" align="left">b</th>
467
- <th valign="top" align="left">c</th>
468
- </tr><tr>
469
- <th valign="top" align="left">a</th>
470
- <th valign="top" align="left">b</th>
471
- <th valign="top" align="left">c</th>
472
- </tr><tr>
473
- <th valign="top" align="left">a</th>
474
- <th valign="top" align="left">b</th>
475
- <th valign="top" align="left">c</th>
476
- </tr></thead>
477
- <tbody>
478
- <tr>
479
- <td valign="top" align="left">a</td>
480
- <td valign="top" align="left">b</td>
481
- <td valign="top" align="left">c</td>
482
- </tr>
483
- </tbody>
484
- </table>
485
- </sections>
486
- </standard-document>
487
- OUTPUT
488
- expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
489
- .to be_equivalent_to xmlpp(output)
490
- end
491
-
492
- it "processes headerrows attribute for table with header rows" do
493
- input = <<~INPUT
494
- #{ASCIIDOC_BLANK_HDR}
495
- [headerrows=3]
496
- |===
497
- |a |b |c
498
-
499
- |a |b |c
500
- |a |b |c
501
- |a |b |c
502
- |===
503
- INPUT
504
- output = <<~OUTPUT
505
- #{BLANK_HDR}
506
- <sections>
507
- <table id="_">
508
- <thead>
509
- <tr>
510
- <th valign="top" align="left">a</th>
511
- <th valign="top" align="left">b</th>
512
- <th valign="top" align="left">c</th>
513
- </tr>
514
- <tr>
515
- <th valign="top" align="left">a</th>
516
- <th valign="top" align="left">b</th>
517
- <th valign="top" align="left">c</th>
518
- </tr><tr>
519
- <th valign="top" align="left">a</th>
520
- <th valign="top" align="left">b</th>
521
- <th valign="top" align="left">c</th>
522
- </tr></thead>
523
- <tbody>
524
-
525
-
526
- <tr>
527
- <td valign="top" align="left">a</td>
528
- <td valign="top" align="left">b</td>
529
- <td valign="top" align="left">c</td>
530
- </tr>
531
- </tbody>
532
- </table>
533
- </sections>
534
- </standard-document>
535
- OUTPUT
536
- expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
537
- .to be_equivalent_to xmlpp(output)
538
- end
539
-
540
- it "moves table notes inside table" do
541
- input = <<~INPUT
542
- #{ASCIIDOC_BLANK_HDR}
543
- |===
544
- |a |b |c
545
- |===
546
-
547
- NOTE: Note 1
548
-
549
- NOTE: Note 2
550
- INPUT
551
- output = <<~OUTPUT
552
- #{BLANK_HDR}
553
- <sections><table id="_">
554
- <tbody>
555
- <tr>
556
- <td valign="top" align="left">a</td>
557
- <td valign="top" align="left">b</td>
558
- <td valign="top" align="left">c</td>
559
- </tr>
560
- </tbody>
561
- <note id="_">
562
- <p id="_">Note 1</p>
563
- </note><note id="_">
564
- <p id="_">Note 2</p>
565
- </note></table>
566
-
567
- </sections>
568
- </standard-document>
569
- OUTPUT
570
- expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
571
- .to be_equivalent_to xmlpp(output)
572
- end
573
-
574
- it "moves formula key inside formula" do
575
- input = <<~INPUT
576
- #{ASCIIDOC_BLANK_HDR}
577
- [stem]
578
- ++++
579
- Formula
580
- ++++
581
-
582
- Where,
583
-
584
- a:: b
585
-
586
- [stem]
587
- ++++
588
- Formula
589
- ++++
590
-
591
- [%key]
592
- a:: b
593
-
594
- [stem]
595
- ++++
596
- Formula
597
- ++++
598
-
599
- a:: b
600
- INPUT
601
- output = <<~OUTPUT
602
- #{BLANK_HDR}
603
- <sections>
604
- <formula id='_'>
605
- <stem type='MathML'>
606
- <math xmlns='http://www.w3.org/1998/Math/MathML'>
607
- <mi>F</mi>
608
- <mi>or</mi>
609
- <mi>μ</mi>
610
- <mi>l</mi>
611
- <mi>a</mi>
612
- </math>
613
- </stem>
614
- <dl id='_' key='true'>
615
- <dt>a</dt>
616
- <dd>
617
- <p id='_'>b</p>
618
- </dd>
619
- </dl>
620
- </formula>
621
- <formula id='_'>
622
- <stem type='MathML'>
623
- <math xmlns='http://www.w3.org/1998/Math/MathML'>
624
- <mi>F</mi>
625
- <mi>or</mi>
626
- <mi>μ</mi>
627
- <mi>l</mi>
628
- <mi>a</mi>
629
- </math>
630
- </stem>
631
- <dl id='_' key='true'>
632
- <dt>a</dt>
633
- <dd>
634
- <p id='_'>b</p>
635
- </dd>
636
- </dl>
637
- </formula>
638
- <formula id='_'>
639
- <stem type='MathML'>
640
- <math xmlns='http://www.w3.org/1998/Math/MathML'>
641
- <mi>F</mi>
642
- <mi>or</mi>
643
- <mi>μ</mi>
644
- <mi>l</mi>
645
- <mi>a</mi>
646
- </math>
647
- </stem>
648
- </formula>
649
- <dl id='_'>
650
- <dt>a</dt>
651
- <dd>
652
- <p id='_'>b</p>
653
- </dd>
654
- </dl>
655
- </sections>
656
- </standard-document>
657
- OUTPUT
658
- expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
659
- .to be_equivalent_to xmlpp(output)
660
- end
661
-
662
- it "moves footnotes inside figures" do
663
- input = <<~INPUT
664
- #{ASCIIDOC_BLANK_HDR}
665
- .Figuretitle.footnote:[xyz]
666
- image::spec/examples/rice_images/rice_image1.png[]
667
-
668
- footnote:[This is a footnote to a figure]
669
-
670
- footnote:[This is another footnote to a figure]
671
-
672
- A footnote:[This is a third footnote]
673
- INPUT
674
- output = <<~OUTPUT
675
- #{BLANK_HDR}
676
- <sections><figure id="_">
677
- <name>
678
- Figuretitle.
679
- <fn reference='1'>
680
- <p id='_'>xyz</p>
681
- </fn>
682
- </name>
683
- <image src="spec/examples/rice_images/rice_image1.png" id="_" mimetype="image/png" height="auto" width="auto"/>
684
- <fn reference="a">
685
- <p id="_">This is a footnote to a figure</p>
686
- </fn><fn reference="b">
687
- <p id="_">This is another footnote to a figure</p>
688
- </fn></figure>
689
- <p id='_'>
690
- A
691
- <fn reference='2'>
692
- <p id='_'>This is a third footnote</p>
693
- </fn>
694
- </p>
695
- </sections>
696
- </standard-document>
697
- OUTPUT
698
- expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
699
- .to be_equivalent_to xmlpp(output)
700
- end
701
-
702
- it "moves figure key inside figure" do
703
- input = <<~INPUT
704
- #{ASCIIDOC_BLANK_HDR}
705
- image::spec/examples/rice_images/rice_image1.png[]
706
-
707
- key:
708
-
709
- a:: b
710
-
711
- image::spec/examples/rice_images/rice_image1.png[]
712
-
713
- [%key]
714
- a:: b
715
-
716
- image::spec/examples/rice_images/rice_image1.png[]
717
-
718
- a:: b
719
- INPUT
720
- output = <<~OUTPUT
721
- #{BLANK_HDR}
722
- <sections>
723
- <figure id='_'>
724
- <image src='spec/examples/rice_images/rice_image1.png' id='_' mimetype='image/png' height='auto' width='auto'/>
725
- <dl id='_' key='true'>
726
- <dt>a</dt>
727
- <dd>
728
- <p id='_'>b</p>
729
- </dd>
730
- </dl>
731
- </figure>
732
- <figure id='_'>
733
- <image src='spec/examples/rice_images/rice_image1.png' id='_' mimetype='image/png' height='auto' width='auto'/>
734
- <dl id='_' key='true'>
735
- <dt>a</dt>
736
- <dd>
737
- <p id='_'>b</p>
738
- </dd>
739
- </dl>
740
- </figure>
741
- <figure id='_'>
742
- <image src='spec/examples/rice_images/rice_image1.png' id='_' mimetype='image/png' height='auto' width='auto'/>
743
- </figure>
744
- <dl id='_'>
745
- <dt>a</dt>
746
- <dd>
747
- <p id='_'>b</p>
748
- </dd>
749
- </dl>
750
- </sections>
751
- </standard-document>
752
- OUTPUT
753
- expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
754
- .to be_equivalent_to xmlpp(output)
755
- end
756
-
757
- it "processes subfigures" do
758
- input = <<~INPUT
759
- #{ASCIIDOC_BLANK_HDR}
760
- [[figureC-2]]
761
- .Stages of gelatinization
762
- ====
763
- .Initial stages: No grains are fully gelatinized (ungelatinized starch granules are visible inside the kernels)
764
- image::spec/examples/rice_images/rice_image3_1.png[]
765
-
766
- .Intermediate stages: Some fully gelatinized kernels are visible
767
- image::spec/examples/rice_images/rice_image3_2.png[]
768
-
769
- .Final stages: All kernels are fully gelatinized
770
- image::spec/examples/rice_images/rice_image3_3.png[]
771
- ====
772
- INPUT
773
- output = <<~OUTPUT
774
- #{BLANK_HDR}
775
- <sections>
776
- <figure id="figureC-2"><name>Stages of gelatinization</name><figure id="_">
777
- <name>Initial stages: No grains are fully gelatinized (ungelatinized starch granules are visible inside the kernels)</name>
778
- <image src="spec/examples/rice_images/rice_image3_1.png" id="_" mimetype="image/png" height="auto" width="auto"/>
779
- </figure>
780
- <figure id="_">
781
- <name>Intermediate stages: Some fully gelatinized kernels are visible</name>
782
- <image src="spec/examples/rice_images/rice_image3_2.png" id="_" mimetype="image/png" height="auto" width="auto"/>
783
- </figure>
784
- <figure id="_">
785
- <name>Final stages: All kernels are fully gelatinized</name>
786
- <image src="spec/examples/rice_images/rice_image3_3.png" id="_" mimetype="image/png" height="auto" width="auto"/>
787
- </figure></figure>
788
- </sections>
789
- </standard-document>
790
- OUTPUT
791
- expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
792
- .to be_equivalent_to xmlpp(output)
793
- end
794
-
795
- it "moves %beforeclause admonitions to right position" do
796
- input = <<~INPUT
797
- #{ASCIIDOC_BLANK_HDR}
798
-
799
- .Foreword
800
- Foreword
801
-
802
- [NOTE,beforeclauses=true]
803
- ====
804
- Note which is very important
805
- ====
806
-
807
- == Introduction
808
- Introduction
809
-
810
- == Scope
811
- Scope statement
812
-
813
- [IMPORTANT,beforeclauses=true]
814
- ====
815
- Notice which is very important
816
- ====
817
-
818
- [IMPORTANT,coverpage=true]
819
- ====
820
- Notice which is also very important
821
- ====
822
-
823
- INPUT
824
- output = <<~OUTPUT
825
- #{BLANK_HDR}
826
- <preface>
827
- <note id='_'>
828
- <p id='_'>Note which is very important</p>
829
- </note>
830
- <admonition id='_' type='important' coverpage='true'>
831
- <p id='_'>Notice which is also very important</p>
832
- </admonition>
833
- <foreword id='_' obligation='informative'>
834
- <title>Foreword</title>
835
- <p id='_'>Foreword</p>
836
- </foreword>
837
- <introduction id='_' obligation='informative'>
838
- <title>Introduction</title>
839
- <p id='_'>Introduction</p>
840
- </introduction>
841
- </preface>
842
- <sections>
843
- <admonition id='_' type='important'>
844
- <p id='_'>Notice which is very important</p>
845
- </admonition>
846
- <clause id='_' inline-header='false' obligation='normative' type="scope">
847
- <title>Scope</title>
848
- <p id='_'>Scope statement</p>
849
- </clause>
850
- </sections>
851
- </standard-document>
852
- OUTPUT
853
- expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
854
- .to be_equivalent_to xmlpp(output)
855
- end
856
-
857
- it "updates anchor reference along with anchor to match content" do
858
- input = <<~INPUT
859
- #{ASCIIDOC_BLANK_HDR}
860
-
861
- [[samplecode]]
862
- .Sample Code
863
- ====
864
-
865
- [source,ruby]
866
- --
867
- puts "Hello, world."
868
- %w{a b c}.each do |x| <1>
869
- puts x
870
- end
871
- --
872
- <1> This is an annotation
873
- ====
874
- INPUT
875
- output = Nokogiri::XML(Asciidoctor.convert(input, *OPTIONS))
876
- callout_id = output.at("//xmlns:callout/@target").text
877
- annotation_id = output.at("//xmlns:annotation/@id").text
878
- expect(callout_id).to eq(annotation_id)
879
- end
880
- it "deduplicates identifiers in inline SVGs" do
881
- input = <<~INPUT
882
- #{BLANK_HDR}
883
- <sections>
884
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 256 256">
885
- <defs>
886
- <linearGradient id="gradient1">
887
- <stop class="stop1" offset="0%" xlink:href="#gradient1"/>
888
- <stop class="stop2" offset="100%"/>
889
- <style>url(#gradient1)</style>
890
- </linearGradient>
891
- </defs>
892
- <circle fill="url(#gradient1)" cx="128" cy="128" r="100" />
893
- </svg>
894
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 256 256">
895
- <defs>
896
- <linearGradient id="gradient2">
897
- <stop class="stop1" offset="0%" xlink:href="#gradient2"/>
898
- <stop class="stop2" offset="100%"/>
899
- <style>url(#gradient2)</style>
900
- </linearGradient>
901
- </defs>
902
- <circle fill="url(#gradient2)" cx="128" cy="128" r="100" />
903
- </svg>
904
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 256 256">
905
- <defs>
906
- <linearGradient id="gradient1">
907
- <stop class="stop1" offset="0%" xlink:href="#gradient1"/>
908
- <stop class="stop2" offset="100%"/>
909
- <style>url(#gradient1)</style>
910
- </linearGradient>
911
- </defs>
912
- <circle fill="url(#gradient1)" cx="128" cy="128" r="100" />
913
- </svg>
914
- </sections>
915
- </standard-document>
916
- INPUT
917
- output = <<~OUTPUT
918
- #{BLANK_HDR}
919
- <sections>
920
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" viewBox="0 0 256 256">
921
- <defs>
922
- <linearGradient id="gradient1_inject_0">
923
- <stop class="stop1" offset="0%" xlink:href="#gradient1_inject_0"/>
924
- <stop class="stop2" offset="100%"/>
925
- <style>url(#gradient1_inject_0)</style>
926
- </linearGradient>
927
- </defs>
928
- <circle fill="url(#gradient1_inject_0)" cx="128" cy="128" r="100"/>
929
- </svg>
930
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" viewBox="0 0 256 256">
931
- <defs>
932
- <linearGradient id="gradient2">
933
- <stop class="stop1" offset="0%" xlink:href="#gradient2"/>
934
- <stop class="stop2" offset="100%"/>
935
- <style>url(#gradient2)</style>
936
- </linearGradient>
937
- </defs>
938
- <circle fill="url(#gradient2)" cx="128" cy="128" r="100"/>
939
- </svg>
940
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" viewBox="0 0 256 256">
941
- <defs>
942
- <linearGradient id="gradient1_inject_2">
943
- <stop class="stop1" offset="0%" xlink:href="#gradient1_inject_2"/>
944
- <stop class="stop2" offset="100%"/>
945
- <style>url(#gradient1_inject_2)</style>
946
- </linearGradient>
947
- </defs>
948
- <circle fill="url(#gradient1_inject_2)" cx="128" cy="128" r="100"/>
949
- </svg>
950
- </sections>
951
- </standard-document>
952
- OUTPUT
953
- expect(Metanorma::Standoc::Converter.new(nil, *OPTIONS)
954
- .cleanup(Nokogiri::XML(input)).to_xml)
955
- .to be_equivalent_to xmlpp(output)
956
- end
957
-
958
- it "deduplicates identifiers in embedded SVGs" do
959
- input = <<~INPUT
960
- #{ASCIIDOC_BLANK_HDR.sub(/:data-uri-image: false/, ':data-uri-image: true')}
961
-
962
- image::spec/fixtures/action_schemaexpg1.svg[]
963
-
964
- image::spec/examples/rice_images/rice_image1.png[]
965
-
966
- image::spec/fixtures/action_schemaexpg1.svg[]
967
- INPUT
968
-
969
- output = <<~OUTPUT
970
- #{BLANK_HDR}
971
- <sections>
972
- <figure id='_'>
973
- <svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' id='Layer_1' x='0px' y='0px' viewBox='0 0 595.28 841.89' style='enable-background:new 0 0 595.28 841.89;' xml:space='preserve'>
974
- <style/>
975
- <image/>
976
- <a xlink:href='mn://action_schema'>
977
- <rect x='123.28' y='273.93' class='st0' width='88.05' height='41.84'/>
978
- </a>
979
- <a xlink:href='mn://basic_attribute_schema'>
980
- <rect x='324.69' y='450.52' class='st0' width='132.62' height='40.75'/>
981
- </a>
982
- <a xlink:href='mn://support_resource_schema'>
983
- <rect x='324.69' y='528.36' class='st0' width='148.16' height='40.75'/>
984
- </a>
985
- </svg>
986
- </figure>
987
- <figure id='_'>
988
- <image/>
989
- </figure>
990
- <figure id='_'>
991
- <svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' id='Layer_1_inject_1' x='0px' y='0px' viewBox='0 0 595.28 841.89' style='enable-background:new 0 0 595.28 841.89;' xml:space='preserve'>
992
- <style/>
993
- <image/>
994
- <a xlink:href='mn://action_schema'>
995
- <rect x='123.28' y='273.93' class='st0' width='88.05' height='41.84'/>
996
- </a>
997
- <a xlink:href='mn://basic_attribute_schema'>
998
- <rect x='324.69' y='450.52' class='st0' width='132.62' height='40.75'/>
999
- </a>
1000
- <a xlink:href='mn://support_resource_schema'>
1001
- <rect x='324.69' y='528.36' class='st0' width='148.16' height='40.75'/>
1002
- </a>
1003
- </svg>
1004
- </figure>
1005
- </sections>
1006
- </standard-document>
1007
- OUTPUT
1008
- xml = Nokogiri::XML(Asciidoctor.convert(input, *OPTIONS))
1009
- xml.xpath("//*[local-name() = 'image']").each do |x|
1010
- x.replace("<image/>")
1011
- end
1012
- expect(xmlpp(strip_guid(xml.to_xml)
1013
- .gsub(%r{<style.*?</style>}m, "<style/>")))
1014
- .to be_equivalent_to xmlpp(output)
1015
- end
1016
-
1017
- it "removes paras with indexterms" do
1018
- input = <<~INPUT
1019
- #{ASCIIDOC_BLANK_HDR}
1020
-
1021
- == Clause 1
1022
-
1023
- Paragraph
1024
-
1025
- (((index)))
1026
-
1027
- [NOTE]
1028
- --
1029
-
1030
- (((index)))
1031
-
1032
- Note
1033
- --
1034
-
1035
- [NOTE]
1036
- --
1037
-
1038
- (((index)))
1039
-
1040
- --
1041
-
1042
- == Clause 2
1043
-
1044
- Paragraph
1045
-
1046
- ((index))
1047
-
1048
- INPUT
1049
-
1050
- output = <<~OUTPUT
1051
- #{BLANK_HDR}
1052
- <sections>
1053
- <clause id='_' inline-header='false' obligation='normative'>
1054
- <title>Clause 1</title>
1055
- <p id='_'>
1056
- Paragraph
1057
- <index>
1058
- <primary>index</primary>
1059
- </index>
1060
- </p>
1061
- <note id='_'>
1062
- <p id='_'>
1063
- <index>
1064
- <primary>index</primary>
1065
- </index>
1066
- Note
1067
- </p>
1068
- </note>
1069
- <note id='_'>
1070
- <p id='_'>
1071
- <index>
1072
- <primary>index</primary>
1073
- </index>
1074
- </p>
1075
- </note>
1076
- </clause>
1077
- <clause id='_' inline-header='false' obligation='normative'>
1078
- <title>Clause 2</title>
1079
- <p id='_'>Paragraph</p>
1080
- <p id='_'>
1081
- index
1082
- <index>
1083
- <primary>index</primary>
1084
- </index>
1085
- </p>
1086
- </clause>
1087
- </sections>
1088
- </standard-document>
1089
- OUTPUT
1090
- xml = Nokogiri::XML(Asciidoctor.convert(input, *OPTIONS))
1091
- xml.xpath("//*[local-name() = 'image']").each do |x|
1092
- x.replace("<image/>")
1093
- end
1094
- expect(xmlpp(strip_guid(xml.to_xml)
1095
- .gsub(%r{<style.*?</style>}m, "<style/>")))
1096
- .to be_equivalent_to xmlpp(output)
1097
- end
1098
-
1099
- end