metanorma-standoc 1.6.0 → 1.6.5

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 (63) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +66 -0
  3. data/README.adoc +1 -3
  4. data/lib/asciidoctor/standoc/base.rb +8 -16
  5. data/lib/asciidoctor/standoc/basicdoc.rng +32 -0
  6. data/lib/asciidoctor/standoc/cleanup.rb +52 -4
  7. data/lib/asciidoctor/standoc/cleanup_block.rb +41 -4
  8. data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +14 -0
  9. data/lib/asciidoctor/standoc/cleanup_footnotes.rb +25 -0
  10. data/lib/asciidoctor/standoc/cleanup_inline.rb +6 -2
  11. data/lib/asciidoctor/standoc/cleanup_ref.rb +18 -25
  12. data/lib/asciidoctor/standoc/cleanup_terms.rb +3 -0
  13. data/lib/asciidoctor/standoc/converter.rb +61 -3
  14. data/lib/asciidoctor/standoc/front.rb +9 -3
  15. data/lib/asciidoctor/standoc/front_contributor.rb +34 -10
  16. data/lib/asciidoctor/standoc/isodoc.rng +29 -44
  17. data/lib/asciidoctor/standoc/lists.rb +4 -2
  18. data/lib/asciidoctor/standoc/macros.rb +45 -63
  19. data/lib/asciidoctor/standoc/macros_terms.rb +82 -0
  20. data/lib/asciidoctor/standoc/ref.rb +24 -36
  21. data/lib/asciidoctor/standoc/ref_sect.rb +16 -8
  22. data/lib/asciidoctor/standoc/section.rb +5 -9
  23. data/lib/asciidoctor/standoc/table.rb +12 -0
  24. data/lib/asciidoctor/standoc/term_lookup_cleanup.rb +86 -0
  25. data/lib/liquid/custom_blocks/with_json_nested_context.rb +18 -0
  26. data/lib/liquid/custom_blocks/with_yaml_nested_context.rb +19 -0
  27. data/lib/metanorma/standoc/version.rb +1 -1
  28. data/metanorma-standoc.gemspec +6 -3
  29. data/spec/asciidoctor-standoc/base_spec.rb +127 -8
  30. data/spec/asciidoctor-standoc/blocks_spec.rb +8 -8
  31. data/spec/asciidoctor-standoc/cleanup_sections_spec.rb +1514 -0
  32. data/spec/asciidoctor-standoc/cleanup_spec.rb +450 -1554
  33. data/spec/asciidoctor-standoc/isobib_cache_spec.rb +22 -31
  34. data/spec/asciidoctor-standoc/lists_spec.rb +10 -1
  35. data/spec/asciidoctor-standoc/macros_json2text_spec.rb +1 -1
  36. data/spec/asciidoctor-standoc/macros_lutaml_spec.rb +80 -0
  37. data/spec/asciidoctor-standoc/macros_plantuml_spec.rb +307 -0
  38. data/spec/asciidoctor-standoc/macros_spec.rb +378 -169
  39. data/spec/asciidoctor-standoc/macros_yaml2text_spec.rb +1 -1
  40. data/spec/asciidoctor-standoc/refs_dl_spec.rb +8 -8
  41. data/spec/asciidoctor-standoc/refs_spec.rb +350 -101
  42. data/spec/asciidoctor-standoc/section_spec.rb +11 -11
  43. data/spec/asciidoctor-standoc/table_spec.rb +86 -0
  44. data/spec/asciidoctor-standoc/validate_spec.rb +26 -0
  45. data/spec/fixtures/diagram_definitions.lutaml +22 -0
  46. data/spec/fixtures/test.exp +121 -0
  47. data/spec/spec_helper.rb +33 -0
  48. data/spec/support/shared_examples/structured_data_2_text_preprocessor.rb +156 -4
  49. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +49 -233
  50. data/spec/vcr_cassettes/isobib_get_123.yml +12 -58
  51. data/spec/vcr_cassettes/isobib_get_123_1.yml +27 -119
  52. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +361 -0
  53. data/spec/vcr_cassettes/isobib_get_123_2001.yml +12 -58
  54. data/spec/vcr_cassettes/isobib_get_124.yml +11 -57
  55. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +8 -8
  56. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +276 -158
  57. metadata +61 -14
  58. data/.github/workflows/macos.yml +0 -41
  59. data/.github/workflows/ubuntu.yml +0 -45
  60. data/.github/workflows/windows.yml +0 -43
  61. data/lib/asciidoctor/standoc/base_structured_text_preprocessor.rb +0 -123
  62. data/lib/asciidoctor/standoc/json2_text_preprocessor.rb +0 -44
  63. data/lib/asciidoctor/standoc/yaml2_text_preprocessor.rb +0 -46
