metanorma-standoc 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/.gitattributes +4 -0
  3. data/.gitignore +11 -0
  4. data/.hound.yml +3 -0
  5. data/.oss-guides.rubocop.yml +1077 -0
  6. data/.rubocop.ribose.yml +66 -0
  7. data/.rubocop.tb.yml +650 -0
  8. data/.rubocop.yml +15 -0
  9. data/.travis.yml +21 -0
  10. data/CODE_OF_CONDUCT.md +46 -0
  11. data/Gemfile +7 -0
  12. data/LICENSE +25 -0
  13. data/Makefile +39 -0
  14. data/README.adoc +9 -0
  15. data/Rakefile +6 -0
  16. data/bin/rspec +18 -0
  17. data/docs/customisation.adoc +178 -0
  18. data/docs/guidance.adoc +436 -0
  19. data/docs/htmloutput.adoc +115 -0
  20. data/docs/quickstart.adoc +375 -0
  21. data/lib/asciidoctor/standoc/base.rb +198 -0
  22. data/lib/asciidoctor/standoc/biblio.rng +836 -0
  23. data/lib/asciidoctor/standoc/blocks.rb +190 -0
  24. data/lib/asciidoctor/standoc/cleanup.rb +247 -0
  25. data/lib/asciidoctor/standoc/cleanup_block.rb +193 -0
  26. data/lib/asciidoctor/standoc/cleanup_footnotes.rb +78 -0
  27. data/lib/asciidoctor/standoc/cleanup_ref.rb +125 -0
  28. data/lib/asciidoctor/standoc/converter.rb +55 -0
  29. data/lib/asciidoctor/standoc/front.rb +121 -0
  30. data/lib/asciidoctor/standoc/inline.rb +134 -0
  31. data/lib/asciidoctor/standoc/isodoc.rng +1059 -0
  32. data/lib/asciidoctor/standoc/lists.rb +87 -0
  33. data/lib/asciidoctor/standoc/macros.rb +95 -0
  34. data/lib/asciidoctor/standoc/ref.rb +187 -0
  35. data/lib/asciidoctor/standoc/section.rb +159 -0
  36. data/lib/asciidoctor/standoc/table.rb +61 -0
  37. data/lib/asciidoctor/standoc/utils.rb +121 -0
  38. data/lib/asciidoctor/standoc/validate.rb +65 -0
  39. data/lib/asciidoctor/standoc/validate_section.rb +42 -0
  40. data/lib/asciidoctor/standoc/version.rb +5 -0
  41. data/lib/metanorma-standoc.rb +9 -0
  42. data/lib/metanorma/standoc.rb +7 -0
  43. data/lib/metanorma/standoc/processor.rb +40 -0
  44. data/metanorma-standoc.gemspec +47 -0
  45. data/spec/asciidoctor-standoc/base_spec.rb +271 -0
  46. data/spec/asciidoctor-standoc/blocks_spec.rb +469 -0
  47. data/spec/asciidoctor-standoc/cleanup_spec.rb +760 -0
  48. data/spec/asciidoctor-standoc/inline_spec.rb +162 -0
  49. data/spec/asciidoctor-standoc/isobib_cache_spec.rb +332 -0
  50. data/spec/asciidoctor-standoc/lists_spec.rb +190 -0
  51. data/spec/asciidoctor-standoc/macros_spec.rb +111 -0
  52. data/spec/asciidoctor-standoc/refs_spec.rb +606 -0
  53. data/spec/asciidoctor-standoc/section_spec.rb +310 -0
  54. data/spec/asciidoctor-standoc/table_spec.rb +307 -0
  55. data/spec/asciidoctor-standoc/validate_spec.rb +133 -0
  56. data/spec/assets/header.html +7 -0
  57. data/spec/assets/html.css +2 -0
  58. data/spec/assets/htmlcover.html +4 -0
  59. data/spec/assets/htmlintro.html +5 -0
  60. data/spec/assets/i18n.yaml +2 -0
  61. data/spec/assets/iso.headless.html +33 -0
  62. data/spec/assets/iso.xml +8 -0
  63. data/spec/assets/rice_image1.png +0 -0
  64. data/spec/assets/scripts.html +3 -0
  65. data/spec/assets/std.css +2 -0
  66. data/spec/assets/word.css +2 -0
  67. data/spec/assets/wordcover.html +3 -0
  68. data/spec/assets/wordintro.html +4 -0
  69. data/spec/examples/103_01_02.html +247 -0
  70. data/spec/examples/english.yaml +69 -0
  71. data/spec/examples/iso_123_.xml +45 -0
  72. data/spec/examples/iso_123_all_parts.xml +45 -0
  73. data/spec/examples/iso_123_no_year_note.xml +46 -0
  74. data/spec/examples/iso_124_.xml +41 -0
  75. data/spec/examples/iso_216_.xml +47 -0
  76. data/spec/examples/iso_iec_12382_.xml +48 -0
  77. data/spec/examples/rice.adoc +715 -0
  78. data/spec/examples/rice.preview.html +1877 -0
  79. data/spec/examples/rice.sh +4 -0
  80. data/spec/examples/rice_images/rice_image1.png +0 -0
  81. data/spec/examples/rice_images/rice_image2.png +0 -0
  82. data/spec/examples/rice_images/rice_image3_1.png +0 -0
  83. data/spec/examples/rice_images/rice_image3_2.png +0 -0
  84. data/spec/examples/rice_images/rice_image3_3.png +0 -0
  85. data/spec/metanorma/processor_spec.rb +70 -0
  86. data/spec/spec_helper.rb +198 -0
  87. metadata +370 -0
