metanorma-bsi 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +6 -0
  3. data/.hound.yml +3 -0
  4. data/.rubocop.yml +14 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +7 -0
  7. data/LICENSE +25 -0
  8. data/README.adoc +199 -0
  9. data/Rakefile +8 -0
  10. data/bin/rspec +18 -0
  11. data/lib/asciidoctor/bsi/basicdoc.rng +1131 -0
  12. data/lib/asciidoctor/bsi/biblio.rng +1235 -0
  13. data/lib/asciidoctor/bsi/bsi.rng +120 -0
  14. data/lib/asciidoctor/bsi/bsi_intro_en.xml +105 -0
  15. data/lib/asciidoctor/bsi/cleanup.rb +78 -0
  16. data/lib/asciidoctor/bsi/cleanup_ref.rb +183 -0
  17. data/lib/asciidoctor/bsi/converter.rb +83 -0
  18. data/lib/asciidoctor/bsi/front.rb +67 -0
  19. data/lib/asciidoctor/bsi/isodoc.rng +1870 -0
  20. data/lib/asciidoctor/bsi/isostandard.rng +477 -0
  21. data/lib/asciidoctor/bsi/reqt.rng +194 -0
  22. data/lib/asciidoctor/bsi/validate.rb +224 -0
  23. data/lib/asciidoctor/bsi/validate_list.rb +72 -0
  24. data/lib/asciidoctor/bsi/validate_requirement.rb +163 -0
  25. data/lib/isodoc/bsi/base_convert.rb +91 -0
  26. data/lib/isodoc/bsi/bsi.international-standard.xsl +6540 -0
  27. data/lib/isodoc/bsi/html/html_bsi_intro.html +8 -0
  28. data/lib/isodoc/bsi/html/html_bsi_titlepage.html +50 -0
  29. data/lib/isodoc/bsi/html/htmlstyle.css +968 -0
  30. data/lib/isodoc/bsi/html/htmlstyle.scss +699 -0
  31. data/lib/isodoc/bsi/html_convert.rb +56 -0
  32. data/lib/isodoc/bsi/i18n-en.yaml +56 -0
  33. data/lib/isodoc/bsi/i18n.rb +15 -0
  34. data/lib/isodoc/bsi/init.rb +24 -0
  35. data/lib/isodoc/bsi/metadata.rb +33 -0
  36. data/lib/isodoc/bsi/pdf_convert.rb +17 -0
  37. data/lib/isodoc/bsi/presentation_xml_convert.rb +72 -0
  38. data/lib/isodoc/bsi/sts_convert.rb +30 -0
  39. data/lib/isodoc/bsi/xref.rb +134 -0
  40. data/lib/metanorma-bsi.rb +15 -0
  41. data/lib/metanorma/bsi.rb +6 -0
  42. data/lib/metanorma/bsi/processor.rb +51 -0
  43. data/lib/metanorma/bsi/version.rb +6 -0
  44. data/metanorma-bsi.gemspec +47 -0
  45. data/spec/asciidoctor/base_spec.rb +778 -0
  46. data/spec/asciidoctor/blocks_spec.rb +553 -0
  47. data/spec/asciidoctor/cleanup_spec.rb +547 -0
  48. data/spec/asciidoctor/inline_spec.rb +176 -0
  49. data/spec/asciidoctor/lists_spec.rb +194 -0
  50. data/spec/asciidoctor/refs_spec.rb +318 -0
  51. data/spec/asciidoctor/section_spec.rb +382 -0
  52. data/spec/asciidoctor/validate_spec.rb +858 -0
  53. data/spec/assets/header.html +7 -0
  54. data/spec/assets/html.css +2 -0
  55. data/spec/assets/iso.xml +71 -0
  56. data/spec/assets/rice_image1.png +0 -0
  57. data/spec/assets/word.css +2 -0
  58. data/spec/assets/wordintro.html +4 -0
  59. data/spec/assets/xref_error.adoc +7 -0
  60. data/spec/isodoc/blocks_spec.rb +259 -0
  61. data/spec/isodoc/i18n_spec.rb +442 -0
  62. data/spec/isodoc/inline_spec.rb +287 -0
  63. data/spec/isodoc/iso_spec.rb +116 -0
  64. data/spec/isodoc/metadata_spec.rb +262 -0
  65. data/spec/isodoc/postproc_spec.rb +137 -0
  66. data/spec/isodoc/ref_spec.rb +376 -0
  67. data/spec/isodoc/section_spec.rb +467 -0
  68. data/spec/isodoc/terms_spec.rb +246 -0
  69. data/spec/isodoc/xref_spec.rb +1730 -0
  70. data/spec/metanorma/processor_spec.rb +76 -0
  71. data/spec/spec_helper.rb +291 -0
  72. data/spec/vcr_cassettes/iso-639.yml +182 -0
  73. data/spec/vcr_cassettes/isobib_get_639_1967.yml +136 -0
  74. data/spec/vcr_cassettes/multistandard.yml +352 -0
  75. metadata +343 -0
