metanorma-standoc 1.5.2 → 1.5.3
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.
- checksums.yaml +4 -4
- data/lib/asciidoctor/standoc/base_structured_text_preprocessor.rb +123 -0
- data/lib/asciidoctor/standoc/basicdoc.rng +31 -1
- data/lib/asciidoctor/standoc/cleanup.rb +1 -0
- data/lib/asciidoctor/standoc/cleanup_amend.rb +54 -0
- data/lib/asciidoctor/standoc/cleanup_block.rb +0 -2
- data/lib/asciidoctor/standoc/cleanup_footnotes.rb +0 -3
- data/lib/asciidoctor/standoc/cleanup_inline.rb +6 -1
- data/lib/asciidoctor/standoc/cleanup_section.rb +1 -2
- data/lib/asciidoctor/standoc/converter.rb +3 -1
- data/lib/asciidoctor/standoc/front_contributor.rb +15 -7
- data/lib/asciidoctor/standoc/inline.rb +13 -1
- data/lib/asciidoctor/standoc/isodoc.rng +108 -8
- data/lib/asciidoctor/standoc/json2_text_preprocessor.rb +43 -0
- data/lib/asciidoctor/standoc/macros.rb +45 -33
- data/lib/asciidoctor/standoc/section.rb +8 -3
- data/lib/asciidoctor/standoc/table.rb +3 -2
- data/lib/asciidoctor/standoc/views/datamodel/model_representation.adoc.erb +10 -10
- data/lib/asciidoctor/standoc/yaml2_text_preprocessor.rb +43 -0
- data/lib/liquid/custom_blocks/key_iterator.rb +21 -0
- data/lib/liquid/custom_filters/values.rb +7 -0
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +1 -3
- data/spec/asciidoctor-standoc/blocks_spec.rb +254 -142
- data/spec/asciidoctor-standoc/cleanup_spec.rb +31 -31
- data/spec/asciidoctor-standoc/macros_json2text_spec.rb +10 -0
- data/spec/asciidoctor-standoc/macros_spec.rb +2 -0
- data/spec/asciidoctor-standoc/macros_yaml2text_spec.rb +5 -560
- data/spec/asciidoctor-standoc/section_spec.rb +0 -1
- data/spec/asciidoctor-standoc/table_spec.rb +112 -112
- data/spec/asciidoctor-standoc/validate_spec.rb +5 -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 +110 -109
- data/spec/support/shared_examples/structured_data_2_text_preprocessor.rb +583 -0
- metadata +24 -3
- data/lib/asciidoctor/standoc/macros_yaml2text.rb +0 -165
@@ -708,9 +708,9 @@ end
|
|
708
708
|
<sections><table id="_">
|
709
709
|
<tbody>
|
710
710
|
<tr>
|
711
|
-
<td align="left">a</td>
|
712
|
-
<td align="left">b</td>
|
713
|
-
<td align="left">c</td>
|
711
|
+
<td valign="top" align="left">a</td>
|
712
|
+
<td valign="top" align="left">b</td>
|
713
|
+
<td valign="top" align="left">c</td>
|
714
714
|
</tr>
|
715
715
|
</tbody>
|
716
716
|
<dl id="_">
|
@@ -739,23 +739,23 @@ end
|
|
739
739
|
#{BLANK_HDR}
|
740
740
|
<sections>
|
741
741
|
<table id="_"><thead><tr>
|
742
|
-
<th align="left">a</th>
|
743
|
-
<th align="left">b</th>
|
744
|
-
<th align="left">c</th>
|
742
|
+
<th valign="top" align="left">a</th>
|
743
|
+
<th valign="top" align="left">b</th>
|
744
|
+
<th valign="top" align="left">c</th>
|
745
745
|
</tr><tr>
|
746
|
-
<th align="left">a</th>
|
747
|
-
<th align="left">b</th>
|
748
|
-
<th align="left">c</th>
|
746
|
+
<th valign="top" align="left">a</th>
|
747
|
+
<th valign="top" align="left">b</th>
|
748
|
+
<th valign="top" align="left">c</th>
|
749
749
|
</tr><tr>
|
750
|
-
<th align="left">a</th>
|
751
|
-
<th align="left">b</th>
|
752
|
-
<th align="left">c</th>
|
750
|
+
<th valign="top" align="left">a</th>
|
751
|
+
<th valign="top" align="left">b</th>
|
752
|
+
<th valign="top" align="left">c</th>
|
753
753
|
</tr></thead>
|
754
754
|
<tbody>
|
755
755
|
<tr>
|
756
|
-
<td align="left">a</td>
|
757
|
-
<td align="left">b</td>
|
758
|
-
<td align="left">c</td>
|
756
|
+
<td valign="top" align="left">a</td>
|
757
|
+
<td valign="top" align="left">b</td>
|
758
|
+
<td valign="top" align="left">c</td>
|
759
759
|
</tr>
|
760
760
|
</tbody>
|
761
761
|
</table>
|
@@ -781,26 +781,26 @@ end
|
|
781
781
|
<table id="_">
|
782
782
|
<thead>
|
783
783
|
<tr>
|
784
|
-
<th align="left">a</th>
|
785
|
-
<th align="left">b</th>
|
786
|
-
<th align="left">c</th>
|
784
|
+
<th valign="top" align="left">a</th>
|
785
|
+
<th valign="top" align="left">b</th>
|
786
|
+
<th valign="top" align="left">c</th>
|
787
787
|
</tr>
|
788
788
|
<tr>
|
789
|
-
<th align="left">a</th>
|
790
|
-
<th align="left">b</th>
|
791
|
-
<th align="left">c</th>
|
789
|
+
<th valign="top" align="left">a</th>
|
790
|
+
<th valign="top" align="left">b</th>
|
791
|
+
<th valign="top" align="left">c</th>
|
792
792
|
</tr><tr>
|
793
|
-
<th align="left">a</th>
|
794
|
-
<th align="left">b</th>
|
795
|
-
<th align="left">c</th>
|
793
|
+
<th valign="top" align="left">a</th>
|
794
|
+
<th valign="top" align="left">b</th>
|
795
|
+
<th valign="top" align="left">c</th>
|
796
796
|
</tr></thead>
|
797
797
|
<tbody>
|
798
798
|
|
799
799
|
|
800
800
|
<tr>
|
801
|
-
<td align="left">a</td>
|
802
|
-
<td align="left">b</td>
|
803
|
-
<td align="left">c</td>
|
801
|
+
<td valign="top" align="left">a</td>
|
802
|
+
<td valign="top" align="left">b</td>
|
803
|
+
<td valign="top" align="left">c</td>
|
804
804
|
</tr>
|
805
805
|
</tbody>
|
806
806
|
</table>
|
@@ -824,9 +824,9 @@ end
|
|
824
824
|
<sections><table id="_">
|
825
825
|
<tbody>
|
826
826
|
<tr>
|
827
|
-
<td align="left">a</td>
|
828
|
-
<td align="left">b</td>
|
829
|
-
<td align="left">c</td>
|
827
|
+
<td valign="top" align="left">a</td>
|
828
|
+
<td valign="top" align="left">b</td>
|
829
|
+
<td valign="top" align="left">c</td>
|
830
830
|
</tr>
|
831
831
|
</tbody>
|
832
832
|
<note id="_">
|
@@ -2646,7 +2646,7 @@ INPUT
|
|
2646
2646
|
</clause>
|
2647
2647
|
</clause>
|
2648
2648
|
<definitions id='_' obligation='normative'>
|
2649
|
-
<title>
|
2649
|
+
<title>Symboles et termes abrégés</title>
|
2650
2650
|
<clause id='_' inline-header='false' obligation='normative'>
|
2651
2651
|
<title>General</title>
|
2652
2652
|
</clause>
|
@@ -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>
|
@@ -1,565 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
RSpec.describe Asciidoctor::Standoc::Yaml2TextPreprocessor do
|
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
|
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
|