@@ -111,7 +111,7 @@ RSpec.describe Asciidoctor::Standoc do
111
111
  <title>Terms and definitions</title>
112
112
  <p id="_">For the purposes of this document,
113
113
  the following terms and definitions apply.</p>
114
- <term id="_">
114
+ <term id="term-term1">
115
115
  <preferred>Term1</preferred>
116
116
  </term>
117
117
  </terms>
@@ -133,14 +133,14 @@ RSpec.describe Asciidoctor::Standoc do
133
133
  <title>Intro 4</title>
134
134
  <terms id="_" obligation="normative">
135
135
  <title>Intro 5</title>
136
- <term id="_">
136
+ <term id="term-term1-1">
137
137
  <preferred>Term1</preferred>
138
138
  </term>
139
139
  </terms>
140
140
  </clause>
141
141
  <terms id="_" obligation="normative">
142
142
  <title>Normal Terms</title>
143
- <term id="_">
143
+ <term id="term-term2">
144
144
  <preferred>Term2</preferred>
145
145
  </term>
146
146
  </terms>
@@ -317,7 +317,7 @@ RSpec.describe Asciidoctor::Standoc do
317
317
  <title>Terms and definitions</title>
318
318
  <p id="_">For the purposes of this document,
319
319
  the following terms and definitions apply.</p>
320
- <term id="_" language="en" script="Latn">
320
+ <term id="term-term1" language="en" script="Latn">
321
321
  <preferred>Term1</preferred>
322
322
  </term>
323
323
  </terms>
@@ -339,14 +339,14 @@ RSpec.describe Asciidoctor::Standoc do
339
339
  <title>Intro 4</title>
340
340
  <terms id="_" language="en" script="Latn" obligation="normative">
341
341
  <title>Intro 5</title>
342
- <term id="_">
342
+ <term id="term-term1-1">
343
343
  <preferred>Term1</preferred>
344
344
  </term>
345
345
  </terms>
346
346
  </clause>
347
347
  <terms id="_" language="en" script="Latn" obligation="normative">
348
348
  <title>Normal Terms</title>
349
- <term id="_">
349
+ <term id="term-term2">
350
350
  <preferred>Term2</preferred>
351
351
  </term>
352
352
  </terms>
@@ -468,7 +468,7 @@ RSpec.describe Asciidoctor::Standoc do
468
468
  <terms id='_' obligation='normative'>
469
469
  <title>Terms and definitions</title>
470
470
  <p id="_">For the purposes of this document, the following terms and definitions apply.</p>
471
- <term id='_'>
471
+ <term id='term-term1'>
472
472
  <preferred>Term1</preferred>
473
473
  </term>
474
474
  </terms>
@@ -477,7 +477,7 @@ RSpec.describe Asciidoctor::Standoc do
477
477
  <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
478
478
  <terms id='_' obligation='normative'>
479
479
  <title>Normal Terms</title>
480
- <term id='_'>
480
+ <term id='term-term2'>
481
481
  <preferred>Term2</preferred>
482
482
  </term>
483
483
  </terms>
@@ -536,7 +536,7 @@ RSpec.describe Asciidoctor::Standoc do
536
536
  <terms id='_' obligation='normative'>
