metanorma-standoc 2.2.0.1 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/metanorma/standoc/base.rb +12 -0
- data/lib/metanorma/standoc/blocks.rb +26 -13
- data/lib/metanorma/standoc/cleanup_biblio.rb +14 -8
- data/lib/metanorma/standoc/cleanup_reqt.rb +3 -136
- data/lib/metanorma/standoc/front_contributor.rb +0 -10
- data/lib/metanorma/standoc/reqt.rb +19 -75
- data/lib/metanorma/standoc/section.rb +35 -3
- data/lib/metanorma/standoc/utils.rb +9 -43
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +2 -2
- data/spec/metanorma/biblio_spec.rb +8 -8
- data/spec/metanorma/blocks_spec.rb +20 -266
- data/spec/metanorma/cleanup_blocks_spec.rb +0 -168
- data/spec/metanorma/macros_concept_spec.rb +1033 -0
- data/spec/metanorma/macros_spec.rb +0 -1030
- data/spec/metanorma/reqt_spec.rb +130 -0
- data/spec/metanorma/section_spec.rb +5 -0
- data/spec/vcr_cassettes/bsi16341.yml +52 -36
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +88 -88
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +10 -10
- data/spec/vcr_cassettes/hide_refs.yml +65 -65
- data/spec/vcr_cassettes/isobib_get_123.yml +12 -12
- data/spec/vcr_cassettes/isobib_get_123_1.yml +22 -22
- data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +30 -30
- data/spec/vcr_cassettes/isobib_get_123_2.yml +21 -21
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +11 -11
- data/spec/vcr_cassettes/isobib_get_124.yml +11 -11
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +34 -58
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +45 -45
- data/spec/vcr_cassettes/std-link.yml +11 -11
- metadata +9 -7
@@ -0,0 +1,1033 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Metanorma::Standoc do
|
4
|
+
it "processes the Metanorma::Standoc concept and related macros" do
|
5
|
+
input = <<~INPUT
|
6
|
+
#{ASCIIDOC_BLANK_HDR}
|
7
|
+
|
8
|
+
{{clause1}}
|
9
|
+
term:[clause1]
|
10
|
+
{{clause1,w\[o\]rd}}
|
11
|
+
term:[clause1,w[o]rd]
|
12
|
+
{{clause1,w\[o\]rd,term}}
|
13
|
+
{{blah}}
|
14
|
+
term:[blah]
|
15
|
+
{{blah,word}}
|
16
|
+
term:[blah,word]
|
17
|
+
{{blah,term,word}}
|
18
|
+
{{blah,term,word,xref}}
|
19
|
+
{{blah,term,word,xref,options="noital,noref,nolinkmention,nolinkref"}}
|
20
|
+
{{blah,term,word,xref,options="ital,ref,linkmention,linkref"}}
|
21
|
+
|
22
|
+
related:contrast[blah]
|
23
|
+
|
24
|
+
[[clause1]]
|
25
|
+
== Clause
|
26
|
+
Terms are defined here
|
27
|
+
INPUT
|
28
|
+
output = <<~OUTPUT
|
29
|
+
#{BLANK_HDR}
|
30
|
+
<preface>
|
31
|
+
<foreword id='_' obligation='informative'>
|
32
|
+
<title>Foreword</title>
|
33
|
+
<p id='_'>
|
34
|
+
<concept>
|
35
|
+
<strong>
|
36
|
+
term
|
37
|
+
<tt>clause1</tt>
|
38
|
+
not resolved via ID
|
39
|
+
<tt>clause1</tt>
|
40
|
+
</strong>
|
41
|
+
</concept>
|
42
|
+
<concept>
|
43
|
+
<strong>
|
44
|
+
term
|
45
|
+
<tt>clause1</tt>
|
46
|
+
not resolved via ID
|
47
|
+
<tt>clause1</tt>
|
48
|
+
</strong>
|
49
|
+
</concept>
|
50
|
+
<concept>
|
51
|
+
<strong>
|
52
|
+
term
|
53
|
+
<tt>clause1</tt>, display <tt>w[o]rd</tt>
|
54
|
+
not resolved via ID
|
55
|
+
<tt>clause1</tt>
|
56
|
+
</strong>
|
57
|
+
</concept>
|
58
|
+
<concept>
|
59
|
+
<strong>
|
60
|
+
term
|
61
|
+
<tt>clause1</tt>, display <tt>w[o]rd</tt>
|
62
|
+
not resolved via ID
|
63
|
+
<tt>clause1</tt>
|
64
|
+
</strong>
|
65
|
+
</concept>
|
66
|
+
<concept>
|
67
|
+
<strong>
|
68
|
+
term
|
69
|
+
<tt>clause1</tt>, display <tt>w[o]rd</tt>
|
70
|
+
not resolved via ID
|
71
|
+
<tt>clause1</tt>
|
72
|
+
</strong>
|
73
|
+
</concept>
|
74
|
+
<concept>
|
75
|
+
<strong>
|
76
|
+
term
|
77
|
+
<tt>blah</tt>
|
78
|
+
not resolved via ID
|
79
|
+
<tt>blah</tt>
|
80
|
+
</strong>
|
81
|
+
</concept>
|
82
|
+
<concept>
|
83
|
+
<strong>
|
84
|
+
term
|
85
|
+
<tt>blah</tt>
|
86
|
+
not resolved via ID
|
87
|
+
<tt>blah</tt>
|
88
|
+
</strong>
|
89
|
+
</concept>
|
90
|
+
<concept>
|
91
|
+
<strong>
|
92
|
+
term
|
93
|
+
<tt>blah</tt>
|
94
|
+
, display
|
95
|
+
<tt>word</tt>
|
96
|
+
not resolved via ID
|
97
|
+
<tt>blah</tt>
|
98
|
+
</strong>
|
99
|
+
</concept>
|
100
|
+
<concept>
|
101
|
+
<strong>
|
102
|
+
term
|
103
|
+
<tt>blah</tt>
|
104
|
+
, display
|
105
|
+
<tt>word</tt>
|
106
|
+
not resolved via ID
|
107
|
+
<tt>blah</tt>
|
108
|
+
</strong>
|
109
|
+
</concept>
|
110
|
+
<concept>
|
111
|
+
<strong>
|
112
|
+
term
|
113
|
+
<tt>blah</tt>
|
114
|
+
, display
|
115
|
+
<tt>term</tt>
|
116
|
+
not resolved via ID
|
117
|
+
<tt>blah</tt>
|
118
|
+
</strong>
|
119
|
+
</concept>
|
120
|
+
<concept>
|
121
|
+
<strong>
|
122
|
+
term
|
123
|
+
<tt>blah</tt>
|
124
|
+
, display
|
125
|
+
<tt>term</tt>
|
126
|
+
not resolved via ID
|
127
|
+
<tt>blah</tt>
|
128
|
+
</strong>
|
129
|
+
</concept>
|
130
|
+
<concept ital='false' ref='false' linkmention='false' linkref='false'>
|
131
|
+
<strong>
|
132
|
+
term
|
133
|
+
<tt>blah</tt>
|
134
|
+
, display
|
135
|
+
<tt>term</tt>
|
136
|
+
not resolved via ID
|
137
|
+
<tt>blah</tt>
|
138
|
+
</strong>
|
139
|
+
</concept>
|
140
|
+
<concept ital='true' ref='true' linkmention='true' linkref='true'>
|
141
|
+
<strong>
|
142
|
+
term
|
143
|
+
<tt>blah</tt>
|
144
|
+
, display
|
145
|
+
<tt>term</tt>
|
146
|
+
not resolved via ID
|
147
|
+
<tt>blah</tt>
|
148
|
+
</strong>
|
149
|
+
</concept>
|
150
|
+
</p>
|
151
|
+
<related type='contrast'>
|
152
|
+
<strong>
|
153
|
+
term
|
154
|
+
<tt>blah</tt>
|
155
|
+
not resolved via ID
|
156
|
+
<tt>blah</tt>
|
157
|
+
</strong>
|
158
|
+
</related>
|
159
|
+
</foreword>
|
160
|
+
</preface>
|
161
|
+
<sections>
|
162
|
+
<clause id='clause1' inline-header='false' obligation='normative'>
|
163
|
+
<title>Clause</title>
|
164
|
+
<p id='_'>Terms are defined here</p>
|
165
|
+
</clause>
|
166
|
+
</sections>
|
167
|
+
</standard-document>
|
168
|
+
OUTPUT
|
169
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
170
|
+
.to be_equivalent_to xmlpp(output)
|
171
|
+
end
|
172
|
+
|
173
|
+
it "processes the Metanorma::Standoc concept macros for acronyms" do
|
174
|
+
input = <<~INPUT
|
175
|
+
#{ASCIIDOC_BLANK_HDR}
|
176
|
+
|
177
|
+
{{Clause1}}
|
178
|
+
{{Clause1,Clause 1}}
|
179
|
+
{{Clause 2}}
|
180
|
+
{{Clause 2,Clause 1}}
|
181
|
+
{{<<Clause2>>,Clause 2}}
|
182
|
+
|
183
|
+
symbol:[Clause1]
|
184
|
+
symbol:[Clause1,word]
|
185
|
+
symbol:[Clause 2]
|
186
|
+
symbol:[Clause 2,word]
|
187
|
+
|
188
|
+
{{<<Clause2>>,word}}
|
189
|
+
{{<<Clause2>>,word,term}}
|
190
|
+
{{<<Clause2>>,word,term,xref}}
|
191
|
+
{{<<Clause2>>,word,term,xref,options="noital,noref,nolinkmention,nolinkref"}}
|
192
|
+
{{<<Clause2>>,word,term,xref,options="ital,ref,linkmention,linkref"}}
|
193
|
+
|
194
|
+
== Terms and definitions
|
195
|
+
=== Clause1
|
196
|
+
== Symbols and Abbreviated Terms
|
197
|
+
Clause1:: A
|
198
|
+
[[Clause2]]Clause 2:: C
|
199
|
+
INPUT
|
200
|
+
output = <<~OUTPUT
|
201
|
+
#{BLANK_HDR}
|
202
|
+
<preface>
|
203
|
+
<foreword id='_' obligation='informative'>
|
204
|
+
<title>Foreword</title>
|
205
|
+
<p id='_'>
|
206
|
+
<concept>
|
207
|
+
<refterm>Clause1</refterm>
|
208
|
+
<renderterm>Clause1</renderterm>
|
209
|
+
<xref target='term-Clause1'/>
|
210
|
+
</concept>
|
211
|
+
<concept>
|
212
|
+
<refterm>Clause1</refterm>
|
213
|
+
<renderterm>Clause 1</renderterm>
|
214
|
+
<xref target='term-Clause1'/>
|
215
|
+
</concept>
|
216
|
+
<concept>
|
217
|
+
<refterm>Clause 2</refterm>
|
218
|
+
<renderterm>Clause 2</renderterm>
|
219
|
+
<xref target='Clause2'/>
|
220
|
+
</concept>
|
221
|
+
<concept>
|
222
|
+
<refterm>Clause 2</refterm>
|
223
|
+
<renderterm>Clause 1</renderterm>
|
224
|
+
<xref target='Clause2'/>
|
225
|
+
</concept>
|
226
|
+
<concept>
|
227
|
+
<refterm>Clause 2</refterm>
|
228
|
+
<renderterm>Clause 2</renderterm>
|
229
|
+
<xref target='Clause2'/>
|
230
|
+
</concept>
|
231
|
+
</p><p id="_">
|
232
|
+
<concept>
|
233
|
+
<refterm>Clause1</refterm>
|
234
|
+
<renderterm>Clause1</renderterm>
|
235
|
+
<xref target='symbol-Clause1'/>
|
236
|
+
</concept>
|
237
|
+
<concept>
|
238
|
+
<refterm>Clause1</refterm>
|
239
|
+
<renderterm>word</renderterm>
|
240
|
+
<xref target='symbol-Clause1'/>
|
241
|
+
</concept>
|
242
|
+
<concept>
|
243
|
+
<refterm>Clause 2</refterm>
|
244
|
+
<renderterm>Clause 2</renderterm>
|
245
|
+
<xref target='Clause2'/>
|
246
|
+
</concept>
|
247
|
+
<concept>
|
248
|
+
<refterm>Clause 2</refterm>
|
249
|
+
<renderterm>word</renderterm>
|
250
|
+
<xref target='Clause2'/>
|
251
|
+
</concept>
|
252
|
+
</p><p id="_">
|
253
|
+
<concept>
|
254
|
+
<refterm>word</refterm>
|
255
|
+
<renderterm>word</renderterm>
|
256
|
+
<xref target='Clause2'/>
|
257
|
+
</concept>
|
258
|
+
<concept>
|
259
|
+
<refterm>word</refterm>
|
260
|
+
<renderterm>term</renderterm>
|
261
|
+
<xref target='Clause2'/>
|
262
|
+
</concept>
|
263
|
+
<concept>
|
264
|
+
<refterm>word</refterm>
|
265
|
+
<renderterm>term</renderterm>
|
266
|
+
<xref target='Clause2'>xref</xref>
|
267
|
+
</concept>
|
268
|
+
<concept ital='false' ref='false' linkmention='false' linkref='false'>
|
269
|
+
<refterm>word</refterm>
|
270
|
+
<renderterm>term</renderterm>
|
271
|
+
<xref target='Clause2'>xref</xref>
|
272
|
+
</concept>
|
273
|
+
<concept ital='true' ref='true' linkmention='true' linkref='true'>
|
274
|
+
<refterm>word</refterm>
|
275
|
+
<renderterm>term</renderterm>
|
276
|
+
<xref target='Clause2'>xref</xref>
|
277
|
+
</concept>
|
278
|
+
</p>
|
279
|
+
</foreword>
|
280
|
+
</preface>
|
281
|
+
<sections>
|
282
|
+
<terms id='_' obligation='normative'>
|
283
|
+
<title>Terms and definitions</title>
|
284
|
+
<p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
|
285
|
+
<term id='term-Clause1'>
|
286
|
+
<preferred><expression><name>Clause1</name></expression></preferred>
|
287
|
+
</term>
|
288
|
+
</terms>
|
289
|
+
<definitions id='_' obligation='normative'>
|
290
|
+
<title>Symbols and abbreviated terms</title>
|
291
|
+
<dl id='_'>
|
292
|
+
<dt id="symbol-Clause1">Clause1</dt>
|
293
|
+
<dd>
|
294
|
+
<p id='_'>A</p>
|
295
|
+
</dd>
|
296
|
+
<dt id='Clause2'>Clause 2</dt>
|
297
|
+
<dd>
|
298
|
+
<p id='_'>C</p>
|
299
|
+
</dd>
|
300
|
+
</dl>
|
301
|
+
</definitions>
|
302
|
+
</sections>
|
303
|
+
</standard-document>
|
304
|
+
OUTPUT
|
305
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
306
|
+
.to be_equivalent_to xmlpp(output)
|
307
|
+
end
|
308
|
+
|
309
|
+
it "processes the concept and related macros with xrefs" do
|
310
|
+
input = <<~INPUT
|
311
|
+
#{ASCIIDOC_BLANK_HDR}
|
312
|
+
{{<<clause1>>}}
|
313
|
+
{{<<clause1>>,w\[o\]rd}}
|
314
|
+
{{<<clause1>>,term,w\[o\]rd}}
|
315
|
+
{{<<clause1>>,term,w\[o\]rd,Clause #1}}
|
316
|
+
|
317
|
+
related:supersedes[<<clause1>>,term]
|
318
|
+
|
319
|
+
[[clause1]]
|
320
|
+
== Clause
|
321
|
+
Terms are defined here
|
322
|
+
INPUT
|
323
|
+
output = <<~OUTPUT
|
324
|
+
#{BLANK_HDR}
|
325
|
+
<preface>
|
326
|
+
<foreword id='_' obligation='informative'>
|
327
|
+
<title>Foreword</title>
|
328
|
+
<p id='_'>
|
329
|
+
<concept>
|
330
|
+
<xref target='clause1'/>
|
331
|
+
</concept>
|
332
|
+
<concept>
|
333
|
+
<refterm>w[o]rd</refterm>
|
334
|
+
<renderterm>w[o]rd</renderterm>
|
335
|
+
<xref target='clause1'/>
|
336
|
+
</concept>
|
337
|
+
<concept>
|
338
|
+
<refterm>term</refterm>
|
339
|
+
<renderterm>w[o]rd</renderterm>
|
340
|
+
<xref target='clause1'/>
|
341
|
+
</concept>
|
342
|
+
<concept>
|
343
|
+
<refterm>term</refterm>
|
344
|
+
<renderterm>w[o]rd</renderterm>
|
345
|
+
<xref target='clause1'>Clause #1</xref>
|
346
|
+
</concept>
|
347
|
+
</p>
|
348
|
+
<related type='supersedes'>
|
349
|
+
<preferred>
|
350
|
+
<expression>
|
351
|
+
<name>term</name>
|
352
|
+
</expression>
|
353
|
+
</preferred>
|
354
|
+
<xref target='clause1'/>
|
355
|
+
</related>
|
356
|
+
</foreword>
|
357
|
+
</preface>
|
358
|
+
<sections>
|
359
|
+
<clause id='clause1' inline-header='false' obligation='normative'>
|
360
|
+
<title>Clause</title>
|
361
|
+
<p id='_'>Terms are defined here</p>
|
362
|
+
</clause>
|
363
|
+
</sections>
|
364
|
+
</standard-document>
|
365
|
+
OUTPUT
|
366
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
367
|
+
.to be_equivalent_to xmlpp(output)
|
368
|
+
end
|
369
|
+
|
370
|
+
it "processes the concept and related macros with erefs" do
|
371
|
+
input = <<~INPUT
|
372
|
+
#{ASCIIDOC_BLANK_HDR}
|
373
|
+
{{<<blah>>}}
|
374
|
+
{{<<blah>>,word}}
|
375
|
+
{{<<blah>>,term,word}}
|
376
|
+
{{<<blah>>,term,word,Clause #1}}
|
377
|
+
{{<<blah,clause=3.1>>}}
|
378
|
+
{{<<blah,clause=3.1>>,word}}
|
379
|
+
{{<<blah,clause=3.1>>,term,word}}
|
380
|
+
{{<<blah,clause=3.1,figure=a>>}}
|
381
|
+
{{<<blah,clause=3.1,figure=a>>,word}}
|
382
|
+
{{<<blah,clause=3.1,figure=a>>,term,word,Clause #1}}
|
383
|
+
|
384
|
+
related:narrower[<<blah,clause=3.1,figure=a>>,term]
|
385
|
+
|
386
|
+
[bibliography]
|
387
|
+
== Bibliography
|
388
|
+
* [[[blah,blah]]] _Blah_
|
389
|
+
INPUT
|
390
|
+
output = <<~OUTPUT
|
391
|
+
#{BLANK_HDR}
|
392
|
+
<preface>
|
393
|
+
<foreword id='_' obligation='informative'>
|
394
|
+
<title>Foreword</title>
|
395
|
+
<p id='_'>
|
396
|
+
<concept>
|
397
|
+
<eref bibitemid='blah'/>
|
398
|
+
</concept>
|
399
|
+
<concept>
|
400
|
+
<refterm>word</refterm>
|
401
|
+
<renderterm>word</renderterm>
|
402
|
+
<eref bibitemid='blah'/>
|
403
|
+
</concept>
|
404
|
+
<concept>
|
405
|
+
<refterm>term</refterm>
|
406
|
+
<renderterm>word</renderterm>
|
407
|
+
<eref bibitemid='blah'/>
|
408
|
+
</concept>
|
409
|
+
<concept>
|
410
|
+
<refterm>term</refterm>
|
411
|
+
<renderterm>word</renderterm>
|
412
|
+
<eref bibitemid='blah'>Clause #1</eref>
|
413
|
+
</concept>
|
414
|
+
<concept>
|
415
|
+
<eref bibitemid='blah'>
|
416
|
+
<localityStack>
|
417
|
+
<locality type='clause'>
|
418
|
+
<referenceFrom>3.1</referenceFrom>
|
419
|
+
</locality>
|
420
|
+
</localityStack>
|
421
|
+
</eref>
|
422
|
+
</concept>
|
423
|
+
<concept>
|
424
|
+
<refterm>word</refterm>
|
425
|
+
<renderterm>word</renderterm>
|
426
|
+
<eref bibitemid='blah'>
|
427
|
+
<localityStack>
|
428
|
+
<locality type='clause'>
|
429
|
+
<referenceFrom>3.1</referenceFrom>
|
430
|
+
</locality>
|
431
|
+
</localityStack>
|
432
|
+
</eref>
|
433
|
+
</concept>
|
434
|
+
<concept>
|
435
|
+
<refterm>term</refterm>
|
436
|
+
<renderterm>word</renderterm>
|
437
|
+
<eref bibitemid='blah'>
|
438
|
+
<localityStack>
|
439
|
+
<locality type='clause'>
|
440
|
+
<referenceFrom>3.1</referenceFrom>
|
441
|
+
</locality>
|
442
|
+
</localityStack>
|
443
|
+
</eref>
|
444
|
+
</concept>
|
445
|
+
<concept>
|
446
|
+
<eref bibitemid='blah'>
|
447
|
+
<localityStack>
|
448
|
+
<locality type='clause'>
|
449
|
+
<referenceFrom>3.1</referenceFrom>
|
450
|
+
</locality>
|
451
|
+
<locality type='figure'>
|
452
|
+
<referenceFrom>a</referenceFrom>
|
453
|
+
</locality>
|
454
|
+
</localityStack>
|
455
|
+
</eref>
|
456
|
+
</concept>
|
457
|
+
<concept>
|
458
|
+
<refterm>word</refterm>
|
459
|
+
<renderterm>word</renderterm>
|
460
|
+
<eref bibitemid='blah'>
|
461
|
+
<localityStack>
|
462
|
+
<locality type='clause'>
|
463
|
+
<referenceFrom>3.1</referenceFrom>
|
464
|
+
</locality>
|
465
|
+
<locality type='figure'>
|
466
|
+
<referenceFrom>a</referenceFrom>
|
467
|
+
</locality>
|
468
|
+
</localityStack>
|
469
|
+
</eref>
|
470
|
+
</concept>
|
471
|
+
<concept>
|
472
|
+
<refterm>term</refterm>
|
473
|
+
<renderterm>word</renderterm>
|
474
|
+
<eref bibitemid='blah'>
|
475
|
+
<localityStack>
|
476
|
+
<locality type='clause'>
|
477
|
+
<referenceFrom>3.1</referenceFrom>
|
478
|
+
</locality>
|
479
|
+
<locality type='figure'>
|
480
|
+
<referenceFrom>a</referenceFrom>
|
481
|
+
</locality>
|
482
|
+
</localityStack>
|
483
|
+
Clause #1
|
484
|
+
</eref>
|
485
|
+
</concept>
|
486
|
+
</p>
|
487
|
+
<related type='narrower'>
|
488
|
+
<preferred>
|
489
|
+
<expression>
|
490
|
+
<name>term</name>
|
491
|
+
</expression>
|
492
|
+
</preferred>
|
493
|
+
<eref bibitemid='blah'>
|
494
|
+
<localityStack>
|
495
|
+
<locality type='clause'>
|
496
|
+
<referenceFrom>3.1</referenceFrom>
|
497
|
+
</locality>
|
498
|
+
<locality type='figure'>
|
499
|
+
<referenceFrom>a</referenceFrom>
|
500
|
+
</locality>
|
501
|
+
</localityStack>
|
502
|
+
</eref>
|
503
|
+
</related>
|
504
|
+
</foreword>
|
505
|
+
</preface>
|
506
|
+
<sections> </sections>
|
507
|
+
<bibliography>
|
508
|
+
<references id='_' normative='false' obligation='informative'>
|
509
|
+
<title>Bibliography</title>
|
510
|
+
<bibitem id='blah'>
|
511
|
+
<formattedref format='application/x-isodoc+xml'>
|
512
|
+
<em>Blah</em>
|
513
|
+
</formattedref>
|
514
|
+
<docidentifier>blah</docidentifier>
|
515
|
+
</bibitem>
|
516
|
+
</references>
|
517
|
+
</bibliography>
|
518
|
+
</standard-document>
|
519
|
+
OUTPUT
|
520
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
521
|
+
.to be_equivalent_to xmlpp(output)
|
522
|
+
end
|
523
|
+
|
524
|
+
it "processes the concept and related macros with termbase" do
|
525
|
+
input = <<~INPUT
|
526
|
+
#{ASCIIDOC_BLANK_HDR}
|
527
|
+
{{<<IEV:135-13-13>>}}
|
528
|
+
{{<<IEV:135-13-13>>,word}}
|
529
|
+
{{<<IEV:135-13-13>>,term,word}}
|
530
|
+
{{<<IEV:135-13-13>>,term,word,Clause #1}}
|
531
|
+
|
532
|
+
related:see[<<IEV:135-13-13>>,term]
|
533
|
+
INPUT
|
534
|
+
output = <<~OUTPUT
|
535
|
+
#{BLANK_HDR}
|
536
|
+
<sections>
|
537
|
+
<p id='_'>
|
538
|
+
<concept>
|
539
|
+
<termref base='IEV' target='135-13-13'/>
|
540
|
+
</concept>
|
541
|
+
<concept>
|
542
|
+
<refterm>word</refterm>
|
543
|
+
<renderterm>word</renderterm>
|
544
|
+
<termref base='IEV' target='135-13-13'/>
|
545
|
+
</concept>
|
546
|
+
<concept>
|
547
|
+
<refterm>term</refterm>
|
548
|
+
<renderterm>word</renderterm>
|
549
|
+
<termref base='IEV' target='135-13-13'/>
|
550
|
+
</concept>
|
551
|
+
<concept>
|
552
|
+
<refterm>term</refterm>
|
553
|
+
<renderterm>word</renderterm>
|
554
|
+
<termref base='IEV' target='135-13-13'>Clause #1</termref>
|
555
|
+
</concept>
|
556
|
+
</p>
|
557
|
+
<related type='see'>
|
558
|
+
<preferred>
|
559
|
+
<expression>
|
560
|
+
<name>term</name>
|
561
|
+
</expression>
|
562
|
+
</preferred>
|
563
|
+
<termref base='IEV' target='135-13-13'/>
|
564
|
+
</related>
|
565
|
+
</sections>
|
566
|
+
</standard-document>
|
567
|
+
OUTPUT
|
568
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
569
|
+
.to be_equivalent_to xmlpp(output)
|
570
|
+
end
|
571
|
+
|
572
|
+
it "processes the concept macros with disambiguation for math symbols" do
|
573
|
+
input = <<~INPUT
|
574
|
+
#{ASCIIDOC_BLANK_HDR}
|
575
|
+
[[clause1]]
|
576
|
+
|
577
|
+
== Symbols and Abbreviated Terms
|
578
|
+
stem:[|~ x ~|]:: A function that returns the smallest integer greater than or equal to stem:[x]; also known as the _ceiling_ function.
|
579
|
+
stem:[|__ x __|]:: A function that returns the largest integer less than or equal to stem:[x]; also known as the _floor_ function.
|
580
|
+
INPUT
|
581
|
+
output = <<~OUTPUT
|
582
|
+
#{BLANK_HDR}
|
583
|
+
<sections>
|
584
|
+
<definitions id='clause1' obligation='normative'>
|
585
|
+
<title>Symbols and abbreviated terms</title>
|
586
|
+
<dl id='_'>
|
587
|
+
<dt id='symbol-__x230a_-x-__x230b_'>
|
588
|
+
<stem type='MathML'>
|
589
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
590
|
+
<mo>⌊</mo>
|
591
|
+
<mi>x</mi>
|
592
|
+
<mo>⌋</mo>
|
593
|
+
</math>
|
594
|
+
</stem>
|
595
|
+
</dt>
|
596
|
+
<dd>
|
597
|
+
<p id='_'>
|
598
|
+
A function that returns the largest integer less than or equal to
|
599
|
+
<stem type='MathML'>
|
600
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
601
|
+
<mi>x</mi>
|
602
|
+
</math>
|
603
|
+
</stem>
|
604
|
+
; also known as the
|
605
|
+
<em>floor</em>
|
606
|
+
function.
|
607
|
+
</p>
|
608
|
+
</dd>
|
609
|
+
<dt id='symbol-__x2308_-x-__x2309_'>
|
610
|
+
<stem type='MathML'>
|
611
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
612
|
+
<mo>⌈</mo>
|
613
|
+
<mi>x</mi>
|
614
|
+
<mo>⌉</mo>
|
615
|
+
</math>
|
616
|
+
</stem>
|
617
|
+
</dt>
|
618
|
+
<dd>
|
619
|
+
<p id='_'>
|
620
|
+
A function that returns the smallest integer greater than or equal
|
621
|
+
to
|
622
|
+
<stem type='MathML'>
|
623
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
624
|
+
<mi>x</mi>
|
625
|
+
</math>
|
626
|
+
</stem>
|
627
|
+
; also known as the
|
628
|
+
<em>ceiling</em>
|
629
|
+
function.
|
630
|
+
</p>
|
631
|
+
</dd>
|
632
|
+
</dl>
|
633
|
+
</definitions>
|
634
|
+
</sections>
|
635
|
+
</standard-document>
|
636
|
+
OUTPUT
|
637
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
638
|
+
.to be_equivalent_to xmlpp(output)
|
639
|
+
end
|
640
|
+
|
641
|
+
describe "term inline macros" do
|
642
|
+
subject(:convert) do
|
643
|
+
xmlpp(
|
644
|
+
strip_guid(
|
645
|
+
Asciidoctor.convert(
|
646
|
+
input, *OPTIONS
|
647
|
+
),
|
648
|
+
),
|
649
|
+
)
|
650
|
+
end
|
651
|
+
let(:input) do
|
652
|
+
<<~XML
|
653
|
+
#{ASCIIDOC_BLANK_HDR}
|
654
|
+
== Terms and Definitions
|
655
|
+
|
656
|
+
=== name
|
657
|
+
|
658
|
+
== Main
|
659
|
+
|
660
|
+
term:[name,name2] is a term
|
661
|
+
|
662
|
+
{{name,name2}} is a term
|
663
|
+
|
664
|
+
related:equivalent[name]
|
665
|
+
XML
|
666
|
+
end
|
667
|
+
let(:output) do
|
668
|
+
<<~XML
|
669
|
+
#{BLANK_HDR}
|
670
|
+
<sections>
|
671
|
+
<terms id='_' obligation='normative'>
|
672
|
+
<title>Terms and definitions</title>
|
673
|
+
<p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
|
674
|
+
<term id='term-name'>
|
675
|
+
<preferred><expression><name>name</name></expression></preferred>
|
676
|
+
</term>
|
677
|
+
</terms>
|
678
|
+
<clause id='_' inline-header='false' obligation='normative'>
|
679
|
+
<title>Main</title>
|
680
|
+
<p id='_'>
|
681
|
+
<concept>
|
682
|
+
<refterm>name</refterm>
|
683
|
+
<renderterm>name2</renderterm>
|
684
|
+
<xref target='term-name'/>
|
685
|
+
</concept>
|
686
|
+
is a term
|
687
|
+
</p>
|
688
|
+
<p id='_'>
|
689
|
+
<concept>
|
690
|
+
<refterm>name</refterm>
|
691
|
+
<renderterm>name2</renderterm>
|
692
|
+
<xref target='term-name'/>
|
693
|
+
</concept>
|
694
|
+
is a term
|
695
|
+
</p>
|
696
|
+
<related type='equivalent'>
|
697
|
+
<preferred>
|
698
|
+
<expression>
|
699
|
+
<name>name</name>
|
700
|
+
</expression>
|
701
|
+
</preferred>
|
702
|
+
<xref target='term-name'>name</xref>
|
703
|
+
</related>
|
704
|
+
</clause>
|
705
|
+
</sections>
|
706
|
+
</standard-document>
|
707
|
+
XML
|
708
|
+
end
|
709
|
+
|
710
|
+
it "converts macro into the correct xml" do
|
711
|
+
expect(convert).to(be_equivalent_to(xmlpp(output)))
|
712
|
+
end
|
713
|
+
|
714
|
+
context "default params" do
|
715
|
+
let(:input) do
|
716
|
+
<<~XML
|
717
|
+
#{ASCIIDOC_BLANK_HDR}
|
718
|
+
|
719
|
+
== Terms and Definitions
|
720
|
+
|
721
|
+
=== name
|
722
|
+
|
723
|
+
== Main
|
724
|
+
|
725
|
+
term:[name] is a term
|
726
|
+
|
727
|
+
{{name}} is a term
|
728
|
+
XML
|
729
|
+
end
|
730
|
+
let(:output) do
|
731
|
+
<<~XML
|
732
|
+
#{BLANK_HDR}
|
733
|
+
<sections>
|
734
|
+
<terms id='_' obligation='normative'>
|
735
|
+
<title>Terms and definitions</title>
|
736
|
+
<p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
|
737
|
+
<term id='term-name'>
|
738
|
+
<preferred><expression><name>name</name></expression></preferred>
|
739
|
+
</term>
|
740
|
+
</terms>
|
741
|
+
<clause id='_' inline-header='false' obligation='normative'>
|
742
|
+
<title>Main</title>
|
743
|
+
<p id='_'>
|
744
|
+
<concept>
|
745
|
+
<refterm>name</refterm>
|
746
|
+
<renderterm>name</renderterm>
|
747
|
+
<xref target='term-name'/>
|
748
|
+
</concept>
|
749
|
+
is a term
|
750
|
+
</p>
|
751
|
+
<p id='_'>
|
752
|
+
<concept>
|
753
|
+
<refterm>name</refterm>
|
754
|
+
<renderterm>name</renderterm>
|
755
|
+
<xref target='term-name'/>
|
756
|
+
</concept>
|
757
|
+
is a term
|
758
|
+
</p>
|
759
|
+
</clause>
|
760
|
+
</sections>
|
761
|
+
</standard-document>
|
762
|
+
XML
|
763
|
+
end
|
764
|
+
|
765
|
+
it "uses `name` as termref name" do
|
766
|
+
expect(convert).to(be_equivalent_to(xmlpp(output)))
|
767
|
+
end
|
768
|
+
end
|
769
|
+
|
770
|
+
context "terms with index terms" do
|
771
|
+
let(:input) do
|
772
|
+
<<~XML
|
773
|
+
#{ASCIIDOC_BLANK_HDR}
|
774
|
+
|
775
|
+
== Terms and Definitions
|
776
|
+
|
777
|
+
=== name(((name)))
|
778
|
+
|
779
|
+
== Main
|
780
|
+
|
781
|
+
term:[name] is a term
|
782
|
+
|
783
|
+
{{name}} is a term
|
784
|
+
XML
|
785
|
+
end
|
786
|
+
let(:output) do
|
787
|
+
<<~XML
|
788
|
+
#{BLANK_HDR}
|
789
|
+
<sections>
|
790
|
+
<terms id='_' obligation='normative'>
|
791
|
+
<title>Terms and definitions</title>
|
792
|
+
<p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
|
793
|
+
<term id='term-name'>
|
794
|
+
<preferred><expression><name>name
|
795
|
+
<index>
|
796
|
+
<primary>name</primary>
|
797
|
+
</index>
|
798
|
+
</name>
|
799
|
+
</expression></preferred>
|
800
|
+
</term>
|
801
|
+
</terms>
|
802
|
+
<clause id='_' inline-header='false' obligation='normative'>
|
803
|
+
<title>Main</title>
|
804
|
+
<p id='_'>
|
805
|
+
<concept>
|
806
|
+
<refterm>name</refterm>
|
807
|
+
<renderterm>name</renderterm>
|
808
|
+
<xref target='term-name'/>
|
809
|
+
</concept>
|
810
|
+
is a term
|
811
|
+
</p>
|
812
|
+
<p id='_'>
|
813
|
+
<concept>
|
814
|
+
<refterm>name</refterm>
|
815
|
+
<renderterm>name</renderterm>
|
816
|
+
<xref target='term-name'/>
|
817
|
+
</concept>
|
818
|
+
is a term
|
819
|
+
</p>
|
820
|
+
</clause>
|
821
|
+
</sections>
|
822
|
+
</standard-document>
|
823
|
+
XML
|
824
|
+
end
|
825
|
+
|
826
|
+
it "strips index terms in terms anchors" do
|
827
|
+
expect(convert).to(be_equivalent_to(xmlpp(output)))
|
828
|
+
end
|
829
|
+
end
|
830
|
+
|
831
|
+
context "multiply exising ids in document" do
|
832
|
+
let(:input) do
|
833
|
+
<<~XML
|
834
|
+
#{ASCIIDOC_BLANK_HDR}
|
835
|
+
|
836
|
+
== Terms and Definitions
|
837
|
+
|
838
|
+
=== name
|
839
|
+
=== name2
|
840
|
+
|
841
|
+
[[term-name]]
|
842
|
+
== Main
|
843
|
+
|
844
|
+
paragraph
|
845
|
+
|
846
|
+
[[term-name2]]
|
847
|
+
== Second
|
848
|
+
|
849
|
+
term:[name] is a term
|
850
|
+
term:[name2] is a term
|
851
|
+
{{name}} is a term
|
852
|
+
{{name2}} is a term
|
853
|
+
XML
|
854
|
+
end
|
855
|
+
let(:output) do
|
856
|
+
<<~XML
|
857
|
+
#{BLANK_HDR}
|
858
|
+
<sections>
|
859
|
+
<terms id='_' obligation='normative'>
|
860
|
+
<title>Terms and definitions</title>
|
861
|
+
<p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
|
862
|
+
<term id='term-name-1'>
|
863
|
+
<preferred><expression><name>name</name></expression></preferred>
|
864
|
+
</term>
|
865
|
+
<term id='term-name2-1'>
|
866
|
+
<preferred><expression><name>name2</name></expression></preferred>
|
867
|
+
</term>
|
868
|
+
</terms>
|
869
|
+
<clause id='term-name' inline-header='false' obligation='normative'>
|
870
|
+
<title>Main</title>
|
871
|
+
<p id='_'>paragraph</p>
|
872
|
+
</clause>
|
873
|
+
<clause id='term-name2' inline-header='false' obligation='normative'>
|
874
|
+
<title>Second</title>
|
875
|
+
<p id='_'>
|
876
|
+
<concept>
|
877
|
+
<refterm>name</refterm>
|
878
|
+
<renderterm>name</renderterm>
|
879
|
+
<xref target='term-name-1'/>
|
880
|
+
</concept>
|
881
|
+
is a term
|
882
|
+
<concept>
|
883
|
+
<refterm>name2</refterm>
|
884
|
+
<renderterm>name2</renderterm>
|
885
|
+
<xref target='term-name2-1'/>
|
886
|
+
</concept>
|
887
|
+
is a term
|
888
|
+
<concept>
|
889
|
+
<refterm>name</refterm>
|
890
|
+
<renderterm>name</renderterm>
|
891
|
+
<xref target='term-name-1'/>
|
892
|
+
</concept>
|
893
|
+
is a term
|
894
|
+
<concept>
|
895
|
+
<refterm>name2</refterm>
|
896
|
+
<renderterm>name2</renderterm>
|
897
|
+
<xref target='term-name2-1'/>
|
898
|
+
</concept>
|
899
|
+
is a term
|
900
|
+
</p>
|
901
|
+
</clause>
|
902
|
+
</sections>
|
903
|
+
</standard-document>
|
904
|
+
XML
|
905
|
+
end
|
906
|
+
|
907
|
+
it "generates unique ids which do not match existing ids" do
|
908
|
+
expect(convert).to(be_equivalent_to(xmlpp(output)))
|
909
|
+
end
|
910
|
+
end
|
911
|
+
|
912
|
+
context "when missing actual ref" do
|
913
|
+
let(:input) do
|
914
|
+
<<~XML
|
915
|
+
#{ASCIIDOC_BLANK_HDR}
|
916
|
+
|
917
|
+
== Terms and Definitions
|
918
|
+
|
919
|
+
=== name identity
|
920
|
+
|
921
|
+
[[name-check]]
|
922
|
+
=== name check
|
923
|
+
|
924
|
+
paragraph
|
925
|
+
|
926
|
+
term:[name check] is a term
|
927
|
+
|
928
|
+
term:[name identity] is a term
|
929
|
+
|
930
|
+
Moreover, term:[missing] is a term
|
931
|
+
|
932
|
+
|
933
|
+
{{name check}} is a term
|
934
|
+
|
935
|
+
{{name identity}} is a term
|
936
|
+
|
937
|
+
Moreover, {{missing}} is a term
|
938
|
+
|
939
|
+
related:equivalent[missing]
|
940
|
+
XML
|
941
|
+
end
|
942
|
+
let(:output) do
|
943
|
+
<<~XML
|
944
|
+
#{BLANK_HDR}
|
945
|
+
<sections>
|
946
|
+
<terms id='_' obligation='normative'>
|
947
|
+
<title>Terms and definitions</title>
|
948
|
+
<p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
|
949
|
+
<term id='term-name-identity'>
|
950
|
+
<preferred><expression><name>name identity</name></expression></preferred>
|
951
|
+
</term>
|
952
|
+
<term id='name-check'>
|
953
|
+
<preferred><expression><name>name check</name></expression></preferred>
|
954
|
+
<related type='equivalent'>
|
955
|
+
<strong>
|
956
|
+
term
|
957
|
+
<tt>missing</tt>
|
958
|
+
not resolved via ID
|
959
|
+
<tt>missing</tt>
|
960
|
+
</strong>
|
961
|
+
</related>
|
962
|
+
<definition><verbal-definition>
|
963
|
+
<p id='_'>paragraph</p>
|
964
|
+
<p id='_'>
|
965
|
+
<concept>
|
966
|
+
<refterm>name check</refterm>
|
967
|
+
<renderterm>name check</renderterm>
|
968
|
+
<xref target='name-check'/>
|
969
|
+
</concept>
|
970
|
+
is a term
|
971
|
+
</p>
|
972
|
+
<p id='_'>
|
973
|
+
<concept>
|
974
|
+
<refterm>name identity</refterm>
|
975
|
+
<renderterm>name identity</renderterm>
|
976
|
+
<xref target='term-name-identity'/>
|
977
|
+
</concept>
|
978
|
+
is a term
|
979
|
+
</p>
|
980
|
+
<p id='_'>
|
981
|
+
Moreover,
|
982
|
+
<concept>
|
983
|
+
<strong>
|
984
|
+
term
|
985
|
+
<tt>missing</tt>
|
986
|
+
not resolved via ID
|
987
|
+
<tt>missing</tt>
|
988
|
+
</strong>
|
989
|
+
</concept>
|
990
|
+
is a term
|
991
|
+
</p>
|
992
|
+
<p id='_'>
|
993
|
+
<concept>
|
994
|
+
<refterm>name check</refterm>
|
995
|
+
<renderterm>name check</renderterm>
|
996
|
+
<xref target='name-check'/>
|
997
|
+
</concept>
|
998
|
+
is a term
|
999
|
+
</p>
|
1000
|
+
<p id='_'>
|
1001
|
+
<concept>
|
1002
|
+
<refterm>name identity</refterm>
|
1003
|
+
<renderterm>name identity</renderterm>
|
1004
|
+
<xref target='term-name-identity'/>
|
1005
|
+
</concept>
|
1006
|
+
is a term
|
1007
|
+
</p>
|
1008
|
+
<p id='_'>
|
1009
|
+
Moreover,
|
1010
|
+
<concept>
|
1011
|
+
<strong>
|
1012
|
+
term
|
1013
|
+
<tt>missing</tt>
|
1014
|
+
not resolved via ID
|
1015
|
+
<tt>missing</tt>
|
1016
|
+
</strong>
|
1017
|
+
</concept>
|
1018
|
+
is a term
|
1019
|
+
</p>
|
1020
|
+
</verbal-definition></definition>
|
1021
|
+
</term>
|
1022
|
+
</terms>
|
1023
|
+
</sections>
|
1024
|
+
</standard-document>
|
1025
|
+
XML
|
1026
|
+
end
|
1027
|
+
|
1028
|
+
it "generates unique ids which do not match existing ids" do
|
1029
|
+
expect(convert).to(be_equivalent_to(xmlpp(output)))
|
1030
|
+
end
|
1031
|
+
end
|
1032
|
+
end
|
1033
|
+
end
|