metanorma-standoc 1.5.1 → 1.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +62 -0
- data/lib/asciidoctor/standoc/base.rb +7 -2
- data/lib/asciidoctor/standoc/basicdoc.rng +23 -0
- data/lib/asciidoctor/standoc/cleanup.rb +32 -12
- data/lib/asciidoctor/standoc/cleanup_amend.rb +54 -0
- data/lib/asciidoctor/standoc/cleanup_block.rb +0 -2
- data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +14 -0
- data/lib/asciidoctor/standoc/cleanup_footnotes.rb +11 -3
- data/lib/asciidoctor/standoc/cleanup_inline.rb +62 -1
- data/lib/asciidoctor/standoc/cleanup_ref.rb +6 -5
- data/lib/asciidoctor/standoc/cleanup_section.rb +19 -3
- data/lib/asciidoctor/standoc/cleanup_terms.rb +2 -2
- data/lib/asciidoctor/standoc/converter.rb +4 -2
- data/lib/asciidoctor/standoc/front.rb +9 -3
- data/lib/asciidoctor/standoc/front_contributor.rb +58 -18
- data/lib/asciidoctor/standoc/inline.rb +21 -31
- data/lib/asciidoctor/standoc/isodoc.rng +125 -58
- data/lib/asciidoctor/standoc/log.rb +10 -1
- data/lib/asciidoctor/standoc/macros.rb +44 -33
- data/lib/asciidoctor/standoc/ref.rb +39 -44
- data/lib/asciidoctor/standoc/ref_sect.rb +12 -5
- data/lib/asciidoctor/standoc/section.rb +11 -10
- data/lib/asciidoctor/standoc/table.rb +3 -2
- data/lib/asciidoctor/standoc/utils.rb +2 -1
- data/lib/asciidoctor/standoc/validate.rb +30 -18
- data/lib/asciidoctor/standoc/validate_section.rb +1 -1
- data/lib/asciidoctor/standoc/views/datamodel/model_representation.adoc.erb +10 -10
- data/lib/liquid/custom_blocks/key_iterator.rb +21 -0
- data/lib/liquid/custom_blocks/with_json_nested_context.rb +18 -0
- data/lib/liquid/custom_blocks/with_yaml_nested_context.rb +19 -0
- data/lib/liquid/custom_filters/values.rb +7 -0
- data/lib/metanorma/standoc.rb +0 -5
- data/lib/metanorma/standoc/version.rb +20 -1
- data/metanorma-standoc.gemspec +4 -4
- data/spec/asciidoctor-standoc/base_spec.rb +248 -10
- data/spec/asciidoctor-standoc/blocks_spec.rb +263 -144
- data/spec/asciidoctor-standoc/cleanup_spec.rb +199 -50
- data/spec/asciidoctor-standoc/inline_spec.rb +132 -5
- data/spec/asciidoctor-standoc/isobib_cache_spec.rb +13 -27
- data/spec/asciidoctor-standoc/macros_json2text_spec.rb +10 -0
- data/spec/asciidoctor-standoc/macros_spec.rb +43 -23
- data/spec/asciidoctor-standoc/macros_yaml2text_spec.rb +6 -561
- data/spec/asciidoctor-standoc/refs_dl_spec.rb +5 -3
- data/spec/asciidoctor-standoc/refs_spec.rb +268 -57
- data/spec/asciidoctor-standoc/section_spec.rb +0 -1
- data/spec/asciidoctor-standoc/table_spec.rb +119 -113
- data/spec/asciidoctor-standoc/validate_spec.rb +27 -1
- data/spec/examples/codes_table.html +1365 -1365
- data/spec/fixtures/macros_datamodel/address_class_profile.xml +46 -46
- data/spec/fixtures/macros_datamodel/address_component_profile.xml +21 -21
- data/spec/fixtures/macros_datamodel/blank_definition_profile.xml +21 -21
- data/spec/spec_helper.rb +115 -109
- data/spec/support/shared_examples/structured_data_2_text_preprocessor.rb +781 -0
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +54 -238
- data/spec/vcr_cassettes/isobib_get_123.yml +14 -60
- data/spec/vcr_cassettes/isobib_get_123_1.yml +24 -116
- data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +361 -0
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +14 -60
- data/spec/vcr_cassettes/isobib_get_124.yml +11 -57
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +8 -8
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +39 -37
- metadata +42 -11
- data/.github/workflows/macos.yml +0 -46
- data/.github/workflows/ubuntu.yml +0 -49
- data/.github/workflows/windows.yml +0 -53
- data/lib/asciidoctor/standoc/macros_yaml2text.rb +0 -165
- data/lib/metanorma/standoc/latexml_requirement.rb +0 -62
- data/lib/metanorma/standoc/requirement.rb +0 -13
@@ -48,13 +48,11 @@ EOS
|
|
48
48
|
<title type="title-intro" format="text/plain" language="en" script="Latn">Latex, rubber</title>
|
49
49
|
<title type="title-main" format="text/plain" language="en" script="Latn">Determination of total solids content</title>
|
50
50
|
<title type='main' format='text/plain' language='en' script='Latn'>Latex, rubber - Determination of total solids content</title>
|
51
|
-
<title type="title-intro" format="text/plain" language="fr" script="Latn">Latex de caoutchouc</title>
|
52
|
-
<title type="title-main" format="text/plain" language="fr" script="Latn">Détermination des matières solides totales</title>
|
53
|
-
<title type='main' format='text/plain' language='fr' script='Latn'>Latex de caoutchouc - Détermination des matières solides totales</title>
|
54
51
|
<uri type="src">https://www.iso.org/standard/61884.html</uri>
|
55
52
|
<uri type="obp">https://www.iso.org/obp/ui/#!iso:std:61884:en</uri>
|
56
53
|
<uri type="rss">https://www.iso.org/contents/data/standard/06/18/61884.detail.rss</uri>
|
57
54
|
<docidentifier type="ISO">ISO 124:2014</docidentifier>
|
55
|
+
<docidentifier type='URN'>urn:iso:std:iso:124:stage-90.93:ed-7:en</docidentifier>
|
58
56
|
<docnumber>124</docnumber>
|
59
57
|
<date type="published">
|
60
58
|
<on>2014</on>
|
@@ -69,10 +67,8 @@ EOS
|
|
69
67
|
</contributor>
|
70
68
|
<edition>7</edition>
|
71
69
|
<language>en</language>
|
72
|
-
<language>fr</language>
|
73
70
|
<script>Latn</script>
|
74
71
|
<abstract format="text/plain" language="en" script="Latn">ISO 124:2014 specifies methods for the determination of the total solids content of natural rubber field and concentrated latices and synthetic rubber latex. These methods are not necessarily suitable for latex from natural sources other than the Hevea brasiliensis, for vulcanized latex, for compounded latex, or for artificial dispersions of rubber.</abstract>
|
75
|
-
<abstract format="text/plain" language="fr" script="Latn">L'ISO 124:2014 spécifie des méthodes pour la détermination des matières solides totales dans le latex de plantation, le latex de concentré de caoutchouc naturel et le latex de caoutchouc synthétique. Ces méthodes ne conviennent pas nécessairement au latex d'origine naturelle autre que celui de l'Hevea brasiliensis, au latex vulcanisé, aux mélanges de latex, ou aux dispersions artificielles de caoutchouc.</abstract>
|
76
72
|
<status>
|
77
73
|
<stage>90</stage>
|
78
74
|
<substage>93</substage>
|
@@ -113,9 +109,6 @@ EOS
|
|
113
109
|
<title type="title-intro" format="text/plain" language="en" script="Latn">Rubber latex</title>
|
114
110
|
<title type="title-main" format="text/plain" language="en" script="Latn">Sampling</title>
|
115
111
|
<title type="main" format="text/plain" language="en" script="Latn">Rubber latex – Sampling</title>
|
116
|
-
<title type="title-intro" format="text/plain" language="fr" script="Latn">Latex de caoutchouc</title>
|
117
|
-
<title type="title-main" format="text/plain" language="fr" script="Latn">Échantillonnage</title>
|
118
|
-
<title type="main" format="text/plain" language="fr" script="Latn">Latex de caoutchouc – Échantillonnage</title>
|
119
112
|
<uri type="src">https://www.iso.org/standard/23281.html</uri>
|
120
113
|
<uri type="obp">https://www.iso.org/obp/ui/#!iso:std:23281:en</uri>
|
121
114
|
<uri type="rss">https://www.iso.org/contents/data/standard/02/32/23281.detail.rss</uri>
|
@@ -131,7 +124,6 @@ EOS
|
|
131
124
|
</contributor>
|
132
125
|
<edition>3</edition>
|
133
126
|
<language>en</language>
|
134
|
-
<language>fr</language>
|
135
127
|
<script>Latn</script>
|
136
128
|
<status>
|
137
129
|
<stage>90</stage>
|
@@ -155,8 +147,6 @@ EOS
|
|
155
147
|
<fetched>#{Date.today}</fetched>
|
156
148
|
<title type="title-main" format="text/plain" language="en" script="Latn">Rubber latex – Sampling</title>
|
157
149
|
<title type="main" format="text/plain" language="en" script="Latn">Rubber latex – Sampling</title>
|
158
|
-
<title type="title-main" format="text/plain" language="fr" script="Latn">Latex de caoutchouc – Échantillonnage</title>
|
159
|
-
<title type="main" format="text/plain" language="fr" script="Latn">Latex de caoutchouc – Échantillonnage</title>
|
160
150
|
<uri type="src">https://www.iso.org/standard/23281.html</uri>
|
161
151
|
<uri type="obp">https://www.iso.org/obp/ui/#!iso:std:23281:en</uri>
|
162
152
|
<uri type="rss">https://www.iso.org/contents/data/standard/02/32/23281.detail.rss</uri>
|
@@ -175,7 +165,6 @@ EOS
|
|
175
165
|
</contributor>
|
176
166
|
<edition>3</edition>
|
177
167
|
<language>en</language>
|
178
|
-
<language>fr</language>
|
179
168
|
<script>Latn</script>
|
180
169
|
<status>
|
181
170
|
<stage>90</stage>
|
@@ -218,13 +207,11 @@ EOS
|
|
218
207
|
<title type="title-intro" format="text/plain" language="en" script="Latn">Rubber latex</title>
|
219
208
|
<title type="title-main" format="text/plain" language="en" script="Latn">Sampling</title>
|
220
209
|
<title type='main' format='text/plain' language='en' script='Latn'>Rubber latex - Sampling</title>
|
221
|
-
<title type="title-intro" format="text/plain" language="fr" script="Latn">Latex de caoutchouc</title>
|
222
|
-
<title type="title-main" format="text/plain" language="fr" script="Latn">Échantillonnage</title>
|
223
|
-
<title type='main' format='text/plain' language='fr' script='Latn'>Latex de caoutchouc - Échantillonnage</title>
|
224
210
|
<uri type="src">https://www.iso.org/standard/23281.html</uri>
|
225
211
|
<uri type="obp">https://www.iso.org/obp/ui/#!iso:std:23281:en</uri>
|
226
212
|
<uri type="rss">https://www.iso.org/contents/data/standard/02/32/23281.detail.rss</uri>
|
227
213
|
<docidentifier type="ISO">ISO 123:2001</docidentifier>
|
214
|
+
<docidentifier type='URN'>urn:iso:std:iso:123:stage-90.93:ed-3:en</docidentifier>
|
228
215
|
<docnumber>123</docnumber>
|
229
216
|
<date type="published">
|
230
217
|
<on>2001</on>
|
@@ -239,7 +226,6 @@ EOS
|
|
239
226
|
</contributor>
|
240
227
|
<edition>3</edition>
|
241
228
|
<language>en</language>
|
242
|
-
<language>fr</language>
|
243
229
|
<script>Latn</script>
|
244
230
|
<status>
|
245
231
|
<stage>90</stage>
|
@@ -340,7 +326,7 @@ EOS
|
|
340
326
|
FileUtils.rm_rf File.expand_path("~/.iev/cache")
|
341
327
|
|
342
328
|
# mock_isobib_get_123
|
343
|
-
VCR.use_cassette "isobib_get_123_2001" do
|
329
|
+
VCR.use_cassette "isobib_get_123_2001", :re_record_interval => 25200 do
|
344
330
|
Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
|
345
331
|
#{FLUSH_CACHE_ISOBIB_BLANK_HDR}
|
346
332
|
[bibliography]
|
@@ -421,7 +407,7 @@ EOS
|
|
421
407
|
it "activates global cache" do
|
422
408
|
FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
|
423
409
|
FileUtils.rm_rf "relaton/cache"
|
424
|
-
VCR.use_cassette "isobib_get_123_2001" do
|
410
|
+
VCR.use_cassette "isobib_get_123_2001", :re_record_interval => 25200 do
|
425
411
|
Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
|
426
412
|
#{CACHED_ISOBIB_BLANK_HDR}
|
427
413
|
[bibliography]
|
@@ -541,7 +527,7 @@ EOS
|
|
541
527
|
#)
|
542
528
|
|
543
529
|
# mock_isobib_get_124
|
544
|
-
VCR.use_cassette "isobib_get_124" do
|
530
|
+
VCR.use_cassette "isobib_get_124", :re_record_interval => 25200 do
|
545
531
|
Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
|
546
532
|
#{CACHED_ISOBIB_BLANK_HDR}
|
547
533
|
[bibliography]
|
@@ -580,7 +566,7 @@ EOS
|
|
580
566
|
#)
|
581
567
|
|
582
568
|
# mock_isobib_get_123_undated
|
583
|
-
VCR.use_cassette "isobib_get_123" do
|
569
|
+
VCR.use_cassette "isobib_get_123", :re_record_interval => 25200 do
|
584
570
|
Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
|
585
571
|
#{CACHED_ISOBIB_BLANK_HDR}
|
586
572
|
[bibliography]
|
@@ -601,7 +587,7 @@ EOS
|
|
601
587
|
end
|
602
588
|
|
603
589
|
it "does not expire stale dated references" do
|
604
|
-
VCR.use_cassette "isobib_get_123_2001" do
|
590
|
+
VCR.use_cassette "isobib_get_123_2001", :re_record_interval => 25200 do
|
605
591
|
FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore1")
|
606
592
|
FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
|
607
593
|
|
@@ -635,8 +621,8 @@ EOS
|
|
635
621
|
end
|
636
622
|
|
637
623
|
it "prioritises local over global cache values" do
|
638
|
-
VCR.use_cassette "isobib_get_123_2001" do
|
639
|
-
VCR.use_cassette "isobib_get_124" do
|
624
|
+
VCR.use_cassette "isobib_get_123_2001", :re_record_interval => 25200 do
|
625
|
+
VCR.use_cassette "isobib_get_124", :re_record_interval => 25200 do
|
640
626
|
FileUtils.rm_rf File.expand_path("~/.relaton-bib.pstore1")
|
641
627
|
FileUtils.mv File.expand_path("~/.relaton/cache"), File.expand_path("~/.relaton-bib.pstore1"), force: true
|
642
628
|
FileUtils.rm_rf "relaton/cache"
|
@@ -687,19 +673,19 @@ EOS
|
|
687
673
|
private
|
688
674
|
|
689
675
|
def mock_isobib_get_123
|
690
|
-
expect(RelatonIso::IsoBibliography).to receive(:get).with("ISO 123", "2001", {:title=>"<em>Standard</em>", :usrlbl=>nil}).and_return(RelatonIsoBib::XMLParser.from_xml(ISO_123_DATED))
|
676
|
+
expect(RelatonIso::IsoBibliography).to receive(:get).with("ISO 123", "2001", {:lang=>"en", :title=>"<em>Standard</em>", :usrlbl=>nil}).and_return(RelatonIsoBib::XMLParser.from_xml(ISO_123_DATED))
|
691
677
|
end
|
692
678
|
|
693
679
|
def mock_isobib_get_123_undated
|
694
|
-
expect(RelatonIso::IsoBibliography).to receive(:get).with("ISO 123", nil, {:title=>"<em>Standard</em>", :usrlbl=>nil}).and_return(RelatonIsoBib::XMLParser.from_xml(ISO_123_UNDATED))
|
680
|
+
expect(RelatonIso::IsoBibliography).to receive(:get).with("ISO 123", nil, {:lang=>"en", :title=>"<em>Standard</em>", :usrlbl=>nil}).and_return(RelatonIsoBib::XMLParser.from_xml(ISO_123_UNDATED))
|
695
681
|
end
|
696
682
|
|
697
683
|
def mock_isobib_get_124
|
698
|
-
expect(RelatonIso::IsoBibliography).to receive(:get).with("ISO 124", "2014", {:title=>"<em>Standard</em>", :usrlbl=>nil}).and_return(RelatonIsoBib::XMLParser.from_xml(ISO_124_DATED))
|
684
|
+
expect(RelatonIso::IsoBibliography).to receive(:get).with("ISO 124", "2014", {:lang=>"en", :title=>"<em>Standard</em>", :usrlbl=>nil}).and_return(RelatonIsoBib::XMLParser.from_xml(ISO_124_DATED))
|
699
685
|
end
|
700
686
|
|
701
687
|
def mock_ietfbib_get_123
|
702
|
-
expect(RelatonIetf::IetfBibliography).to receive(:get).with("RFC 123", nil, {:title=>"<em>Standard</em>", :usrlbl=>nil}).and_return(RelatonIsoBib::XMLParser.from_xml(IETF_123_SHORT))
|
688
|
+
expect(RelatonIetf::IetfBibliography).to receive(:get).with("RFC 123", nil, {:lang=>"en", :title=>"<em>Standard</em>", :usrlbl=>nil}).and_return(RelatonIsoBib::XMLParser.from_xml(IETF_123_SHORT))
|
703
689
|
end
|
704
690
|
|
705
691
|
end
|
@@ -8,6 +8,7 @@ RSpec.describe Asciidoctor::Standoc do
|
|
8
8
|
deprecated:[term1]
|
9
9
|
domain:[term1]
|
10
10
|
inherit:[<<ref1>>]
|
11
|
+
autonumber:table[3]
|
11
12
|
|
12
13
|
[bibliography]
|
13
14
|
== Bibliography
|
@@ -23,6 +24,7 @@ RSpec.describe Asciidoctor::Standoc do
|
|
23
24
|
<inherit>
|
24
25
|
<eref type='inline' bibitemid='ref1' citeas='XYZ 123'/>
|
25
26
|
</inherit>
|
27
|
+
<autonumber type='table'>3</autonumber>
|
26
28
|
</foreword>
|
27
29
|
</preface>
|
28
30
|
<sections> </sections>
|
@@ -293,29 +295,47 @@ OUTPUT
|
|
293
295
|
<formula id='_'>
|
294
296
|
<stem type='MathML'>
|
295
297
|
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
298
|
+
<mover>
|
299
|
+
<mrow>
|
300
|
+
<mi>X</mi>
|
301
|
+
</mrow>
|
302
|
+
<mrow>
|
303
|
+
<mo>¯</mo>
|
304
|
+
</mrow>
|
305
|
+
</mover>
|
306
|
+
<mo>′</mo>
|
307
|
+
<mo>=</mo>
|
308
|
+
<mfrac>
|
309
|
+
<mrow>
|
310
|
+
<mn>1</mn>
|
311
|
+
</mrow>
|
312
|
+
<mrow>
|
313
|
+
<mi>v</mi>
|
314
|
+
</mrow>
|
315
|
+
</mfrac>
|
316
|
+
<munderover>
|
317
|
+
<mrow>
|
318
|
+
<mo>∑</mo>
|
319
|
+
</mrow>
|
320
|
+
<mrow>
|
321
|
+
<mrow>
|
322
|
+
<mi>i</mi>
|
323
|
+
<mo>=</mo>
|
324
|
+
<mn>1</mn>
|
325
|
+
</mrow>
|
326
|
+
</mrow>
|
327
|
+
<mrow>
|
328
|
+
<mi>v</mi>
|
329
|
+
</mrow>
|
330
|
+
</munderover>
|
331
|
+
<msub>
|
332
|
+
<mrow>
|
333
|
+
<mi>t</mi>
|
334
|
+
</mrow>
|
335
|
+
<mrow>
|
336
|
+
<mi>i</mi>
|
337
|
+
</mrow>
|
338
|
+
</msub>
|
319
339
|
</math>
|
320
340
|
</stem>
|
321
341
|
</formula>
|
@@ -1,565 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
|
-
RSpec.describe
|
4
|
-
|
5
|
-
let(:
|
6
|
-
|
7
|
-
|
8
|
-
if defined?(example_yaml_content)
|
9
|
-
File.open(example_file, 'w') { |n| n.puts(example_yaml_content) }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
after do
|
14
|
-
FileUtils.rm_rf(example_file)
|
15
|
-
end
|
16
|
-
|
17
|
-
context 'Array of hashes' do
|
18
|
-
let(:example_yaml_content) do
|
19
|
-
<<~TEXT
|
20
|
-
---
|
21
|
-
- name: spaghetti
|
22
|
-
desc: wheat noodles of 9mm diameter
|
23
|
-
symbol: SPAG
|
24
|
-
symbol_def: the situation is message like spaghetti at a kid's meal
|
25
|
-
TEXT
|
26
|
-
end
|
27
|
-
let(:input) do
|
28
|
-
<<~TEXT
|
29
|
-
= Document title
|
30
|
-
Author
|
31
|
-
:docfile: test.adoc
|
32
|
-
:nodoc:
|
33
|
-
:novalid:
|
34
|
-
:no-isobib:
|
35
|
-
:imagesdir: spec/assets
|
36
|
-
|
37
|
-
[yaml2text,#{example_file},my_context]
|
38
|
-
----
|
39
|
-
{my_context.*,item,EOF}
|
40
|
-
{item.name}:: {item.desc}
|
41
|
-
{EOF}
|
42
|
-
----
|
43
|
-
TEXT
|
44
|
-
end
|
45
|
-
let(:output) do
|
46
|
-
<<~TEXT
|
47
|
-
#{BLANK_HDR}
|
48
|
-
<sections>
|
49
|
-
<dl id='_'>
|
50
|
-
<dt>spaghetti</dt>
|
51
|
-
<dd>
|
52
|
-
<p id='_'>wheat noodles of 9mm diameter</p>
|
53
|
-
</dd>
|
54
|
-
</dl>
|
55
|
-
</sections>
|
56
|
-
</standard-document>
|
57
|
-
TEXT
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'correctly renders input yaml' do
|
61
|
-
expect(
|
62
|
-
xmlpp(
|
63
|
-
strip_guid(
|
64
|
-
Asciidoctor.convert(input,
|
65
|
-
backend: :standoc,
|
66
|
-
header_footer: true),
|
67
|
-
),
|
68
|
-
),
|
69
|
-
).to(be_equivalent_to(xmlpp(output)))
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
context 'An array of strings' do
|
74
|
-
let(:example_yaml_content) do
|
75
|
-
<<~TEXT
|
76
|
-
---
|
77
|
-
- lorem
|
78
|
-
- ipsum
|
79
|
-
- dolor
|
80
|
-
TEXT
|
81
|
-
end
|
82
|
-
let(:input) do
|
83
|
-
<<~TEXT
|
84
|
-
= Document title
|
85
|
-
Author
|
86
|
-
:docfile: test.adoc
|
87
|
-
:nodoc:
|
88
|
-
:novalid:
|
89
|
-
:no-isobib:
|
90
|
-
:imagesdir: spec/assets
|
91
|
-
|
92
|
-
[yaml2text,#{example_file},ar]
|
93
|
-
----
|
94
|
-
{ar.*,s,EOS}
|
95
|
-
=== {s.#} {s}
|
96
|
-
|
97
|
-
This section is about {s}.
|
98
|
-
|
99
|
-
{EOS}
|
100
|
-
----
|
101
|
-
TEXT
|
102
|
-
end
|
103
|
-
let(:output) do
|
104
|
-
<<~TEXT
|
105
|
-
#{BLANK_HDR}
|
106
|
-
<sections>
|
107
|
-
<clause id="_" inline-header="false" obligation="normative">
|
108
|
-
<title>0 lorem</title>
|
109
|
-
<p id='_'>This section is about lorem.</p>
|
110
|
-
</clause>
|
111
|
-
<clause id='_' inline-header='false' obligation='normative'>
|
112
|
-
<title>1 ipsum</title>
|
113
|
-
<p id='_'>This section is about ipsum.</p>
|
114
|
-
</clause>
|
115
|
-
<clause id='_' inline-header='false' obligation='normative'>
|
116
|
-
<title>2 dolor</title>
|
117
|
-
<p id='_'>This section is about dolor.</p>
|
118
|
-
</clause>
|
119
|
-
</sections>
|
120
|
-
</standard-document>
|
121
|
-
TEXT
|
122
|
-
end
|
123
|
-
|
124
|
-
it 'correctly renders input yaml' do
|
125
|
-
expect(
|
126
|
-
xmlpp(
|
127
|
-
strip_guid(
|
128
|
-
Asciidoctor.convert(input,
|
129
|
-
backend: :standoc,
|
130
|
-
header_footer: true),
|
131
|
-
),
|
132
|
-
),
|
133
|
-
).to(be_equivalent_to(xmlpp(output)))
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
context 'A simple hash' do
|
138
|
-
let(:example_yaml_content) do
|
139
|
-
<<~TEXT
|
140
|
-
---
|
141
|
-
name: Lorem ipsum
|
142
|
-
desc: dolor sit amet
|
143
|
-
TEXT
|
144
|
-
end
|
145
|
-
let(:input) do
|
146
|
-
<<~TEXT
|
147
|
-
= Document title
|
148
|
-
Author
|
149
|
-
:docfile: test.adoc
|
150
|
-
:nodoc:
|
151
|
-
:novalid:
|
152
|
-
:no-isobib:
|
153
|
-
:imagesdir: spec/assets
|
154
|
-
|
155
|
-
[yaml2text,#{example_file},my_item]
|
156
|
-
----
|
157
|
-
=== {my_item.name}
|
158
|
-
|
159
|
-
{my_item.desc}
|
160
|
-
----
|
161
|
-
TEXT
|
162
|
-
end
|
163
|
-
let(:output) do
|
164
|
-
<<~TEXT
|
165
|
-
#{BLANK_HDR}
|
166
|
-
<sections>
|
167
|
-
<clause id="_" inline-header="false" obligation="normative">
|
168
|
-
<title>Lorem ipsum</title>
|
169
|
-
<p id='_'>dolor sit amet</p>
|
170
|
-
</clause>
|
171
|
-
</sections>
|
172
|
-
</standard-document>
|
173
|
-
TEXT
|
174
|
-
end
|
175
|
-
|
176
|
-
it 'correctly renders input yaml' do
|
177
|
-
expect(
|
178
|
-
xmlpp(
|
179
|
-
strip_guid(
|
180
|
-
Asciidoctor.convert(input,
|
181
|
-
backend: :standoc,
|
182
|
-
header_footer: true),
|
183
|
-
),
|
184
|
-
),
|
185
|
-
).to(be_equivalent_to(xmlpp(output)))
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
context 'A simple hash with free keys' do
|
190
|
-
let(:example_yaml_content) do
|
191
|
-
<<~TEXT
|
192
|
-
---
|
193
|
-
name: Lorem ipsum
|
194
|
-
desc: dolor sit amet
|
195
|
-
TEXT
|
196
|
-
end
|
197
|
-
let(:input) do
|
198
|
-
<<~TEXT
|
199
|
-
= Document title
|
200
|
-
Author
|
201
|
-
:docfile: test.adoc
|
202
|
-
:nodoc:
|
203
|
-
:novalid:
|
204
|
-
:no-isobib:
|
205
|
-
:imagesdir: spec/assets
|
206
|
-
|
207
|
-
[yaml2text,#{example_file},my_item]
|
208
|
-
----
|
209
|
-
{my_item.*,key,EOI}
|
210
|
-
=== {key}
|
211
|
-
|
212
|
-
{my_item[key]}
|
213
|
-
|
214
|
-
{EOI}
|
215
|
-
----
|
216
|
-
TEXT
|
217
|
-
end
|
218
|
-
let(:output) do
|
219
|
-
<<~TEXT
|
220
|
-
#{BLANK_HDR}
|
221
|
-
<sections>
|
222
|
-
<clause id="_" inline-header="false" obligation="normative">
|
223
|
-
<title>name</title>
|
224
|
-
<p id='_'>Lorem ipsum</p>
|
225
|
-
</clause>
|
226
|
-
<clause id='_' inline-header='false' obligation='normative'>
|
227
|
-
<title>desc</title>
|
228
|
-
<p id='_'>dolor sit amet</p>
|
229
|
-
</clause>
|
230
|
-
</sections>
|
231
|
-
</standard-document>
|
232
|
-
TEXT
|
233
|
-
end
|
234
|
-
|
235
|
-
it 'correctly renders input yaml' do
|
236
|
-
expect(
|
237
|
-
xmlpp(
|
238
|
-
strip_guid(
|
239
|
-
Asciidoctor.convert(input,
|
240
|
-
backend: :standoc,
|
241
|
-
header_footer: true),
|
242
|
-
),
|
243
|
-
),
|
244
|
-
).to(be_equivalent_to(xmlpp(output)))
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
|
-
context 'An array of hashes' do
|
249
|
-
let(:example_yaml_content) do
|
250
|
-
<<~TEXT
|
251
|
-
---
|
252
|
-
- name: Lorem
|
253
|
-
desc: ipsum
|
254
|
-
nums: [2]
|
255
|
-
- name: dolor
|
256
|
-
desc: sit
|
257
|
-
nums: []
|
258
|
-
- name: amet
|
259
|
-
desc: lorem
|
260
|
-
nums: [2, 4, 6]
|
261
|
-
TEXT
|
262
|
-
end
|
263
|
-
let(:input) do
|
264
|
-
<<~TEXT
|
265
|
-
= Document title
|
266
|
-
Author
|
267
|
-
:docfile: test.adoc
|
268
|
-
:nodoc:
|
269
|
-
:novalid:
|
270
|
-
:no-isobib:
|
271
|
-
:imagesdir: spec/assets
|
272
|
-
|
273
|
-
[yaml2text,#{example_file},ar]
|
274
|
-
----
|
275
|
-
{ar.*,item,EOF}
|
276
|
-
|
277
|
-
{item.name}:: {item.desc}
|
278
|
-
|
279
|
-
{item.nums.*,num,EON}
|
280
|
-
- {item.name}: {num}
|
281
|
-
{EON}
|
282
|
-
|
283
|
-
{EOF}
|
284
|
-
----
|
285
|
-
TEXT
|
286
|
-
end
|
287
|
-
let(:output) do
|
288
|
-
<<~TEXT
|
289
|
-
#{BLANK_HDR}
|
290
|
-
<sections>
|
291
|
-
<dl id='_'>
|
292
|
-
<dt>Lorem</dt>
|
293
|
-
<dd>
|
294
|
-
<p id='_'>ipsum</p>
|
295
|
-
<ul id='_'>
|
296
|
-
<li>
|
297
|
-
<p id='_'>Lorem: 2</p>
|
298
|
-
</li>
|
299
|
-
</ul>
|
300
|
-
</dd>
|
301
|
-
<dt>dolor</dt>
|
302
|
-
<dd>
|
303
|
-
<p id='_'>sit</p>
|
304
|
-
</dd>
|
305
|
-
<dt>amet</dt>
|
306
|
-
<dd>
|
307
|
-
<p id='_'>lorem</p>
|
308
|
-
<ul id='_'>
|
309
|
-
<li>
|
310
|
-
<p id='_'>amet: 2</p>
|
311
|
-
</li>
|
312
|
-
<li>
|
313
|
-
<p id='_'>amet: 4</p>
|
314
|
-
</li>
|
315
|
-
<li>
|
316
|
-
<p id='_'>amet: 6</p>
|
317
|
-
</li>
|
318
|
-
</ul>
|
319
|
-
</dd>
|
320
|
-
</dl>
|
321
|
-
</sections>
|
322
|
-
</standard-document>
|
323
|
-
TEXT
|
324
|
-
end
|
325
|
-
|
326
|
-
it 'correctly renders input yaml' do
|
327
|
-
expect(
|
328
|
-
xmlpp(
|
329
|
-
strip_guid(
|
330
|
-
Asciidoctor.convert(input,
|
331
|
-
backend: :standoc,
|
332
|
-
header_footer: true),
|
333
|
-
),
|
334
|
-
),
|
335
|
-
).to(be_equivalent_to(xmlpp(output)))
|
336
|
-
end
|
337
|
-
end
|
338
|
-
|
339
|
-
context "An array with interpolated file names, etc. \
|
340
|
-
for Asciidoc's consumption" do
|
341
|
-
let(:example_yaml_content) do
|
342
|
-
<<~TEXT
|
343
|
-
---
|
344
|
-
prefix: doc-
|
345
|
-
items:
|
346
|
-
- lorem
|
347
|
-
- ipsum
|
348
|
-
- dolor
|
349
|
-
TEXT
|
350
|
-
end
|
351
|
-
let(:input) do
|
352
|
-
<<~TEXT
|
353
|
-
= Document title
|
354
|
-
Author
|
355
|
-
:docfile: test.adoc
|
356
|
-
:nodoc:
|
357
|
-
:novalid:
|
358
|
-
:no-isobib:
|
359
|
-
:imagesdir: spec/assets
|
360
|
-
|
361
|
-
[yaml2text,#{example_file},yaml]
|
362
|
-
------
|
363
|
-
First item is {yaml.items[0]}.
|
364
|
-
Last item is {yaml.items[-1]}.
|
365
|
-
|
366
|
-
{yaml.items.*,s,EOS}
|
367
|
-
=== {s.#} -> {s.# + 1} {s} == {yaml.items[s.#]}
|
368
|
-
|
369
|
-
[source,ruby]
|
370
|
-
----
|
371
|
-
include::{yaml.prefix}{s.#}.rb[]
|
372
|
-
----
|
373
|
-
|
374
|
-
{EOS}
|
375
|
-
------
|
376
|
-
TEXT
|
377
|
-
end
|
378
|
-
let(:output) do
|
379
|
-
<<~TEXT
|
380
|
-
#{BLANK_HDR}
|
381
|
-
<preface>
|
382
|
-
<foreword id='_' obligation='informative'>
|
383
|
-
<title>Foreword</title>
|
384
|
-
<p id='_'>First item is lorem. Last item is dolor.</p>
|
385
|
-
</foreword>
|
386
|
-
</preface>
|
387
|
-
<sections>
|
388
|
-
<clause id='_' inline-header='false' obligation='normative'>
|
389
|
-
<title>0 → 1 lorem == lorem</title>
|
390
|
-
<sourcecode lang='ruby' id='_'>link:doc-0.rb[]</sourcecode>
|
391
|
-
</clause>
|
392
|
-
<clause id='_' inline-header='false' obligation='normative'>
|
393
|
-
<title>1 → 2 ipsum == ipsum</title>
|
394
|
-
<sourcecode lang='ruby' id='_'>link:doc-1.rb[]</sourcecode>
|
395
|
-
</clause>
|
396
|
-
<clause id='_' inline-header='false' obligation='normative'>
|
397
|
-
<title>2 → 3 dolor == dolor</title>
|
398
|
-
<sourcecode lang='ruby' id='_'>link:doc-2.rb[]</sourcecode>
|
399
|
-
</clause>
|
400
|
-
</sections>
|
401
|
-
</standard-document>
|
402
|
-
TEXT
|
403
|
-
end
|
404
|
-
|
405
|
-
# TODO: fix frozen string error
|
406
|
-
xit 'correctly renders input yaml' do
|
407
|
-
expect(
|
408
|
-
xmlpp(
|
409
|
-
strip_guid(
|
410
|
-
Asciidoctor.convert(input,
|
411
|
-
backend: :standoc,
|
412
|
-
header_footer: true),
|
413
|
-
),
|
414
|
-
),
|
415
|
-
).to(be_equivalent_to(xmlpp(output)))
|
416
|
-
end
|
417
|
-
end
|
418
|
-
|
419
|
-
context "Array of language codes" do
|
420
|
-
let(:input) do
|
421
|
-
<<~TEXT
|
422
|
-
= Document title
|
423
|
-
Author
|
424
|
-
:docfile: test.adoc
|
425
|
-
:nodoc:
|
426
|
-
:novalid:
|
427
|
-
:no-isobib:
|
428
|
-
:imagesdir: spec/assets
|
429
|
-
|
430
|
-
[yaml2text,#{File.expand_path('../assets/codes.yml', __dir__)},ar]
|
431
|
-
----
|
432
|
-
{ar.*,item,EOF}
|
433
|
-
.{item.values[1]}
|
434
|
-
[%noheader,cols="h,1"]
|
435
|
-
|===
|
436
|
-
{item.*,key,EOK}
|
437
|
-
| {key} | {item[key]}
|
438
|
-
|
439
|
-
{EOK}
|
440
|
-
|===
|
441
|
-
{EOF}
|
442
|
-
----
|
443
|
-
TEXT
|
444
|
-
end
|
445
|
-
let(:output) do
|
446
|
-
<<~TEXT
|
447
|
-
#{BLANK_HDR}
|
448
|
-
<sections>
|
449
|
-
#{File.read(File.expand_path('../examples/codes_table.html', __dir__))}
|
450
|
-
</sections>
|
451
|
-
</standard-document>
|
452
|
-
TEXT
|
453
|
-
end
|
454
|
-
|
455
|
-
it 'correctly renders input yaml' do
|
456
|
-
expect(
|
457
|
-
xmlpp(
|
458
|
-
strip_guid(
|
459
|
-
Asciidoctor.convert(input,
|
460
|
-
backend: :standoc,
|
461
|
-
header_footer: true),
|
462
|
-
),
|
463
|
-
),
|
464
|
-
).to(be_equivalent_to(xmlpp(output)))
|
465
|
-
end
|
466
|
-
end
|
467
|
-
|
468
|
-
context "Nested hash dot notation" do
|
469
|
-
let(:example_yaml_content) do
|
470
|
-
<<~TEXT
|
471
|
-
data:
|
472
|
-
acadsin-zho-hani-latn-2002:
|
473
|
-
code: acadsin-zho-hani-latn-2002
|
474
|
-
name:
|
475
|
-
en: Academica Sinica -- Chinese Tongyong Pinyin (2002)
|
476
|
-
authority: acadsin
|
477
|
-
lang:
|
478
|
-
system: iso-639-2
|
479
|
-
code: zho
|
480
|
-
source_script: Hani
|
481
|
-
target_script: Latn
|
482
|
-
system:
|
483
|
-
id: '2002'
|
484
|
-
specification: Academica Sinica -- Chinese Tongyong Pinyin (2002)
|
485
|
-
notes: 'NOTE: OGC 11-122r1 code `zho_Hani2Latn_AcadSin_2002`'
|
486
|
-
TEXT
|
487
|
-
end
|
488
|
-
let(:input) do
|
489
|
-
<<~TEXT
|
490
|
-
= Document title
|
491
|
-
Author
|
492
|
-
:docfile: test.adoc
|
493
|
-
:nodoc:
|
494
|
-
:novalid:
|
495
|
-
:no-isobib:
|
496
|
-
:imagesdir: spec/assets
|
497
|
-
|
498
|
-
[yaml2text,#{example_file},authorities]
|
499
|
-
----
|
500
|
-
[cols="a,a,a,a",options="header"]
|
501
|
-
|===
|
502
|
-
| Script conversion system authority code | Name in English | Notes | Name en
|
503
|
-
|
504
|
-
{authorities.data.*,key,EOI}
|
505
|
-
| {key} | {authorities.data[key]['code']} | {authorities.data[key]['notes']} | {authorities.data[key].name.en}
|
506
|
-
{EOI}
|
507
|
-
|
508
|
-
|===
|
509
|
-
----
|
510
|
-
TEXT
|
511
|
-
end
|
512
|
-
let(:output) do
|
513
|
-
<<~TEXT
|
514
|
-
#{BLANK_HDR}
|
515
|
-
<sections>
|
516
|
-
<table id='_'>
|
517
|
-
<thead>
|
518
|
-
<tr>
|
519
|
-
<th align='left'>Script conversion system authority code</th>
|
520
|
-
<th align='left'>Name in English</th>
|
521
|
-
<th align='left'>Notes</th>
|
522
|
-
<th align='left'>Name en</th>
|
523
|
-
</tr>
|
524
|
-
</thead>
|
525
|
-
<tbody>
|
526
|
-
<tr>
|
527
|
-
<td align='left'>
|
528
|
-
<p id='_'>acadsin-zho-hani-latn-2002</p>
|
529
|
-
</td>
|
530
|
-
<td align='left'>
|
531
|
-
<p id='_'>acadsin-zho-hani-latn-2002</p>
|
532
|
-
</td>
|
533
|
-
<td align='left'>
|
534
|
-
<note id='_'>
|
535
|
-
<p id='_'>
|
536
|
-
OGC 11-122r1 code
|
537
|
-
<tt>zho_Hani2Latn_AcadSin_2002</tt>
|
538
|
-
</p>
|
539
|
-
</note>
|
540
|
-
</td>
|
541
|
-
<td align='left'>
|
542
|
-
<p id='_'>Academica Sinica — Chinese Tongyong Pinyin (2002)</p>
|
543
|
-
</td>
|
544
|
-
</tr>
|
545
|
-
</tbody>
|
546
|
-
</table>
|
547
|
-
</sections>
|
548
|
-
</standard-document>
|
549
|
-
TEXT
|
550
|
-
end
|
551
|
-
|
552
|
-
it 'correctly renders input yaml' do
|
553
|
-
expect(
|
554
|
-
xmlpp(
|
555
|
-
strip_guid(
|
556
|
-
Asciidoctor.convert(input,
|
557
|
-
backend: :standoc,
|
558
|
-
header_footer: true),
|
559
|
-
),
|
560
|
-
),
|
561
|
-
).to(be_equivalent_to(xmlpp(output)))
|
562
|
-
end
|
3
|
+
RSpec.describe 'Yaml2Text macros' do
|
4
|
+
it_behaves_like "structured data 2 text preprocessor" do
|
5
|
+
let(:extention) { "yaml" }
|
6
|
+
def transform_to_type(data)
|
7
|
+
data.to_yaml
|
563
8
|
end
|
564
9
|
end
|
565
10
|
end
|