537
537
  <title>Terms, definitions and symbols</title>
538
538
  <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
539
- <term id='_'>
539
+ <term id='term-term'>
540
540
  <preferred>Term</preferred>
541
541
  </term>
542
542
  <definitions id='_' obligation="normative" type="symbols">
@@ -565,7 +565,7 @@ RSpec.describe Asciidoctor::Standoc do
565
565
  <terms id='_' obligation='normative'>
566
566
  <title>Terms, definitions and abbreviated terms</title>
567
567
  <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
568
- <term id='_'>
568
+ <term id='term-term'>
569
569
  <preferred>Term</preferred>
570
570
  </term>
571
571
  <definitions id='_' obligation="normative" type="abbreviated_terms">
@@ -710,7 +710,7 @@ RSpec.describe Asciidoctor::Standoc do
710
710
  <terms id="_" obligation="normative">
711
711
  <title>Terms and definitions</title><p id="_">For the purposes of this document, the terms and definitions
712
712
  given in <eref bibitemid="iso1234"/> and <eref bibitemid="iso5678"/> and the following apply.</p>
713
- <term id="_">
713
+ <term id="term-term1">
714
714
  <preferred>Term1</preferred>
715
715
  </term>
716
716
  </terms></sections>
@@ -35,6 +35,92 @@ RSpec.describe Asciidoctor::Standoc do
35
35
  OUTPUT
36
36
  end
37
37
 
38
+ it "processes column widths in tables" do
39
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
40
+ #{ASCIIDOC_BLANK_HDR}
41
+ [cols=".<,.^,^.>"]
42
+ |===
43
+ |A |B |C
44
+
45
+ |1 |2 |3
46
+ |===
47
+
48
+ [cols="3"]
49
+ |===
50
+ |A |B |C
51
+
52
+ |1 |2 |3
53
+ |===
54
+
55
+
56
+ [cols="1,2,6"]
57
+ |===
58
+ |A |B |C
59
+
60
+ |1 |2 |3
61
+ |===
62
+ INPUT
63
+ #{BLANK_HDR}
64
+ <sections>
65
+ <table id='_'>
66
+ <thead>
67
+ <tr>
68
+ <th valign='top' align='left'>A</th>
69
+ <th valign='middle' align='left'>B</th>
70
+ <th valign='bottom' align='center'>C</th>
71
+ </tr>
72
+ </thead>
73
+ <tbody>
74
+ <tr>
75
+ <td valign='top' align='left'>1</td>
76
+ <td valign='middle' align='left'>2</td>
77
+ <td valign='bottom' align='center'>3</td>
78
+ </tr>
79
+ </tbody>
80
+ </table>
81
+ <table id='_'>
82
+ <thead>
83
+ <tr>
84
+ <th valign='top' align='left'>A</th>
85
+ <th valign='top' align='left'>B</th>
86
+ <th valign='top' align='left'>C</th>
87
+ </tr>
88
+ </thead>
89
+ <tbody>
90
+ <tr>
91
+ <td valign='top' align='left'>1</td>
92
+ <td valign='top' align='left'>2</td>
93
+ <td valign='top' align='left'>3</td>
94
+ </tr>
95
+ </tbody>
96
+ </table>
97
+ <table id='_'>
98
+ <colgroup>
99
+ <col width='11.1111%'/>
100
+ <col width='22.2222%'/>
101
+ <col width='66.6667%'/>
102
+ </colgroup>
103
+ <thead>
104
+ <tr>
105
+ <th valign='top' align='left'>A</th>
106
+ <th valign='top' align='left'>B</th>
107
+ <th valign='top' align='left'>C</th>
108
+ </tr>
109
+ </thead>
110
+ <tbody>
111
+ <tr>
112
+ <td valign='top' align='left'>1</td>
113
+ <td valign='top' align='left'>2</td>
114
+ <td valign='top' align='left'>3</td>
115
+ </tr>
116
+ </tbody>
117
+ </table>
118
+ </sections>
119
+ </standard-document>
120
+ OUTPUT
121
+ end
122
+
123
+
38
124
  it "inserts header rows in a table with a name and no header" do