@@ -0,0 +1,760 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Asciidoctor::Standoc do
4
+ it "removes empty text elements" do
5
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
6
+ #{ASCIIDOC_BLANK_HDR}
7
+ == {blank}
8
+ INPUT
9
+ #{BLANK_HDR}
10
+ <sections>
11
+ <clause id="_" inline-header="false" obligation="normative">
12
+
13
+ </clause>
14
+ </sections>
15
+ </standard-document>
16
+ OUTPUT
17
+ end
18
+
19
+ it "processes stem-only terms as admitted" do
20
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
21
+ #{ASCIIDOC_BLANK_HDR}
22
+ == Terms and Definitions
23
+
24
+ === stem:[t_90]
25
+
26
+ stem:[t_91]
27
+
28
+ Time
29
+ INPUT
30
+ #{BLANK_HDR}
31
+ <sections>
32
+ <terms id="_" obligation="normative">
33
+ <title>Terms and definitions</title>
34
+ <term id="_"><preferred><stem type="AsciiMath">t_90</stem></preferred><admitted><stem type="AsciiMath">t_91</stem></admitted>
35
+ <definition><p id="_">Time</p></definition></term>
36
+ </terms>
37
+ </sections>
38
+ </standard-document>
39
+ OUTPUT
40
+ end
41
+
42
+ it "moves term domains out of the term definition paragraph" do
43
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
44
+ #{ASCIIDOC_BLANK_HDR}
45
+ == Terms and Definitions
46
+
47
+ === Tempus
48
+
49
+ domain:[relativity] Time
50
+ INPUT
51
+ #{BLANK_HDR}
52
+ <sections>
53
+ <terms id="_" obligation="normative">
54
+ <title>Terms and definitions</title>
55
+ <term id="_">
56
+ <preferred>Tempus</preferred>
57
+ <domain>relativity</domain><definition><p id="_"> Time</p></definition>
58
+ </term>
59
+ </terms>
60
+ </sections>
61
+ </standard-document>
62
+ OUTPUT
63
+ end
64
+
65
+ it "permits multiple blocks in term definition paragraph" do
66
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
67
+ = Document title
68
+ Author
69
+ :docfile: test.adoc
70
+ :nodoc:
71
+ :novalid:
72
+ :stem:
73
+
74
+ == Terms and Definitions
75
+
76
+ === stem:[t_90]
77
+
78
+ [stem]
79
+ ++++
80
+ t_A
81
+ ++++
82
+
83
+ This paragraph is extraneous
84
+ INPUT
85
+ #{BLANK_HDR}
86
+ <sections>
87
+ <terms id="_" obligation="normative">
88
+ <title>Terms and definitions</title>
89
+ <term id="_"><preferred><stem type="AsciiMath">t_90</stem></preferred><definition><formula id="_">
90
+ <stem type="AsciiMath">t_A</stem>
91
+ </formula><p id="_">This paragraph is extraneous</p></definition>
92
+ </term>
93
+ </terms>
94
+ </sections>
95
+ </standard-document>
96
+ OUTPUT
97
+ end
98
+
99
+ it "strips any initial boilerplate from terms and definitions" do
100
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
101
+ #{ASCIIDOC_BLANK_HDR}
102
+ == Terms and Definitions
103
+
104
+ I am boilerplate
105
+
106
+ * So am I
107
+
108
+ === Time
109
+
110
+ This paragraph is extraneous
111
+ INPUT
112
+ #{BLANK_HDR}
113
+ <sections>
114
+ <terms id="_" obligation="normative"><title>Terms and definitions</title>
115
+
116
+ <term id="_">
117
+ <preferred>Time</preferred>
118
+ <definition><p id="_">This paragraph is extraneous</p></definition>
119
+ </term></terms>
120
+ </sections>
121
+ </standard-document>
122
+ OUTPUT
123
+ end
124
+
125
+ it "moves notes inside preceding blocks, if they are not at clause end, and the blocks are not delimited" do
126
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
127
+ #{ASCIIDOC_BLANK_HDR}
128
+ [stem]
129
+ ++++
130
+ r = 1 %
131
+ r = 1 %
132
+ ++++
133
+
134
+ NOTE: That formula does not do much
135
+
136
+ Indeed.
137
+ INPUT
138
+ #{BLANK_HDR}
139
+ <sections><formula id="_">
140
+ <stem type="AsciiMath">r = 1 %
141
+ r = 1 %</stem>
142
+ <note id="_">
143
+ <p id="_">That formula does not do much</p>
144
+ </note></formula>
145
+
146
+ <p id="_">Indeed.</p></sections>
147
+ </standard-document>
148
+ OUTPUT
149
+ end
150
+
151
+ it "does not move notes inside preceding blocks, if they are at clause end" do
152
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
153
+ #{ASCIIDOC_BLANK_HDR}
154
+ [source,ruby]
155
+ [1...x].each do |y|
156
+ puts y
157
+ end
158
+
159
+ NOTE: That loop does not do much
160
+ INPUT
161
+ #{BLANK_HDR}
162
+ <sections><sourcecode id="_">[1...x].each do |y|
163
+ puts y
164
+ end</sourcecode>
165
+ <note id="_">
166
+ <p id="_">That loop does not do much</p>
167
+ </note></sections>
168
+ </standard-document>
169
+ OUTPUT
170
+ end
171
+
172
+ it "converts xrefs to references into erefs" do
173
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
174
+ #{ASCIIDOC_BLANK_HDR}
175
+ <<iso216>>
176
+
177
+ [bibliography]
178
+ == Normative References
179
+ * [[[iso216,ISO 216:2001]]], _Reference_
180
+ INPUT
181
+ #{BLANK_HDR}
182
+ <preface><foreword obligation="informative">
183
+ <title>Foreword</title>
184
+ <p id="_">
185
+ <eref type="inline" bibitemid="iso216" citeas="ISO 216:2001"/>
186
+ </p>
187
+ </foreword></preface><sections>
188
+ </sections><bibliography><references id="_" obligation="informative">
189
+ <title>Normative References</title>
190
+ <bibitem id="iso216" type="standard">
191
+ <title format="text/plain">Reference</title>
192
+ <docidentifier>ISO 216</docidentifier>
193
+ <date type="published">
194
+ <on>2001</on>
195
+ </date>
196
+ <contributor>
197
+ <role type="publisher"/>
198
+ <organization>
199
+ <name>ISO</name>
200
+ </organization>
201
+ </contributor>
202
+ </bibitem>
203
+ </references>
204
+ </bibliography
205
+ </standard-document>
206
+ OUTPUT
207
+ end
208
+
209
+ it "extracts localities from erefs" do
210
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
211
+ #{ASCIIDOC_BLANK_HDR}
212
+ <<iso216,whole,clause=3,example=9-11,locality:prelude=33,locality:entirety:the reference>>
213
+
214
+ [bibliography]
215
+ == Normative References
216
+ * [[[iso216,ISO 216]]], _Reference_
217
+ INPUT
218
+ #{BLANK_HDR}
219
+ <preface><foreword obligation="informative">
220
+ <title>Foreword</title>
221
+ <p id="_">
222
+ <eref type="inline" bibitemid="iso216" citeas="ISO 216"><locality type="whole"/><locality type="clause"><referenceFrom>3</referenceFrom></locality><locality type="example"><referenceFrom>9</referenceFrom><referenceTo>11</referenceTo></locality><locality type="locality:prelude"><referenceFrom>33</referenceFrom></locality><locality type="locality:entirety"/>the reference</eref>
223
+ </p>
224
+ </foreword></preface><sections>
225
+ </sections><bibliography><references id="_" obligation="informative">
226
+ <title>Normative References</title>
227
+ <bibitem id="iso216" type="standard">
228
+ <title format="text/plain">Reference</title>
229
+ <docidentifier>ISO 216</docidentifier>
230
+ <contributor>
231
+ <role type="publisher"/>
232
+ <organization>
233
+ <name>ISO</name>
234
+ </organization>
235
+ </contributor>
236
+ </bibitem>
237
+ </references>
238
+ </bibliography>
239
+ </standard-document>
240
+ OUTPUT
241
+ end
242
+
243
+
244
+ it "strips type from xrefs" do
245
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
246
+ #{ASCIIDOC_BLANK_HDR}
247
+ <<iso216>>
248
+
249
+ [bibliography]
250
+ == Clause
251
+ * [[[iso216,ISO 216]]], _Reference_
252
+ INPUT
253
+ #{BLANK_HDR}
254
+ <preface>
255
+ <foreword obligation="informative">
256
+ <title>Foreword</title>
257
+ <p id="_">
258
+ <eref type="inline" bibitemid="iso216" citeas="ISO 216"/>
259
+ </p>
260
+ </foreword></preface><sections>
261
+ </sections><bibliography><references id="_" obligation="informative">
262
+ <title>Bibliography</title>
263
+ <bibitem id="iso216" type="standard">
264
+ <title format="text/plain">Reference</title>
265
+ <docidentifier>ISO 216</docidentifier>
266
+ <contributor>
267
+ <role type="publisher"/>
268
+ <organization>
269
+ <name>ISO</name>
270
+ </organization>
271
+ </contributor>
272
+ </bibitem>
273
+ </references></bibliography>
274
+ </standard-document>
275
+ OUTPUT
276
+ end
277
+
278
+ it "processes localities in term sources" do
279
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
280
+ #{ASCIIDOC_BLANK_HDR}
281
+ == Terms and Definitions
282
+
283
+ === Term1
284
+
285
+ [.source]
286
+ <<ISO2191,section=1>>
287
+ INPUT
288
+ #{BLANK_HDR}
289
+ <sections>
290
+ <terms id="_" obligation="normative">
291
+ <title>Terms and definitions</title>
292
+ <term id="_">
293
+ <preferred>Term1</preferred>
294
+ <termsource status="identical">
295
+ <origin bibitemid="ISO2191" type="inline" citeas=""><locality type="section"><referenceFrom>1</referenceFrom></locality></origin>
296
+ </termsource>
297
+ </term>
298
+ </terms>
299
+ </sections>
300
+ </standard-document>
301
+ OUTPUT
302
+ end
303
+
304
+ it "removes extraneous material from Normative References" do
305
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
306
+ #{ASCIIDOC_BLANK_HDR}
307
+ [bibliography]
308
+ == Normative References
309
+
310
+ This is extraneous information
311
+
312
+ * [[[iso216,ISO 216]]], _Reference_
313
+ INPUT
314
+ #{BLANK_HDR}
315
+ <sections></sections>
316
+ <bibliography><references id="_" obligation="informative"><title>Normative References</title>
317
+ <bibitem id="iso216" type="standard">
318
+ <title format="text/plain">Reference</title>
319
+ <docidentifier>ISO 216</docidentifier>
320
+ <contributor>
321
+ <role type="publisher"/>
322
+ <organization>
323
+ <name>ISO</name>
324
+ </organization>
325
+ </contributor>
326
+ </bibitem>
327
+ </references>
328
+ </bibliography>
329
+ </standard-document>
330
+ OUTPUT
331
+ end
332
+
333
+ it "inserts IDs into paragraphs" do
334
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
335
+ #{ASCIIDOC_BLANK_HDR}
336
+ Paragraph
337
+ INPUT
338
+ #{BLANK_HDR}
339
+ <sections>
340
+ <p id="_">Paragraph</p>
341
+ </sections>
342
+ </standard-document>
343
+ OUTPUT
344
+ end
345
+
346
+ it "inserts IDs into notes" do
347
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
348
+ #{ASCIIDOC_BLANK_HDR}
349
+ [example]
350
+ ====
351
+ NOTE: This note has no ID
352
+ ====
353
+ INPUT
354
+ #{BLANK_HDR}
355
+ <sections>
356
+ <example id="_">
357
+ <note id="_">
358
+ <p id="_">This note has no ID</p>
359
+ </note>
360
+ </example>
361
+ </sections>
362
+ </standard-document>
363
+ OUTPUT
364
+ end
365
+
366
+ it "moves table key inside table" do
367
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
368
+ #{ASCIIDOC_BLANK_HDR}
369
+ |===
370
+ |a |b |c
371
+ |===
372
+
373
+ Key
374
+
375
+ a:: b
376
+ INPUT
377
+ #{BLANK_HDR}
378
+ <sections><table id="_">
379
+ <tbody>
380
+ <tr>
381
+ <td align="left">a</td>
382
+ <td align="left">b</td>
383
+ <td align="left">c</td>
384
+ </tr>
385
+ </tbody>
386
+ <dl id="_">
387
+ <dt>a</dt>
388
+ <dd>
389
+ <p id="_">b</p>
390
+ </dd>
391
+ </dl></table>
392
+
393
+ </sections>
394
+ </standard-document>
395
+ OUTPUT
396
+ end
397
+
398
+ it "processes headerrows attribute for table without header rows" do
399
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
400
+ #{ASCIIDOC_BLANK_HDR}
401
+ [headerrows=3]
402
+ |===
403
+ |a |b |c
404
+ |a |b |c
405
+ |a |b |c
406
+ |a |b |c
407
+ |===
408
+ INPUT
409
+ #{BLANK_HDR}
410
+ <sections>
411
+ <table id="_"><thead><tr>
412
+ <td align="left">a</td>
413
+ <td align="left">b</td>
414
+ <td align="left">c</td>
415
+ </tr><tr>
416
+ <td align="left">a</td>
417
+ <td align="left">b</td>
418
+ <td align="left">c</td>
419
+ </tr><tr>
420
+ <td align="left">a</td>
421
+ <td align="left">b</td>
422
+ <td align="left">c</td>
423
+ </tr></thead>
424
+ <tbody>
425
+ <tr>
426
+ <td align="left">a</td>
427
+ <td align="left">b</td>
428
+ <td align="left">c</td>
429
+ </tr>
430
+ </tbody>
431
+ </table>
432
+ </sections>
433
+ </standard-document>
434
+ OUTPUT
435
+ end
436
+
437
+ it "processes headerrows attribute for table with header rows" do
438
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
439
+ #{ASCIIDOC_BLANK_HDR}
440
+ [headerrows=3]
441
+ |===
442
+ |a |b |c
443
+
444
+ |a |b |c
445
+ |a |b |c
446
+ |a |b |c
447
+ |===
448
+ INPUT
449
+ #{BLANK_HDR}
450
+ <sections>
451
+ <table id="_">
452
+ <thead>
453
+ <tr>
454
+ <th align="left">a</th>
455
+ <th align="left">b</th>
456
+ <th align="left">c</th>
457
+ </tr>
458
+ <tr>
459
+ <td align="left">a</td>
460
+ <td align="left">b</td>
461
+ <td align="left">c</td>
462
+ </tr><tr>
463
+ <td align="left">a</td>
464
+ <td align="left">b</td>
465
+ <td align="left">c</td>
466
+ </tr></thead>
467
+ <tbody>
468
+
469
+
470
+ <tr>
471
+ <td align="left">a</td>
472
+ <td align="left">b</td>
473
+ <td align="left">c</td>
474
+ </tr>
475
+ </tbody>
476
+ </table>
477
+ </sections>
478
+ </standard-document>
479
+ OUTPUT
480
+ end
481
+
482
+ it "moves table notes inside table" do
483
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
484
+ #{ASCIIDOC_BLANK_HDR}
485
+ |===
486
+ |a |b |c
487
+ |===
488
+
489
+ NOTE: Note 1
490
+
491
+ NOTE: Note 2
492
+ INPUT
493
+ #{BLANK_HDR}
494
+ <sections><table id="_">
495
+ <tbody>
496
+ <tr>
497
+ <td align="left">a</td>
498
+ <td align="left">b</td>
499
+ <td align="left">c</td>
500
+ </tr>
501
+ </tbody>
502
+ <note id="_">
503
+ <p id="_">Note 1</p>
504
+ </note><note id="_">
505
+ <p id="_">Note 2</p>
506
+ </note></table>
507
+
508
+ </sections>
509
+ OUTPUT
510
+ end
511
+
512
+ it "moves formula key inside formula" do
513
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
514
+ #{ASCIIDOC_BLANK_HDR}
515
+ [stem]
516
+ ++++
517
+ Formula
518
+ ++++
519
+
520
+ where
521
+
522
+ a:: b
523
+ INPUT
524
+ #{BLANK_HDR}
525
+ <sections><formula id="_">
526
+ <stem type="AsciiMath">Formula</stem>
527
+ <dl id="_">
528
+ <dt>a</dt>
529
+ <dd>
530
+ <p id="_">b</p>
531
+ </dd>
532
+ </dl></formula>
533
+
534
+ </sections>
535
+ </standard-document>
536
+ OUTPUT
537
+ end
538
+
539
+ it "moves footnotes inside figures" do
540
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
541
+ #{ASCIIDOC_BLANK_HDR}
542
+ image::spec/examples/rice_images/rice_image1.png[]
543
+
544
+ footnote:[This is a footnote to a figure]
545
+
546
+ footnote:[This is another footnote to a figure]
547
+ INPUT
548
+ #{BLANK_HDR}
549
+ <sections><figure id="_">
550
+ <image src="spec/examples/rice_images/rice_image1.png" id="_" imagetype="PNG" height="auto" width="auto"/>
551
+ <fn reference="a">
552
+ <p id="_">This is a footnote to a figure</p>
553
+ </fn><fn reference="b">
554
+ <p id="_">This is another footnote to a figure</p>
555
+ </fn></figure>
556
+
557
+ </sections>
558
+
559
+ </standard-document>
560
+ OUTPUT
561
+ end
562
+
563
+ it "moves figure key inside figure" do
564
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
565
+ #{ASCIIDOC_BLANK_HDR}
566
+ image::spec/examples/rice_images/rice_image1.png[]
567
+
568
+ Key
569
+
570
+ a:: b
571
+ INPUT
572
+ #{BLANK_HDR}
573
+ <sections><figure id="_">
574
+ <image src="spec/examples/rice_images/rice_image1.png" id="_" imagetype="PNG" height="auto" width="auto"/>
575
+ <dl id="_">
576
+ <dt>a</dt>
577
+ <dd>
578
+ <p id="_">b</p>
579
+ </dd>
580
+ </dl></figure>
581
+
582
+ </sections>
583
+
584
+ </standard-document>
585
+ OUTPUT
586
+ end
587
+
588
+ it "processes subfigures" do
589
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
590
+ #{ASCIIDOC_BLANK_HDR}
591
+ [[figureC-2]]
592
+ .Stages of gelatinization
593
+ ====
594
+ .Initial stages: No grains are fully gelatinized (ungelatinized starch granules are visible inside the kernels)
595
+ image::spec/examples/rice_images/rice_image3_1.png[]
596
+
597
+ .Intermediate stages: Some fully gelatinized kernels are visible
598
+ image::spec/examples/rice_images/rice_image3_2.png[]
599
+
600
+ .Final stages: All kernels are fully gelatinized
601
+ image::spec/examples/rice_images/rice_image3_3.png[]
602
+ ====
603
+ INPUT
604
+ #{BLANK_HDR}
605
+ <sections>
606
+ <figure id="figureC-2"><figure id="_">
607
+ <name>Initial stages: No grains are fully gelatinized (ungelatinized starch granules are visible inside the kernels)</name>
608
+ <image src="spec/examples/rice_images/rice_image3_1.png" id="_" imagetype="PNG" height="auto" width="auto"/>
609
+ </figure>
610
+ <figure id="_">
611
+ <name>Intermediate stages: Some fully gelatinized kernels are visible</name>
612
+ <image src="spec/examples/rice_images/rice_image3_2.png" id="_" imagetype="PNG" height="auto" width="auto"/>
613
+ </figure>
614
+ <figure id="_">
615
+ <name>Final stages: All kernels are fully gelatinized</name>
616
+ <image src="spec/examples/rice_images/rice_image3_3.png" id="_" imagetype="PNG" height="auto" width="auto"/>
617
+ </figure></figure>
618
+ </sections>
619
+ </standard-document>
620
+ OUTPUT
621
+ end
622
+
623
+ it "numbers bibliographic notes and footnotes sequentially" do
624
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
625
+ #{ASCIIDOC_BLANK_HDR}
626
+ footnote:[Footnote]
627
+
628
+ [bibliography]
629
+ == Normative References
630
+
631
+ * [[[iso123,ISO 123:--]]] footnote:[The standard is in press] _Standard_
632
+
633
+ == Clause
634
+ footnote:[Footnote2]
635
+ INPUT
636
+ #{BLANK_HDR}
637
+ <preface><foreword obligation="informative">
638
+ <title>Foreword</title>
639
+ <p id="_"><fn reference="1">
640
+ <p id="_">Footnote</p>
641
+ </fn>
642
+ </p>
643
+ </foreword></preface><sections>
644
+
645
+ <clause id="_" inline-header="false" obligation="normative">
646
+ <title>Clause</title>
647
+ <p id="_"><fn reference="2">
648
+ <p id="_">Footnote2</p>
649
+ </fn>
650
+ </p>
651
+ </clause></sections><bibliography><references id="_" obligation="informative">
652
+ <title>Normative References</title>
653
+ <bibitem id="iso123" type="standard">
654
+ <title format="text/plain">Standard</title>
655
+ <docidentifier>ISO 123</docidentifier>
656
+ <date type="published">
657
+ <on>--</on>
658
+ </date>
659
+ <contributor>
660
+ <role type="publisher"/>
661
+ <organization>
662
+ <name>ISO</name>
663
+ </organization>
664
+ </contributor>
665
+ <note format="text/plain">ISO DATE: The standard is in press</note>
666
+ </bibitem>
667
+ </references>
668
+ </bibliography>
669
+ </standard-document>
670
+ OUTPUT
671
+ end
672
+
673
+ it "defaults section obligations" do
674
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
675
+ #{ASCIIDOC_BLANK_HDR}
676
+
677
+ == Clause
678
+ Text
679
+
680
+ [appendix]
681
+ == Clause
682
+
683
+ Text
684
+ INPUT
685
+ #{BLANK_HDR}
686
+ <sections><clause id="_" inline-header="false" obligation="normative">
687
+ <title>Clause</title>
688
+ <p id="_">Text</p>
689
+ </clause>
690
+ </sections><annex id="_" inline-header="false" obligation="normative">
691
+ <title>Clause</title>
692
+ <p id="_">Text</p>
693
+ </annex>
694
+ </standard-document>
695
+ OUTPUT
696
+ end
697
+
698
+ it "extends clause levels past 5" do
699
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
700
+ #{ASCIIDOC_BLANK_HDR}
701
+
702
+ == Clause1
703
+
704
+ === Clause2
705
+
706
+ ==== Clause3
707
+
708
+ ===== Clause4
709
+
710
+ ====== Clause 5
711
+
712
+ [level=6]
713
+ ====== Clause 6
714
+
715
+ [level=7]
716
+ ====== Clause 7A
717
+
718
+ [level=7]
719
+ ====== Clause 7B
720
+
721
+ [level=6]
722
+ ====== Clause 6B
723
+
724
+ ====== Clause 5B
725
+
726
+ INPUT
727
+ #{BLANK_HDR}
728
+ <sections>
729
+ <clause id="_" inline-header="false" obligation="normative">
730
+ <title>Clause1</title>
731
+ <clause id="_" inline-header="false" obligation="normative">
732
+ <title>Clause2</title>
733
+ <clause id="_" inline-header="false" obligation="normative">
734
+ <title>Clause3</title>
735
+ <clause id="_" inline-header="false" obligation="normative"><title>Clause4</title><clause id="_" inline-header="false" obligation="normative">
736
+ <title>Clause 5</title>
737
+ <clause id="_" inline-header="false" obligation="normative">
738
+ <title>Clause 6</title>
739
+ <clause id="_" inline-header="false" obligation="normative">
740
+ <title>Clause 7A</title>
741
+ </clause><clause id="_" inline-header="false" obligation="normative">
742
+ <title>Clause 7B</title>
743
+ </clause></clause><clause id="_" inline-header="false" obligation="normative">
744
+ <title>Clause 6B</title>
745
+ </clause></clause>
746
+
747
+
748
+
749
+
750
+ <clause id="_" inline-header="false" obligation="normative">
751
+ <title>Clause 5B</title>
752
+ </clause></clause>
753
+ </clause>
754
+ </clause>
755
+ </clause>
756
+ </sections>
757
+ </standard-document>
758
+ OUTPUT
759
+ end
760
+ end