metanorma-standoc 1.5.1 → 1.6.2

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 (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
@@ -0,0 +1,781 @@
1
+ RSpec.shared_examples "structured data 2 text preprocessor" do
2
+ describe "#process" do
3
+ let(:example_file) { "example.#{extention}" }
4
+
5
+ before do
6
+ File.open(example_file, "w") do |n|
7
+ n.puts(transform_to_type(example_content))
8
+ end
9
+ end
10
+
11
+ after do
12
+ FileUtils.rm_rf(example_file)
13
+ end
14
+
15
+ context "Array of hashes" do
16
+ let(:example_content) do
17
+ [{ "name" => "spaghetti",
18
+ "desc" => "wheat noodles of 9mm diameter",
19
+ "symbol" => "SPAG",
20
+ "symbol_def" =>
21
+ "the situation is message like spaghetti at a kid's meal" }]
22
+ end
23
+ let(:input) do
24
+ <<~TEXT
25
+ = Document title
26
+ Author
27
+ :docfile: test.adoc
28
+ :nodoc:
29
+ :novalid:
30
+ :no-isobib:
31
+ :imagesdir: spec/assets
32
+
33
+ [#{extention}2text,#{example_file},my_context]
34
+ ----
35
+ {my_context.*,item,EOF}
36
+ {item.name}:: {item.desc}
37
+ {EOF}
38
+ ----
39
+ TEXT
40
+ end
41
+ let(:output) do
42
+ <<~TEXT
43
+ #{BLANK_HDR}
44
+ <sections>
45
+ <dl id='_'>
46
+ <dt>spaghetti</dt>
47
+ <dd>
48
+ <p id='_'>wheat noodles of 9mm diameter</p>
49
+ </dd>
50
+ </dl>
51
+ </sections>
52
+ </standard-document>
53
+ TEXT
54
+ end
55
+
56
+ it "correctly renders input" do
57
+ expect(
58
+ xmlpp(
59
+ strip_guid(
60
+ Asciidoctor.convert(input,
61
+ backend: :standoc,
62
+ header_footer: true)
63
+ )
64
+ )
65
+ ).to(be_equivalent_to(xmlpp(output)))
66
+ end
67
+ end
68
+
69
+ context "An array of strings" do
70
+ let(:example_content) do
71
+ ["lorem", "ipsum", "dolor"]
72
+ end
73
+ let(:input) do
74
+ <<~TEXT
75
+ = Document title
76
+ Author
77
+ :docfile: test.adoc
78
+ :nodoc:
79
+ :novalid:
80
+ :no-isobib:
81
+ :imagesdir: spec/assets
82
+
83
+ [#{extention}2text,#{example_file},ar]
84
+ ----
85
+ {ar.*,s,EOS}
86
+ === {s.#} {s}
87
+
88
+ This section is about {s}.
89
+
90
+ {EOS}
91
+ ----
92
+ TEXT
93
+ end
94
+ let(:output) do
95
+ <<~TEXT
96
+ #{BLANK_HDR}
97
+ <sections>
98
+ <clause id="_" inline-header="false" obligation="normative">
99
+ <title>0 lorem</title>
100
+ <p id='_'>This section is about lorem.</p>
101
+ </clause>
102
+ <clause id='_' inline-header='false' obligation='normative'>
103
+ <title>1 ipsum</title>
104
+ <p id='_'>This section is about ipsum.</p>
105
+ </clause>
106
+ <clause id='_' inline-header='false' obligation='normative'>
107
+ <title>2 dolor</title>
108
+ <p id='_'>This section is about dolor.</p>
109
+ </clause>
110
+ </sections>
111
+ </standard-document>
112
+ TEXT
113
+ end
114
+
115
+ it "correctly renders input" do
116
+ expect(
117
+ xmlpp(
118
+ strip_guid(
119
+ Asciidoctor.convert(input,
120
+ backend: :standoc,
121
+ header_footer: true)
122
+ )
123
+ )
124
+ ).to(be_equivalent_to(xmlpp(output)))
125
+ end
126
+ end
127
+
128
+ context "A simple hash" do
129
+ let(:example_content) do
130
+ { "name" => "Lorem ipsum", "desc" => "dolor sit amet" }
131
+ end
132
+ let(:input) do
133
+ <<~TEXT
134
+ = Document title
135
+ Author
136
+ :docfile: test.adoc
137
+ :nodoc:
138
+ :novalid:
139
+ :no-isobib:
140
+ :imagesdir: spec/assets
141
+
142
+ [#{extention}2text,#{example_file},my_item]
143
+ ----
144
+ === {my_item.name}
145
+
146
+ {my_item.desc}
147
+ ----
148
+ TEXT
149
+ end
150
+ let(:output) do
151
+ <<~TEXT
152
+ #{BLANK_HDR}
153
+ <sections>
154
+ <clause id="_" inline-header="false" obligation="normative">
155
+ <title>Lorem ipsum</title>
156
+ <p id='_'>dolor sit amet</p>
157
+ </clause>
158
+ </sections>
159
+ </standard-document>
160
+ TEXT
161
+ end
162
+
163
+ it "correctly renders input" do
164
+ expect(
165
+ xmlpp(
166
+ strip_guid(
167
+ Asciidoctor.convert(input,
168
+ backend: :standoc,
169
+ header_footer: true)
170
+ )
171
+ )
172
+ ).to(be_equivalent_to(xmlpp(output)))
173
+ end
174
+ end
175
+
176
+ context "A simple hash with free keys" do
177
+ let(:example_content) do
178
+ { "name" => "Lorem ipsum", "desc" => "dolor sit amet" }
179
+ end
180
+ let(:input) do
181
+ <<~TEXT
182
+ = Document title
183
+ Author
184
+ :docfile: test.adoc
185
+ :nodoc:
186
+ :novalid:
187
+ :no-isobib:
188
+ :imagesdir: spec/assets
189
+
190
+ [#{extention}2text,#{example_file},my_item]
191
+ ----
192
+ {my_item.*,key,EOI}
193
+ === {key}
194
+
195
+ {my_item[key]}
196
+
197
+ {EOI}
198
+ ----
199
+ TEXT
200
+ end
201
+ let(:output) do
202
+ <<~TEXT
203
+ #{BLANK_HDR}
204
+ <sections>
205
+ <clause id="_" inline-header="false" obligation="normative">
206
+ <title>name</title>
207
+ <p id='_'>Lorem ipsum</p>
208
+ </clause>
209
+ <clause id='_' inline-header='false' obligation='normative'>
210
+ <title>desc</title>
211
+ <p id='_'>dolor sit amet</p>
212
+ </clause>
213
+ </sections>
214
+ </standard-document>
215
+ TEXT
216
+ end
217
+
218
+ it "correctly renders input" do
219
+ expect(
220
+ xmlpp(
221
+ strip_guid(
222
+ Asciidoctor.convert(input,
223
+ backend: :standoc,
224
+ header_footer: true)
225
+ )
226
+ )
227
+ ).to(be_equivalent_to(xmlpp(output)))
228
+ end
229
+ end
230
+
231
+ context "An array of hashes" do
232
+ let(:example_content) do
233
+ [{ "name" => "Lorem", "desc" => "ipsum", "nums" => [2] },
234
+ { "name" => "dolor", "desc" => "sit", "nums" => [] },
235
+ { "name" => "amet", "desc" => "lorem", "nums" => [2, 4, 6] }]
236
+ end
237
+ let(:input) do
238
+ <<~TEXT
239
+ = Document title
240
+ Author
241
+ :docfile: test.adoc
242
+ :nodoc:
243
+ :novalid:
244
+ :no-isobib:
245
+ :imagesdir: spec/assets
246
+
247
+ [#{extention}2text,#{example_file},ar]
248
+ ----
249
+ {ar.*,item,EOF}
250
+
251
+ {item.name}:: {item.desc}
252
+
253
+ {item.nums.*,num,EON}
254
+ - {item.name}: {num}
255
+ {EON}
256
+
257
+ {EOF}
258
+ ----
259
+ TEXT
260
+ end
261
+ let(:output) do
262
+ <<~TEXT
263
+ #{BLANK_HDR}
264
+ <sections>
265
+ <dl id='_'>
266
+ <dt>Lorem</dt>
267
+ <dd>
268
+ <p id='_'>ipsum</p>
269
+ <ul id='_'>
270
+ <li>
271
+ <p id='_'>Lorem: 2</p>
272
+ </li>
273
+ </ul>
274
+ </dd>
275
+ <dt>dolor</dt>
276
+ <dd>
277
+ <p id='_'>sit</p>
278
+ </dd>
279
+ <dt>amet</dt>
280
+ <dd>
281
+ <p id='_'>lorem</p>
282
+ <ul id='_'>
283
+ <li>
284
+ <p id='_'>amet: 2</p>
285
+ </li>
286
+ <li>
287
+ <p id='_'>amet: 4</p>
288
+ </li>
289
+ <li>
290
+ <p id='_'>amet: 6</p>
291
+ </li>
292
+ </ul>
293
+ </dd>
294
+ </dl>
295
+ </sections>
296
+ </standard-document>
297
+ TEXT
298
+ end
299
+
300
+ it "correctly renders input" do
301
+ expect(
302
+ xmlpp(
303
+ strip_guid(
304
+ Asciidoctor.convert(input,
305
+ backend: :standoc,
306
+ header_footer: true)
307
+ )
308
+ )
309
+ ).to(be_equivalent_to(xmlpp(output)))
310
+ end
311
+ end
312
+
313
+ context "An array with interpolated file names, etc. \
314
+ for Asciidoc's consumption" do
315
+ let(:example_content) do
316
+ { "prefix" => "doc-", "items" => ["lorem", "ipsum", "dolor"] }
317
+ end
318
+ let(:input) do
319
+ <<~TEXT
320
+ = Document title
321
+ Author
322
+ :docfile: test.adoc
323
+ :nodoc:
324
+ :novalid:
325
+ :no-isobib:
326
+ :imagesdir: spec/assets
327
+
328
+ [#{extention}2text,#{example_file},#{extention}]
329
+ ------
330
+ First item is {#{extention}.items[0]}.
331
+ Last item is {#{extention}.items[-1]}.
332
+
333
+ {#{extention}.items.*,s,EOS}
334
+ === {s.#} -> {s.# + 1} {s} == {#{extention}.items[s.#]}
335
+
336
+ [source,ruby]
337
+ ----
338
+ include::{#{extention}.prefix}{s.#}.rb[]
339
+ ----
340
+
341
+ {EOS}
342
+ ------
343
+ TEXT
344
+ end
345
+ let(:output) do
346
+ <<~TEXT
347
+ #{BLANK_HDR}
348
+ <preface>
349
+ <foreword id='_' obligation='informative'>
350
+ <title>Foreword</title>
351
+ <p id='_'>First item is lorem. Last item is dolor.</p>
352
+ </foreword>
353
+ </preface>
354
+ <sections>
355
+ <clause id='_' inline-header='false' obligation='normative'>
356
+ <title>0 → 1 lorem == lorem</title>
357
+ <sourcecode lang='ruby' id='_'>link:doc-0.rb[]</sourcecode>
358
+ </clause>
359
+ <clause id='_' inline-header='false' obligation='normative'>
360
+ <title>1 → 2 ipsum == ipsum</title>
361
+ <sourcecode lang='ruby' id='_'>link:doc-1.rb[]</sourcecode>
362
+ </clause>
363
+ <clause id='_' inline-header='false' obligation='normative'>
364
+ <title>2 → 3 dolor == dolor</title>
365
+ <sourcecode lang='ruby' id='_'>link:doc-2.rb[]</sourcecode>
366
+ </clause>
367
+ </sections>
368
+ </standard-document>
369
+ TEXT
370
+ end
371
+
372
+ it "correctly renders input" do
373
+ expect(
374
+ xmlpp(
375
+ strip_guid(
376
+ Asciidoctor.convert(input,
377
+ backend: :standoc,
378
+ header_footer: true)
379
+ )
380
+ )
381
+ ).to(be_equivalent_to(xmlpp(output)))
382
+ end
383
+ end
384
+
385
+ context "Array of language codes" do
386
+ let(:example_content) do
387
+ YAML.safe_load(
388
+ File.read(File.expand_path("../../assets/codes.yml", __dir__))
389
+ )
390
+ end
391
+ let(:input) do
392
+ <<~TEXT
393
+ = Document title
394
+ Author
395
+ :docfile: test.adoc
396
+ :nodoc:
397
+ :novalid:
398
+ :no-isobib:
399
+ :imagesdir: spec/assets
400
+
401
+ [#{extention}2text,#{example_file},ar]
402
+ ----
403
+ {ar.*,item,EOF}
404
+ .{item.values[1]}
405
+ [%noheader,cols="h,1"]
406
+ |===
407
+ {item.*,key,EOK}
408
+ | {key} | {item[key]}
409
+
410
+ {EOK}
411
+ |===
412
+ {EOF}
413
+ ----
414
+ TEXT
415
+ end
416
+ let(:output) do
417
+ <<~TEXT
418
+ #{BLANK_HDR}
419
+ <sections>
420
+ #{File.read(File.expand_path('../../examples/codes_table.html', __dir__))}
421
+ </sections>
422
+ </standard-document>
423
+ TEXT
424
+ end
425
+
426
+ it "correctly renders input" do
427
+ expect(
428
+ xmlpp(
429
+ strip_guid(
430
+ Asciidoctor.convert(input,
431
+ backend: :standoc,
432
+ header_footer: true)
433
+ )
434
+ )
435
+ ).to(be_equivalent_to(xmlpp(output)))
436
+ end
437
+ end
438
+
439
+ context "Nested hash dot notation" do
440
+ let(:example_content) do
441
+ { "data" =>
442
+ { "acadsin-zho-hani-latn-2002" =>
443
+ { "code" => "acadsin-zho-hani-latn-2002",
444
+ "name" => {
445
+ "en" => "Academica Sinica -- Chinese Tongyong Pinyin (2002)",
446
+ },
447
+ "authority" => "acadsin",
448
+ "lang" => { "system" => "iso-639-2", "code" => "zho" },
449
+ "source_script" => "Hani",
450
+ "target_script" => "Latn",
451
+ "system" =>
452
+ { "id" => "2002",
453
+ "specification" =>
454
+ "Academica Sinica -- Chinese Tongyong Pinyin (2002)" },
455
+ "notes" =>
456
+ "NOTE: OGC 11-122r1 code `zho_Hani2Latn_AcadSin_2002`" } } }
457
+ end
458
+ let(:input) do
459
+ <<~TEXT
460
+ = Document title
461
+ Author
462
+ :docfile: test.adoc
463
+ :nodoc:
464
+ :novalid:
465
+ :no-isobib:
466
+ :imagesdir: spec/assets
467
+
468
+ [#{extention}2text,#{example_file},authorities]
469
+ ----
470
+ [cols="a,a,a,a",options="header"]
471
+ |===
472
+ | Script conversion system authority code | Name in English | Notes | Name en
473
+
474
+ {authorities.data.*,key,EOI}
475
+ | {key} | {authorities.data[key]['code']} | {authorities.data[key]['notes']} | {authorities.data[key].name.en}
476
+ {EOI}
477
+
478
+ |===
479
+ ----
480
+ TEXT
481
+ end
482
+ let(:output) do
483
+ <<~TEXT
484
+ #{BLANK_HDR}
485
+ <sections>
486
+ <table id='_'>
487
+ <thead>
488
+ <tr>
489
+ <th valign="top" align='left'>Script conversion system authority code</th>
490
+ <th valign="top" align='left'>Name in English</th>
491
+ <th valign="top" align='left'>Notes</th>
492
+ <th valign="top" align='left'>Name en</th>
493
+ </tr>
494
+ </thead>
495
+ <tbody>
496
+ <tr>
497
+ <td valign="top" align='left'>
498
+ <p id='_'>acadsin-zho-hani-latn-2002</p>
499
+ </td>
500
+ <td valign="top" align='left'>
501
+ <p id='_'>acadsin-zho-hani-latn-2002</p>
502
+ </td>
503
+ <td valign="top" align='left'>
504
+ <note id='_'>
505
+ <p id='_'>
506
+ OGC 11-122r1 code
507
+ <tt>zho_Hani2Latn_AcadSin_2002</tt>
508
+ </p>
509
+ </note>
510
+ </td>
511
+ <td valign="top" align='left'>
512
+ <p id='_'>Academica Sinica — Chinese Tongyong Pinyin (2002)</p>
513
+ </td>
514
+ </tr>
515
+ </tbody>
516
+ </table>
517
+ </sections>
518
+ </standard-document>
519
+ TEXT
520
+ end
521
+
522
+ it "correctly renders input" do
523
+ expect(
524
+ xmlpp(
525
+ strip_guid(
526
+ Asciidoctor.convert(input,
527
+ backend: :standoc,
528
+ header_footer: true)
529
+ )
530
+ )
531
+ ).to(be_equivalent_to(xmlpp(output)))
532
+ end
533
+ end
534
+
535
+ context "Liquid code snippets" do
536
+ let(:example_content) do
537
+ [{ "name" => "One", "show" => true },
538
+ { "name" => "Two", "show" => true },
539
+ { "name" => "Three", "show" => false }]
540
+ end
541
+ let(:input) do
542
+ <<~TEXT
543
+ = Document title
544
+ Author
545
+ :docfile: test.adoc
546
+ :nodoc:
547
+ :novalid:
548
+ :no-isobib:
549
+ :imagesdir: spec/assets
550
+
551
+ [#{extention}2text,#{example_file},my_context]
552
+ ----
553
+ {% for item in my_context %}
554
+ {% if item.show %}
555
+ {{ item.name | upcase }}
556
+ {{ item.name | size }}
557
+ {% endif %}
558
+ {% endfor %}
559
+ ----
560
+ TEXT
561
+ end
562
+ let(:output) do
563
+ <<~TEXT
564
+ #{BLANK_HDR}
565
+ <sections>
566
+ <p id='_'>ONE 3</p>
567
+ <p id='_'>TWO 3</p>
568
+ </sections>
569
+ </standard-document>
570
+ TEXT
571
+ end
572
+
573
+ it "renders liquid markup" do
574
+ expect(
575
+ xmlpp(
576
+ strip_guid(
577
+ Asciidoctor.convert(input,
578
+ backend: :standoc,
579
+ header_footer: true)
580
+ )
581
+ )
582
+ ).to(be_equivalent_to(xmlpp(output)))
583
+ end
584
+ end
585
+
586
+ context "Date time objects support" do
587
+ let(:example_content) do
588
+ {
589
+ "date" => Date.parse("1889-09-28"),
590
+ "time" => Time.gm(2020, 10, 15, 5, 34),
591
+ }
592
+ end
593
+ let(:input) do
594
+ <<~TEXT
595
+ = Document title
596
+ Author
597
+ :docfile: test.adoc
598
+ :nodoc:
599
+ :novalid:
600
+ :no-isobib:
601
+ :imagesdir: spec/assets
602
+
603
+ [#{extention}2text,#{example_file},my_context]
604
+ ----
605
+ {{my_context.time}}
606
+
607
+ {{my_context.date}}
608
+ ----
609
+ TEXT
610
+ end
611
+ let(:output) do
612
+ <<~TEXT
613
+ #{BLANK_HDR}
614
+ <sections>
615
+ <p id='_'>1889-09-28</p>
616
+ <p id='_'>2020-10-15 05:34:00 UTC</p>
617
+ </sections>
618
+ </standard-document>
619
+ TEXT
620
+ end
621
+
622
+ it "renders liquid markup" do
623
+ expect(
624
+ xmlpp(
625
+ strip_guid(
626
+ Asciidoctor.convert(input,
627
+ backend: :standoc,
628
+ header_footer: true)
629
+ )
630
+ )
631
+ ).to(be_equivalent_to(xmlpp(output)))
632
+ end
633
+ end
634
+
635
+ context "Nested files support" do
636
+ let(:example_content) do
637
+ {
638
+ "date" => Date.parse("1889-09-28"),
639
+ "time" => Time.gm(2020, 10, 15, 5, 34),
640
+ }
641
+ end
642
+ let(:parent_file) { "parent_file.#{extention}" }
643
+ let(:parent_file_content) { [nested_file, nested_file_2] }
644
+ let(:parent_file_2) { "parent_file_2.#{extention}" }
645
+ let(:parent_file_2_content) { ["name", "description"] }
646
+ let(:parent_file_3) { "parent_file_3.#{extention}" }
647
+ let(:parent_file_3_content) { ["one", "two"] }
648
+ let(:nested_file) { "nested_file.#{extention}" }
649
+ let(:nested_file_content) do
650
+ {
651
+ "name" => "nested file-main",
652
+ "description" => "nested description-main",
653
+ "one" => "nested one-main",
654
+ "two" => "nested two-main",
655
+ }
656
+ end
657
+ let(:nested_file_2) { "nested_file_2.#{extention}" }
658
+ let(:nested_file_2_content) do
659
+ {
660
+ "name" => "nested2 name-main",
661
+ "description" => "nested2 description-main",
662
+ "one" => "nested2 one-main",
663
+ "two" => "nested2 two-main",
664
+ }
665
+ end
666
+ let(:input) do
667
+ <<~TEXT
668
+ = Document title
669
+ Author
670
+ :docfile: test.adoc
671
+ :nodoc:
672
+ :novalid:
673
+ :no-isobib:
674
+ :imagesdir: spec/assets
675
+
676
+ [#{extention}2text,#{parent_file},paths]
677
+ ----
678
+ {% for path in paths %}
679
+
680
+ [#{extention}2text,#{parent_file_2},attribute_names]
681
+ ---
682
+ {% for name in attribute_names %}
683
+
684
+ [#{extention}2text,{{ path }},data]
685
+ --
686
+
687
+ == {{ data[name] | split: "-" | last }}: {{ data[name] }}
688
+
689
+ --
690
+
691
+ {% endfor %}
692
+ ---
693
+
694
+ [#{extention}2text,#{parent_file_3},attribute_names]
695
+ ---
696
+ {% for name in attribute_names %}
697
+
698
+ [#{extention}2text,{{ path }},data]
699
+ --
700
+
701
+ == {{ data[name] }}
702
+
703
+ --
704
+
705
+ {% endfor %}
706
+ ---
707
+
708
+ {% endfor %}
709
+ ----
710
+ TEXT
711
+ end
712
+ let(:output) do
713
+ <<~TEXT
714
+ #{BLANK_HDR}
715
+ <sections>
716
+ <clause id='_' inline-header='false' obligation='normative'>
717
+ <title>main: nested file-main</title>
718
+ </clause>
719
+ <clause id='_' inline-header='false' obligation='normative'>
720
+ <title>main: nested description-main</title>
721
+ </clause>
722
+ <clause id='_' inline-header='false' obligation='normative'>
723
+ <title>nested one-main</title>
724
+ </clause>
725
+ <clause id='_' inline-header='false' obligation='normative'>
726
+ <title>nested two-main</title>
727
+ </clause>
728
+ <clause id='_' inline-header='false' obligation='normative'>
729
+ <title>main: nested2 name-main</title>
730
+ </clause>
731
+ <clause id='_' inline-header='false' obligation='normative'>
732
+ <title>main: nested2 description-main</title>
733
+ </clause>
734
+ <clause id='_' inline-header='false' obligation='normative'>
735
+ <title>nested2 one-main</title>
736
+ </clause>
737
+ <clause id='_' inline-header='false' obligation='normative'>
738
+ <title>nested2 two-main</title>
739
+ </clause>
740
+ </sections>
741
+ </standard-document>
742
+ TEXT
743
+ end
744
+ let(:file_list) do
745
+ {
746
+ parent_file => parent_file_content,
747
+ parent_file_2 => parent_file_2_content,
748
+ parent_file_3 => parent_file_3_content,
749
+ nested_file => nested_file_content,
750
+ nested_file_2 => nested_file_2_content,
751
+ }
752
+ end
753
+
754
+ before do
755
+ file_list.each_pair do |file, content|
756
+ File.open(file, "w") do |n|
757
+ n.puts(transform_to_type(content))
758
+ end
759
+ end
760
+ end
761
+
762
+ after do
763
+ file_list.keys.each do |file|
764
+ FileUtils.rm_rf(file)
765
+ end
766
+ end
767
+
768
+ it "renders liquid markup" do
769
+ expect(
770
+ xmlpp(
771
+ strip_guid(
772
+ Asciidoctor.convert(input,
773
+ backend: :standoc,
774
+ header_footer: true)
775
+ )
776
+ )
777
+ ).to(be_equivalent_to(xmlpp(output)))
778
+ end
779
+ end
780
+ end
781
+ end