39
125
  expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
40
126
  #{ASCIIDOC_BLANK_HDR}
@@ -369,4 +369,30 @@ it "err file succesfully created for docfile path" do
369
369
  expect(File.read("test/test.err")).to include "Hanging paragraph in clause"
370
370
  end
371
371
 
372
+ it "Warning if no block for footnoteblock" do
373
+ FileUtils.rm_f "test.err"
374
+ Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
375
+ = Document title
376
+ Author
377
+ :docfile: test.adoc
378
+
379
+ footnoteblock:[id1]
380
+
381
+ [[id2]]
382
+ [NOTE]
383
+ --
384
+ |===
385
+ |a |b
386
+
387
+ |c |d
388
+ |===
389
+
390
+ * A
391
+ * B
392
+ * C
393
+ --
394
+ INPUT
395
+ expect(File.read("test.err")).to include 'Could not resolve footnoteblock:[id1]'
396
+ end
397
+
372
398
  end
@@ -0,0 +1,22 @@
1
+ diagram MyView {
2
+ title "my diagram"
3
+
4
+ enum AddressClassProfile {
5
+ imlicistAttributeProfile: CharacterString [0..1] {
6
+ definition {
7
+ this is multiline with `ascidoc`
8
+ comments
9
+ and list
10
+ }
11
+ }
12
+ }
13
+
14
+ class AttributeProfile {
15
+ +addressClassProfile: CharacterString [0..1]
16
+ imlicistAttributeProfile: CharacterString [0..1] {
17
+ definition { this is attribute definition
18
+ with multiply lines
19
+ }
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,121 @@
1
+ (*
2
+ $Id: test.exp,v 1.3 2020/07/30 05:18:54 ftanaka Exp $
3
+ ISO 10303 TC184/SC4/WG12 N10658
4
+
5
+ EXPRESS Source:
6
+ ISO 10303-59 ed3 Quality of product shape data - Annotated 3d model data quality criteria schema
7
+
8
+ The following permission notice and disclaimer shall be included in all copies of this EXPRESS schema ("the Schema"),
9
+ and derivations of the Schema:
10
+
11
+ Copyright ISO 2020 All rights reserved
12
+ Permission is hereby granted, free of charge in perpetuity, to any person obtaining a copy of the Schema,
13
+ to use, copy, modify, merge and distribute free of charge, copies of the Schema for the purposes of developing,
14
+ implementing, installing and using software based on the Schema, and to permit persons to whom the Schema is furnished to do so,
15
+ subject to the following conditions:
16
+
17
+ THE SCHEMA IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SCHEMA OR THE
22
+ USE OR OTHER DEALINGS IN THE SCHEMA.
23
+
24
+ In addition, any modified copy of the Schema shall include the following notice:
25
+
26
+ THIS SCHEMA HAS BEEN MODIFIED FROM THE SCHEMA DEFINED IN
27
+ ISO 10303-59 ed3 Quality of product shape data - Annotated 3d model data quality criteria schema
28
+ AND SHOULD NOT BE INTERPRETED AS COMPLYING WITH THAT STANDARD
29
+ *)
30
+
31
+ SCHEMA annotated_3d_model_data_quality_criteria_schema '{iso standard 10303 part(59) version(3) object(1) annotated_3d_model_data_quality_criteria_schema(6)}';
32
+
33
+ (* Need select eleemnts for measure_value *)
34
+ REFERENCE FROM measure_schema
35
+ (measure_value);
36
+
37
+ REFERENCE FROM product_data_quality_criteria_schema
38
+ (data_quality_criteria_representation,
39
+ data_quality_criterion,
40
+ data_quality_measurement_requirement,
41
+ detailed_report_request_with_number_of_data,
42
+ summary_report_request);
43
+
44
+ REFERENCE FROM representation_schema
45
+ (representation,
46
+ representation_item);
47
+
48
+ REFERENCE FROM shape_data_quality_criteria_schema
49
+ (shape_data_quality_assessment_specification_select,
50
+ shape_measurement_accuracy);
51
+
52
+ REFERENCE FROM support_resource_schema
53
+ (identifier,
54
+ label,
55
+ text);
56
+
57
+ TYPE a3m_accuracy_associated_target_select = EXTENSIBLE SELECT;
58
+ END_TYPE;
59
+
60
+ TYPE a3m_data_quality_accuracy_type_name = EXTENSIBLE ENUMERATION;
61
+ END_TYPE;
62
+
63
+ TYPE a3m_data_quality_inspected_element_type_name = EXTENSIBLE ENUMERATION;
64
+ END_TYPE;
65
+
66
+ TYPE a3m_data_quality_measured_data_type_name = EXTENSIBLE ENUMERATION;
67
+ END_TYPE;
68
+
69
+ TYPE a3m_data_quality_type_name_for_location_of_extreme_value = EXTENSIBLE ENUMERATION;
70
+ END_TYPE;
71
+
72
+ TYPE summary_stats_value_type = ENUMERATION OF
73
+ (average_value,
74
+ max_value,
75
+ min_value);
76
+ END_TYPE;
77
+
78
+ ENTITY a3m_data_quality_criteria_representation
79
+ SUBTYPE OF (data_quality_criteria_representation);
80
+ WHERE
81
+ WR1: SIZEOF( QUERY( q <* SELF\representation.items|
82
+ 'ANNOTATED_3D_MODEL_DATA_QUALITY_CRITERIA_SCHEMA.' +
83
+ 'A3M_DATA_QUALITY_CRITERION' IN TYPEOF(q))) > 0;
84
+ END_ENTITY;
85
+
86
+ ENTITY a3m_data_quality_criterion
87
+ ABSTRACT SUPERTYPE
88
+ SUBTYPE OF(data_quality_criterion, data_quality_measurement_requirement);
89
+ assessment_specification : shape_data_quality_assessment_specification_select;
90
+ measured_data_type : a3m_data_quality_measured_data_type_name;
91
+ inspected_elements_types: LIST[1:?] OF a3m_data_quality_inspected_element_type_name;
92
+ accuracy_types : LIST [0:?] OF a3m_data_quality_accuracy_type_name;
93
+ location_of_extreme_value_types: LIST[0:?] OF a3m_data_quality_type_name_for_location_of_extreme_value;
94
+ END_ENTITY;
95
+
96
+ ENTITY a3m_data_quality_criterion_specific_applied_value
97
+ ABSTRACT SUPERTYPE
98
+ SUBTYPE OF(representation_item);
99
+ criterion_to_assign_the_value: a3m_data_quality_criterion;
100
+ applied_value : measure_value;
101
+ END_ENTITY;
102
+
103
+ ENTITY a3m_data_quality_target_accuracy_association;
104
+ id : identifier;
105
+ name : label;
106
+ description : OPTIONAL text;
107
+ accuracy_specification : shape_measurement_accuracy;
108
+ target_to_associate : a3m_accuracy_associated_target_select;
109
+ END_ENTITY;
110
+
111
+ ENTITY a3m_detailed_report_request
112
+ SUBTYPE OF(detailed_report_request_with_number_of_data);
113
+ value_type_requested : summary_stats_value_type;
114
+ END_ENTITY;
115
+
116
+ ENTITY a3m_summary_report_request_with_representative_value
117
+ SUBTYPE OF(summary_report_request);
118
+ value_type_requested : summary_stats_value_type;
119
+ END_ENTITY;
120
+
121
+ END_SCHEMA;
@@ -3,6 +3,11 @@ require "vcr"
3
3
  VCR.configure do |config|
4
4
  config.cassette_library_dir = "spec/vcr_cassettes"
5
5
  config.hook_into :webmock
6
+ config.default_cassette_options = {
7
+ clean_outdated_http_interactions: true,
8
+ re_record_interval: 1512000,
9
+ record: :once,
10
+ }
6
11
  end
7
12
 
8
13
  require "simplecov"
@@ -150,6 +155,24 @@ BLANK_HDR = <<~"HDR".freeze
150
155
  </bibdata>
151
156
  HDR
152
157
 
158
+ BLANK_METANORMA_HDR = <<~"HDR".freeze
159
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
160
+ <?xml version="1.0" encoding="UTF-8"?><html><body>
161
+ <standard-document xmlns="https://www.metanorma.org/ns/standoc" version="#{Metanorma::Standoc::VERSION}" type="semantic">
162
+ <bibdata type="standard">
163
+ <title language="en" format="text/plain">Document title</title>
164
+ <language>en</language>
165
+ <script>Latn</script>
166
+ <status><stage>published</stage></status>
167
+ <copyright>
168
+ <from>#{Time.new.year}</from>
169
+ </copyright>
170
+ <ext>
171
+ <doctype>article</doctype>
172
+ </ext>
173
+ </bibdata>
174
+ HDR
175
+
153
176
  HTML_HDR = <<~END.freeze
154
177
  <html xmlns:epub="http://www.idpf.org/2007/ops">
155
178
  <head>
@@ -248,3 +271,13 @@ def mock_open_uri(code)
248
271
  File.read file, encoding: "utf-8"
249
272
  end.at_least :once
250
273
  end
274
+
275
+ def metanorma_process(input)
276
+ Metanorma::Input::Asciidoc
277
+ .new
278
+ .process(input, "test.adoc", :standoc)
279
+ end
280
+
281
+ def xml_string_conent(xml)
282
+ strip_guid(Nokogiri::HTML(xml).to_s)
283
+ end
@@ -17,7 +17,8 @@ RSpec.shared_examples "structured data 2 text preprocessor" do
17
17
  [{ "name" => "spaghetti",
18
18
  "desc" => "wheat noodles of 9mm diameter",
19
19
  "symbol" => "SPAG",
20
- "symbol_def" => "the situation is message like spaghetti at a kid's meal" }]
20
+ "symbol_def" =>
21
+ "the situation is message like spaghetti at a kid's meal" }]
21
22
  end
22
23
  let(:input) do
23
24
  <<~TEXT
@@ -449,8 +450,10 @@ RSpec.shared_examples "structured data 2 text preprocessor" do
449
450
  "target_script" => "Latn",
450
451
  "system" =>
451
452
  { "id" => "2002",
452
- "specification" => "Academica Sinica -- Chinese Tongyong Pinyin (2002)" },
453
- "notes" => "NOTE: OGC 11-122r1 code `zho_Hani2Latn_AcadSin_2002`" } } }
453
+ "specification" =>
454
+ "Academica Sinica -- Chinese Tongyong Pinyin (2002)" },
455
+ "notes" =>
456
+ "NOTE: OGC 11-122r1 code `zho_Hani2Latn_AcadSin_2002`" } } }
454
457
  end
455
458
  let(:input) do
456
459
  <<~TEXT
@@ -582,7 +585,10 @@ RSpec.shared_examples "structured data 2 text preprocessor" do
582
585
 
583
586
  context "Date time objects support" do
584
587
  let(:example_content) do
585
- { "date" => Date.parse('1889-09-28'), "time" => Time.gm(2020, 10, 15, 5, 34) }
588
+ {
589
+ "date" => Date.parse("1889-09-28"),
590
+ "time" => Time.gm(2020, 10, 15, 5, 34),
591
+ }
586
592
  end
587
593
  let(:input) do
588
594
  <<~TEXT
@@ -625,5 +631,151 @@ RSpec.shared_examples "structured data 2 text preprocessor" do
625
631
  ).to(be_equivalent_to(xmlpp(output)))
626
632
  end
627
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
628
780
  end
629
781
  end