@@ -0,0 +1,553 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Asciidoctor::BSI do
4
+ before(:all) do
5
+ @blank_hdr = blank_hdr_gen
6
+ end
7
+
8
+ it "processes open blocks" do
9
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :bsi, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
10
+ #{ASCIIDOC_BLANK_HDR}
11
+ --
12
+ x
13
+
14
+ y
15
+
16
+ z
17
+ --
18
+ INPUT
19
+ #{@blank_hdr}
20
+ <sections><p id="_">x</p>
21
+ <p id="_">y</p>
22
+ <p id="_">z</p></sections>
23
+ </bsi-standard>
24
+ OUTPUT
25
+ end
26
+
27
+ it "processes stem blocks" do
28
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :bsi, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
29
+ #{ASCIIDOC_BLANK_HDR}
30
+ [stem]
31
+ ++++
32
+ r = 1 %
33
+ r = 1 %
34
+ ++++
35
+
36
+ [stem]
37
+ ++++
38
+ <mml:math><mml:msub xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"> <mml:mrow> <mml:mrow> <mml:mi mathvariant="bold-italic">F</mml:mi> </mml:mrow> </mml:mrow> <mml:mrow> <mml:mrow> <mml:mi mathvariant="bold-italic">&#x0391;</mml:mi> </mml:mrow> </mml:mrow> </mml:msub> </mml:math>
39
+ ++++
40
+ INPUT
41
+ #{@blank_hdr}
42
+ <sections>
43
+ <formula id="_">
44
+ <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>r</mi><mo>=</mo><mn>1</mn><mi>%</mi><mi>r</mi><mo>=</mo><mn>1</mn><mi>%</mi></math></stem>
45
+ </formula>
46
+
47
+ <formula id="_">
48
+ <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub> <mrow> <mrow> <mi mathvariant="bold-italic">F</mi> </mrow> </mrow> <mrow> <mrow> <mi mathvariant="bold-italic">Α</mi> </mrow> </mrow> </msub> </math></stem>
49
+ </formula>
50
+ </sections>
51
+ </bsi-standard>
52
+ OUTPUT
53
+ end
54
+
55
+ it "ignores review blocks unless document is in draft mode" do
56
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :bsi, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
57
+ #{ASCIIDOC_BLANK_HDR}
58
+ [[foreword]]
59
+ .Foreword
60
+ Foreword
61
+
62
+ [reviewer=ISO,date=20170101,from=foreword,to=foreword]
63
+ ****
64
+ A Foreword shall appear in each document. The generic text is shown here. It does not contain requirements, recommendations or permissions.
65
+
66
+ For further information on the Foreword, see *ISO/IEC Directives, Part 2, 2016, Clause 12.*
67
+ ****
68
+ INPUT
69
+ #{@blank_hdr}
70
+ <sections><p id="foreword">Foreword</p>
71
+ </sections>
72
+ </bsi-standard>
73
+ OUTPUT
74
+ end
75
+
76
+ it "processes review blocks if document is in draft mode" do
77
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :bsi, header_footer: true)).sub(/^.+<sections>/m, "<sections>").sub(%r{</sections>.*$}m, "</sections>"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
78
+ = Document title
79
+ Author
80
+ :docfile: test.adoc
81
+ :nodoc:
82
+ :novalid:
83
+ :draft: 1.2
84
+ :no-isobib:
85
+
86
+ [[foreword]]
87
+ .Foreword
88
+ Foreword
89
+
90
+ [reviewer=ISO,date=20170101,from=foreword,to=foreword]
91
+ ****
92
+ A Foreword shall appear in each document. The generic text is shown here. It does not contain requirements, recommendations or permissions.
93
+
94
+ For further information on the Foreword, see *ISO/IEC Directives, Part 2, 2016, Clause 12.*
95
+ ****
96
+ INPUT
97
+ <sections>
98
+ <p id="foreword">Foreword</p>
99
+ <review reviewer="ISO" id="_" date="20170101T00:00:00Z" from="foreword" to="foreword"><p id="_">A Foreword shall appear in each document. The generic text is shown here. It does not contain requirements, recommendations or permissions.</p>
100
+ <p id="_">For further information on the Foreword, see <strong>ISO/IEC Directives, Part 2, 2016, Clause 12.</strong></p></review></sections>
101
+
102
+ OUTPUT
103
+ end
104
+
105
+ it "processes term notes" do
106
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :bsi, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
107
+ #{ASCIIDOC_BLANK_HDR}
108
+ == Terms and Definitions
109
+
110
+ === Term1
111
+
112
+ NOTE: This is a note
113
+ INPUT
114
+ #{@blank_hdr}
115
+ <sections>
116
+ <terms id="_" obligation="normative">
117
+ <title>Terms and definitions</title>
118
+ <p id="_">For the purposes of this British Standard, the following terms and definitions apply.</p>
119
+ #{TERMS_BOILERPLATE}
120
+ <term id="term-term1">
121
+ <preferred>Term1</preferred>
122
+ <termnote id="_">
123
+ <p id="_">This is a note</p>
124
+ </termnote>
125
+ </term>
126
+ </terms>
127
+ </sections>
128
+ </bsi-standard>
129
+ OUTPUT
130
+ end
131
+
132
+ it "processes notes" do
133
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :bsi, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
134
+ #{ASCIIDOC_BLANK_HDR}
135
+ NOTE: This is a note
136
+ INPUT
137
+ #{@blank_hdr}
138
+ <sections>
139
+ <note id="_">
140
+ <p id="_">This is a note</p>
141
+ </note>
142
+ </sections>
143
+ </bsi-standard>
144
+
145
+ OUTPUT
146
+ end
147
+
148
+ it "processes literals" do
149
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :bsi, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
150
+ #{ASCIIDOC_BLANK_HDR}
151
+ ....
152
+ LITERAL
153
+ ....
154
+ INPUT
155
+ #{@blank_hdr}
156
+ <sections>
157
+ <figure id="_">
158
+ <pre id="_">LITERAL</pre>
159
+ </figure>
160
+ </sections>
161
+ </bsi-standard>
162
+ OUTPUT
163
+ end
164
+
165
+
166
+ it "processes commentaries" do
167
+ input = <<~INPUT
168
+ #{ASCIIDOC_BLANK_HDR}
169
+ [[reag]]
170
+ === Reagents
171
+
172
+ [NOTE,type=commentary,target=reag]
173
+ This is a commentary on the reagents
174
+
175
+ [[table1]]
176
+ .Reagents in use
177
+ |===
178
+ | A | B
179
+ |===
180
+
181
+ [[reag2]]
182
+ === Reagents
183
+
184
+ [NOTE,type=commentary]
185
+ This is a commentary on the reagents
186
+
187
+ [[table1]]
188
+ .Reagents in use
189
+ |===
190
+ | A | B
191
+ |===
192
+
193
+ INPUT
194
+
195
+ expect(xmlpp(strip_guid(
196
+ Nokogiri::XML(Asciidoctor.convert(input, backend: :bsi, header_footer: true)).at("//xmlns:sections").to_xml)))
197
+ .to be_equivalent_to xmlpp(<<~"OUTPUT")
198
+ <sections>
199
+ <clause id='reag' inline-header='false' obligation='normative'>
200
+ <title>Reagents</title>
201
+ <admonition id='_' type='commentary' target='reag'>
202
+ <p id='_'>This is a commentary on the reagents</p>
203
+ </admonition>
204
+ <table id='table1'>
205
+ <name>Reagents in use</name>
206
+ <tbody>
207
+ <tr>
208
+ <td valign='top' align='left'>A</td>
209
+ <td valign='top' align='left'>B</td>
210
+ </tr>
211
+ </tbody>
212
+ </table>
213
+ </clause>
214
+ <clause id='reag2' inline-header='false' obligation='normative'>
215
+ <title>Reagents</title>
216
+ <admonition id='_' type='commentary' target='reag2'>
217
+ <p id='_'>This is a commentary on the reagents</p>
218
+ </admonition>
219
+ <table id='table1'>
220
+ <name>Reagents in use</name>
221
+ <tbody>
222
+ <tr>
223
+ <td valign='top' align='left'>A</td>
224
+ <td valign='top' align='left'>B</td>
225
+ </tr>
226
+ </tbody>
227
+ </table>
228
+ </clause>
229
+ </sections>
230
+ OUTPUT
231
+ end
232
+
233
+ it "processes simple admonitions with Asciidoc names" do
234
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :bsi, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
235
+ #{ASCIIDOC_BLANK_HDR}
236
+ CAUTION: Only use paddy or parboiled rice for the determination of husked rice yield.
237
+ INPUT
238
+ #{@blank_hdr}
239
+ <sections>
240
+ <admonition id="_" type="caution">
241
+ <p id="_">Only use paddy or parboiled rice for the determination of husked rice yield.</p>
242
+ </admonition>
243
+ </sections>
244
+ </bsi-standard>
245
+
246
+ OUTPUT
247
+ end
248
+
249
+
250
+ it "processes complex admonitions with non-Asciidoc names" do
251
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :bsi, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
252
+ #{ASCIIDOC_BLANK_HDR}
253
+ [CAUTION,type=Safety Precautions]
254
+ .Safety Precautions
255
+ ====
256
+ While werewolves are hardy community members, keep in mind the following dietary concerns:
257
+
258
+ . They are allergic to cinnamon.
259
+ . More than two glasses of orange juice in 24 hours makes them howl in harmony with alarms and sirens.
260
+ . Celery makes them sad.
261
+ ====
262
+ INPUT
263
+ #{@blank_hdr}
264
+ <sections>
265
+ <admonition id="_" type="safety precautions"><name>Safety Precautions</name><p id="_">While werewolves are hardy community members, keep in mind the following dietary concerns:</p>
266
+ <ol id="_">
267
+ <li>
268
+ <p id="_">They are allergic to cinnamon.</p>
269
+ </li>
270
+ <li>
271
+ <p id="_">More than two glasses of orange juice in 24 hours makes them howl in harmony with alarms and sirens.</p>
272
+ </li>
273
+ <li>
274
+ <p id="_">Celery makes them sad.</p>
275
+ </li>
276
+ </ol></admonition>
277
+ </sections>
278
+ </bsi-standard>
279
+
280
+ OUTPUT
281
+ end
282
+
283
+ it "processes term examples" do
284
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :bsi, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
285
+ #{ASCIIDOC_BLANK_HDR}
286
+ == Terms and Definitions
287
+
288
+ === Term1
289
+
290
+ [example]
291
+ This is an example
292
+ INPUT
293
+ #{@blank_hdr}
294
+ <sections>
295
+ <terms id="_" obligation="normative">
296
+ <title>Terms and definitions</title>
297
+ <p id="_">For the purposes of this British Standard, the following terms and definitions apply.</p>
298
+ #{TERMS_BOILERPLATE}
299
+ <term id="term-term1">
300
+ <preferred>Term1</preferred>
301
+ <termexample id="_">
302
+ <p id="_">This is an example</p>
303
+ </termexample>
304
+ </term>
305
+ </terms>
306
+ </sections>
307
+ </bsi-standard>
308
+
309
+ OUTPUT
310
+ end
311
+
312
+ it "processes examples" do
313
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :bsi, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
314
+ #{ASCIIDOC_BLANK_HDR}
315
+ [example]
316
+ ====
317
+ This is an example
318
+
319
+ Amen
320
+ ====
321
+ INPUT
322
+ #{@blank_hdr}
323
+ <sections>
324
+ <example id="_"><p id="_">This is an example</p>
325
+ <p id="_">Amen</p></example>
326
+ </sections>
327
+ </bsi-standard>
328
+ OUTPUT
329
+ end
330
+
331
+ it "processes preambles" do
332
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :bsi, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
333
+ #{ASCIIDOC_BLANK_HDR}
334
+ This is a preamble
335
+
336
+ == Section 1
337
+ INPUT
338
+ #{@blank_hdr}
339
+ <preface><foreword id="_" obligation="informative">
340
+ <title>FOREWORD</title>
341
+ <p id="_">This is a preamble</p>
342
+ </foreword></preface><sections>
343
+ <clause id="_" inline-header="false" obligation="normative">
344
+ <title>Section 1</title>
345
+ </clause></sections>
346
+ </bsi-standard>
347
+ OUTPUT
348
+ end
349
+
350
+ it "processes images" do
351
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :bsi, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
352
+ #{ASCIIDOC_BLANK_HDR}
353
+ .Split-it-right sample divider
354
+ image::spec/examples/rice_images/rice_image1.png[]
355
+
356
+ INPUT
357
+ #{@blank_hdr}
358
+ <sections>
359
+ <figure id="_">
360
+ <name>Split-it-right sample divider</name>
361
+ <image src="spec/examples/rice_images/rice_image1.png" id="_" mimetype="image/png" height="auto" width="auto"/>
362
+ </figure>
363
+ </sections>
364
+ </bsi-standard>
365
+ OUTPUT
366
+ end
367
+
368
+ it "accepts width and height attributes on images" do
369
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :bsi, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
370
+ #{ASCIIDOC_BLANK_HDR}
371
+ [height=4,width=3]
372
+ image::spec/examples/rice_images/rice_image1.png[]
373
+
374
+ INPUT
375
+ #{@blank_hdr}
376
+ <sections>
377
+ <figure id="_">
378
+ <image src="spec/examples/rice_images/rice_image1.png" id="_" mimetype="image/png" height="4" width="3"/>
379
+ </figure>
380
+ </sections>
381
+ </bsi-standard>
382
+ OUTPUT
383
+ end
384
+
385
+ it "accepts auto for width and height attributes on images" do
386
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :bsi, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
387
+ #{ASCIIDOC_BLANK_HDR}
388
+ [height=4,width=auto]
389
+ image::spec/examples/rice_images/rice_image1.png[]
390
+
391
+ INPUT
392
+ #{@blank_hdr}
393
+ <sections>
394
+ <figure id="_">
395
+ <image src="spec/examples/rice_images/rice_image1.png" id="_" mimetype="image/png" height="4" width="auto"/>
396
+ </figure>
397
+ </sections>
398
+ </bsi-standard>
399
+ OUTPUT
400
+ end
401
+
402
+ it "accepts alignment attribute on paragraphs" do
403
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :bsi, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
404
+ #{ASCIIDOC_BLANK_HDR}
405
+ [align=right]
406
+ This para is right-aligned.
407
+ INPUT
408
+ #{@blank_hdr}
409
+ <sections>
410
+ <p align="right" id="_">This para is right-aligned.</p>
411
+ </sections>
412
+ </bsi-standard>
413
+ OUTPUT
414
+ end
415
+
416
+ it "processes blockquotes" do
417
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :bsi, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
418
+ #{ASCIIDOC_BLANK_HDR}
419
+ [quote, ISO, "ISO7301,section 1"]
420
+ ____
421
+ Block quotation
422
+ ____
423
+ INPUT
424
+ #{@blank_hdr}
425
+ <sections>
426
+ <quote id="_">
427
+ <source type="inline" bibitemid="ISO7301" citeas=""><localityStack><locality type="section"><referenceFrom>1</referenceFrom></locality></localityStack></source>
428
+ <author>ISO</author>
429
+ <p id="_">Block quotation</p>
430
+ </quote>
431
+ </sections>
432
+ </bsi-standard>
433
+ OUTPUT
434
+ end
435
+
436
+ it "processes source code" do
437
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :bsi, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
438
+ #{ASCIIDOC_BLANK_HDR}
439
+ [source,ruby]
440
+ --
441
+ puts "Hello, world."
442
+ %w{a b c}.each do |x|
443
+ puts x
444
+ end
445
+ --
446
+ INPUT
447
+ #{@blank_hdr}
448
+ <sections>
449
+ <sourcecode lang="ruby" id="_">puts "Hello, world."
450
+ %w{a b c}.each do |x|
451
+ puts x
452
+ end</sourcecode>
453
+ </sections>
454
+ </bsi-standard>
455
+ OUTPUT
456
+ end
457
+
458
+ it "processes callouts" do
459
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :bsi, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
460
+ #{ASCIIDOC_BLANK_HDR}
461
+ [source,ruby]
462
+ --
463
+ puts "Hello, world." <1>
464
+ %w{a b c}.each do |x|
465
+ puts x <2>
466
+ end
467
+ --
468
+ <1> This is one callout
469
+ <2> This is another callout
470
+ INPUT
471
+ #{@blank_hdr}
472
+ <sections><sourcecode lang="ruby" id="_">puts "Hello, world." <callout target="_">1</callout>
473
+ %w{a b c}.each do |x|
474
+ puts x <callout target="_">2</callout>
475
+ end<annotation id="_">
476
+ <p id="_">This is one callout</p>
477
+ </annotation><annotation id="_">
478
+ <p id="_">This is another callout</p>
479
+ </annotation></sourcecode>
480
+ </sections>
481
+ </bsi-standard>
482
+ OUTPUT
483
+ end
484
+
485
+ it "processes unmodified term sources" do
486
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :bsi, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
487
+ #{ASCIIDOC_BLANK_HDR}
488
+ == Terms and Definitions
489
+
490
+ === Term1
491
+
492
+ [.source]
493
+ <<ISO2191,section=1>>
494
+ INPUT
495
+ #{@blank_hdr}
496
+ <sections>
497
+ <terms id="_" obligation="normative">
498
+ <title>Terms and definitions</title>
499
+ <p id="_">For the purposes of this British Standard, the following terms and definitions apply.</p>
500
+ #{TERMS_BOILERPLATE}
501
+ <term id="term-term1">
502
+ <preferred>Term1</preferred>
503
+ <termsource status="identical">
504
+ <origin bibitemid="ISO2191" type="inline" citeas="">
505
+ <localityStack>
506
+ <locality type="section"><referenceFrom>1</referenceFrom></locality>
507
+ </localityStack>
508
+ </origin>
509
+ </termsource>
510
+ </term>
511
+ </terms>
512
+ </sections>
513
+ </bsi-standard>
514
+ OUTPUT
515
+ end
516
+
517
+ it "processes modified term sources" do
518
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :bsi, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
519
+ #{ASCIIDOC_BLANK_HDR}
520
+ == Terms and Definitions
521
+
522
+ === Term1
523
+
524
+ [.source]
525
+ <<ISO2191,section=1>>, with adjustments
526
+ INPUT
527
+ #{@blank_hdr}
528
+ <sections>
529
+ <terms id="_" obligation="normative">
530
+ <title>Terms and definitions</title>
531
+ <p id="_">For the purposes of this British Standard, the following terms and definitions apply.</p>
532
+ #{TERMS_BOILERPLATE}
533
+ <term id="term-term1">
534
+ <preferred>Term1</preferred>
535
+ <termsource status="modified">
536
+ <origin bibitemid="ISO2191" type="inline" citeas="">
537
+ <localityStack>
538
+ <locality type="section"><referenceFrom>1</referenceFrom></locality>
539
+ </localityStack>
540
+ </origin>
541
+ <modification>
542
+ <p id="_">with adjustments</p>
543
+ </modification>
544
+ </termsource>
545
+ </term>
546
+ </terms>
547
+ </sections>
548
+ </bsi-standard>
549
+ OUTPUT
550
+ end
551
+
552
+
553
+ end