metanorma-standoc 1.6.4 → 1.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +17 -0
  3. data/lib/asciidoctor/standoc/base.rb +8 -16
  4. data/lib/asciidoctor/standoc/basicdoc.rng +50 -3
  5. data/lib/asciidoctor/standoc/cleanup.rb +1 -1
  6. data/lib/asciidoctor/standoc/cleanup_block.rb +0 -8
  7. data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +33 -20
  8. data/lib/asciidoctor/standoc/cleanup_inline.rb +3 -1
  9. data/lib/asciidoctor/standoc/cleanup_ref.rb +17 -24
  10. data/lib/asciidoctor/standoc/cleanup_terms.rb +4 -6
  11. data/lib/asciidoctor/standoc/converter.rb +4 -49
  12. data/lib/asciidoctor/standoc/front_contributor.rb +8 -4
  13. data/lib/asciidoctor/standoc/inline.rb +7 -5
  14. data/lib/asciidoctor/standoc/isodoc.rng +48 -3
  15. data/lib/asciidoctor/standoc/macros.rb +30 -61
  16. data/lib/asciidoctor/standoc/macros_terms.rb +82 -0
  17. data/lib/asciidoctor/standoc/ref.rb +12 -21
  18. data/lib/asciidoctor/standoc/section.rb +22 -20
  19. data/lib/asciidoctor/standoc/table.rb +12 -0
  20. data/lib/asciidoctor/standoc/term_lookup_cleanup.rb +86 -0
  21. data/lib/asciidoctor/standoc/utils.rb +2 -0
  22. data/lib/metanorma/standoc/version.rb +1 -1
  23. data/metanorma-standoc.gemspec +1 -2
  24. data/spec/asciidoctor-standoc/base_spec.rb +14 -8
  25. data/spec/asciidoctor-standoc/blocks_spec.rb +14 -9
  26. data/spec/asciidoctor-standoc/cleanup_sections_spec.rb +18 -13
  27. data/spec/asciidoctor-standoc/cleanup_spec.rb +75 -11
  28. data/spec/asciidoctor-standoc/inline_spec.rb +4 -5
  29. data/spec/asciidoctor-standoc/macros_lutaml_spec.rb +1 -1
  30. data/spec/asciidoctor-standoc/macros_plantuml_spec.rb +307 -0
  31. data/spec/asciidoctor-standoc/macros_spec.rb +258 -277
  32. data/spec/asciidoctor-standoc/refs_dl_spec.rb +4 -4
  33. data/spec/asciidoctor-standoc/section_spec.rb +155 -12
  34. data/spec/asciidoctor-standoc/table_spec.rb +146 -0
  35. data/spec/fixtures/diagram_definitions.lutaml +4 -4
  36. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +49 -49
  37. data/spec/vcr_cassettes/isobib_get_123.yml +13 -13
  38. data/spec/vcr_cassettes/isobib_get_123_1.yml +25 -25
  39. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +33 -33
  40. data/spec/vcr_cassettes/isobib_get_123_2001.yml +14 -14
  41. data/spec/vcr_cassettes/isobib_get_124.yml +14 -14
  42. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +8 -8
  43. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +71 -75
  44. metadata +7 -18
@@ -142,7 +142,7 @@ copyright::
142
142
  abbreviation:::: ISO
143
143
  url:::: www.iso.org
144
144
  from::: 2014
145
- to::: 2020
145
+ to::: #{Time.now.year}
146
146
  link::
147
147
  type::: src
148
148
  content::: https://www.iso.org/standard/53798.html
@@ -389,7 +389,7 @@ home run record in 1998.</note>
389
389
  </status>
390
390
  <copyright>
391
391
  <from>2014</from>
392
- <to>2020</to>
392
+ <to>#{Time.now.year}</to>
393
393
  <owner>
394
394
  <organization>
395
395
  <name>International Organization for Standardization</name>
@@ -507,7 +507,7 @@ copyright.owner.name:: International Organization for Standardization
507
507
  copyright.owner.abbreviation:: ISO
508
508
  copyright.owner.url:: www.iso.org
509
509
  copyright.from:: 2014
510
- copyright.to:: 2020
510
+ copyright.to:: #{Time.now.year}
511
511
  link::
512
512
  link.type:: src
513
513
  link.content:: https://www.iso.org/standard/53798.html
@@ -707,7 +707,7 @@ home run record in 1998.</note>
707
707
  </status>
708
708
  <copyright>
709
709
  <from>2014</from>
710
- <to>2020</to>
710
+ <to>#{Time.now.year}</to>
711
711
  <owner>
712
712
  <organization>
713
713
  <name>International Organization for Standardization</name>
@@ -34,6 +34,11 @@ RSpec.describe Asciidoctor::Standoc do
34
34
 
35
35
  == Terms, Definitions, Symbols and Abbreviated Terms
36
36
 
37
+ [.boilerplate]
38
+ === Boilerplate
39
+
40
+ Boilerplate text
41
+
37
42
  [.nonterm]
38
43
  === Introduction
39
44
 
@@ -111,12 +116,12 @@ RSpec.describe Asciidoctor::Standoc do
111
116
  <title>Terms and definitions</title>
112
117
  <p id="_">For the purposes of this document,
113
118
  the following terms and definitions apply.</p>
114
- <term id="_">
119
+ <term id="term-term1">
115
120
  <preferred>Term1</preferred>
116
121
  </term>
117
122
  </terms>
118
123
  <clause id="_" obligation="normative"><title>Terms, definitions, symbols and abbreviated terms</title>
119
- <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
124
+ <p id='_'>Boilerplate text</p>
120
125
  <clause id="_" inline-header="false" obligation="normative">
121
126
  <title>Introduction</title>
122
127
  <clause id="_" inline-header="false" obligation="normative">
@@ -133,14 +138,14 @@ RSpec.describe Asciidoctor::Standoc do
133
138
  <title>Intro 4</title>
134
139
  <terms id="_" obligation="normative">
135
140
  <title>Intro 5</title>
136
- <term id="_">
141
+ <term id="term-term1-1">
137
142
  <preferred>Term1</preferred>
138
143
  </term>
139
144
  </terms>
140
145
  </clause>
141
146
  <terms id="_" obligation="normative">
142
147
  <title>Normal Terms</title>
143
- <term id="_">
148
+ <term id="term-term2">
144
149
  <preferred>Term2</preferred>
145
150
  </term>
146
151
  </terms>
@@ -181,6 +186,144 @@ RSpec.describe Asciidoctor::Standoc do
181
186
  OUTPUT
182
187
  end
183
188
 
189
+ it "processes sections with number attributes" do
190
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
191
+ #{ASCIIDOC_BLANK_HDR}
192
+ [number=1bis]
193
+ == Scope
194
+
195
+ Text
196
+
197
+ [number=2bis]
198
+ == Normative References
199
+
200
+ [number=3bis]
201
+ == Terms and Definitions
202
+
203
+ [number=4bis]
204
+ === Term1
205
+
206
+ [number=5bis]
207
+ == Terms, Definitions, Symbols and Abbreviated Terms
208
+
209
+ [.nonterm,number=6bis]
210
+ === Introduction
211
+
212
+ [number=7bis]
213
+ ==== Intro 1
214
+
215
+ [number=8bis]
216
+ === Intro 2
217
+
218
+ [number=9bis]
219
+ === Symbols and Abbreviated Terms
220
+
221
+ [.nonterm,number=10bis]
222
+ ==== General
223
+
224
+ [number=11bis]
225
+ ==== Symbols
226
+
227
+ [number=12bis]
228
+ == Abbreviated Terms
229
+
230
+ [number=13bis]
231
+ == Clause 4
232
+
233
+ [number=14bis]
234
+ === Introduction
235
+
236
+ [number=15bis]
237
+ === Clause 4.2
238
+
239
+ [number=16bis]
240
+ == Terms and Definitions
241
+
242
+ [appendix,number=17bis]
243
+ == Annex
244
+
245
+ [number=18bis]
246
+ === Annex A.1
247
+
248
+ [bibliography,number=19bis]
249
+ == Bibliography
250
+
251
+ [number=20bis]
252
+ === Bibliography Subsection
253
+ INPUT
254
+ #{BLANK_HDR}
255
+ <sections>
256
+ <clause id='_' number='1bis' type='scope' inline-header='false' obligation='normative'>
257
+ <title>Scope</title>
258
+ <p id='_'>Text</p>
259
+ </clause>
260
+ <terms id='_' number='3bis' obligation='normative'>
261
+ <title>Terms and definitions</title>
262
+ <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
263
+ <term id='term-term1' number='4bis'>
264
+ <preferred>Term1</preferred>
265
+ </term>
266
+ </terms>
267
+ <terms id='_' number='5bis' obligation='normative'>
268
+ <title>Terms, definitions, symbols and abbreviated terms</title>
269
+ <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
270
+ <clause id='_' number='6bis' inline-header='false' obligation='normative'>
271
+ <title>Introduction</title>
272
+ <clause id='_' number='7bis' inline-header='false' obligation='normative'>
273
+ <title>Intro 1</title>
274
+ </clause>
275
+ </clause>
276
+ <term id='term-intro-2' number='8bis'>
277
+ <preferred>Intro 2</preferred>
278
+ </term>
279
+ <definitions id='_' number='9bis' obligation='normative'>
280
+ <title>Symbols and abbreviated terms</title>
281
+ <clause id='_' number='10bis' inline-header='false' obligation='normative'>
282
+ <title>General</title>
283
+ </clause>
284
+ <definitions id='_' number='11bis' type='symbols' obligation='normative'>
285
+ <title>Symbols</title>
286
+ </definitions>
287
+ </definitions>
288
+ </terms>
289
+ <definitions id='_' number='12bis' type='abbreviated_terms' obligation='normative'>
290
+ <title>Abbreviated terms</title>
291
+ </definitions>
292
+ <clause id='_' number='13bis' inline-header='false' obligation='normative'>
293
+ <title>Clause 4</title>
294
+ <clause id='_' number='14bis' inline-header='false' obligation='normative'>
295
+ <title>Introduction</title>
296
+ </clause>
297
+ <clause id='_' number='15bis' inline-header='false' obligation='normative'>
298
+ <title>Clause 4.2</title>
299
+ </clause>
300
+ </clause>
301
+ <clause id='_' number='16bis' inline-header='false' obligation='normative'>
302
+ <title>Terms and Definitions</title>
303
+ </clause>
304
+ </sections>
305
+ <annex id='_' number='17bis' inline-header='false' obligation='normative'>
306
+ <title>Annex</title>
307
+ <clause id='_' number='18bis' inline-header='false' obligation='normative'>
308
+ <title>Annex A.1</title>
309
+ </clause>
310
+ </annex>
311
+ <bibliography>
312
+ <references id='_' number='2bis' normative='true' obligation='informative'>
313
+ <title>Normative references</title>
314
+ <p id='_'>There are no normative references in this document.</p>
315
+ </references>
316
+ <clause id='_' number='19bis' obligation='informative'>
317
+ <title>Bibliography</title>
318
+ <references id='_' number='20bis' normative='false' obligation='informative'>
319
+ <title>Bibliography Subsection</title>
320
+ </references>
321
+ </clause>
322
+ </bibliography>
323
+ </standard-document>
324
+ OUTPUT
325
+ end
326
+
184
327
  it "processes sections with language and script attributes" do
185
328
  expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
186
329
  #{ASCIIDOC_BLANK_HDR}
@@ -317,7 +460,7 @@ RSpec.describe Asciidoctor::Standoc do
317
460
  <title>Terms and definitions</title>
318
461
  <p id="_">For the purposes of this document,
319
462
  the following terms and definitions apply.</p>
320
- <term id="_" language="en" script="Latn">
463
+ <term id="term-term1" language="en" script="Latn">
321
464
  <preferred>Term1</preferred>
322
465
  </term>
323
466
  </terms>
@@ -339,14 +482,14 @@ RSpec.describe Asciidoctor::Standoc do
339
482
  <title>Intro 4</title>
340
483
  <terms id="_" language="en" script="Latn" obligation="normative">
341
484
  <title>Intro 5</title>
342
- <term id="_">
485
+ <term id="term-term1-1">
343
486
  <preferred>Term1</preferred>
344
487
  </term>
345
488
  </terms>
346
489
  </clause>
347
490
  <terms id="_" language="en" script="Latn" obligation="normative">
348
491
  <title>Normal Terms</title>
349
- <term id="_">
492
+ <term id="term-term2">
350
493
  <preferred>Term2</preferred>
351
494
  </term>
352
495
  </terms>
@@ -468,7 +611,7 @@ RSpec.describe Asciidoctor::Standoc do
468
611
  <terms id='_' obligation='normative'>
469
612
  <title>Terms and definitions</title>
470
613
  <p id="_">For the purposes of this document, the following terms and definitions apply.</p>
471
- <term id='_'>
614
+ <term id='term-term1'>
472
615
  <preferred>Term1</preferred>
473
616
  </term>
474
617
  </terms>
@@ -477,7 +620,7 @@ RSpec.describe Asciidoctor::Standoc do
477
620
  <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
478
621
  <terms id='_' obligation='normative'>
479
622
  <title>Normal Terms</title>
480
- <term id='_'>
623
+ <term id='term-term2'>
481
624
  <preferred>Term2</preferred>
482
625
  </term>
483
626
  </terms>
@@ -536,7 +679,7 @@ RSpec.describe Asciidoctor::Standoc do
536
679
  <terms id='_' obligation='normative'>
537
680
  <title>Terms, definitions and symbols</title>
538
681
  <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
539
- <term id='_'>
682
+ <term id='term-term'>
540
683
  <preferred>Term</preferred>
541
684
  </term>
542
685
  <definitions id='_' obligation="normative" type="symbols">
@@ -565,7 +708,7 @@ RSpec.describe Asciidoctor::Standoc do
565
708
  <terms id='_' obligation='normative'>
566
709
  <title>Terms, definitions and abbreviated terms</title>
567
710
  <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
568
- <term id='_'>
711
+ <term id='term-term'>
569
712
  <preferred>Term</preferred>
570
713
  </term>
571
714
  <definitions id='_' obligation="normative" type="abbreviated_terms">
@@ -710,7 +853,7 @@ RSpec.describe Asciidoctor::Standoc do
710
853
  <terms id="_" obligation="normative">
711
854
  <title>Terms and definitions</title><p id="_">For the purposes of this document, the terms and definitions
712
855
  given in <eref bibitemid="iso1234"/> and <eref bibitemid="iso5678"/> and the following apply.</p>
713
- <term id="_">
856
+ <term id="term-term1">
714
857
  <preferred>Term1</preferred>
715
858
  </term>
716
859
  </terms></sections>
@@ -35,6 +35,152 @@ RSpec.describe Asciidoctor::Standoc do
35
35
  OUTPUT
36
36
  end
37
37
 
38
+ it "processes table widths" do
39
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
40
+ #{ASCIIDOC_BLANK_HDR}
41
+ [width=75%]
42
+ |===
43
+ |A
44
+ |B
45
+ |===
46
+
47
+ [width=75]
48
+ |===
49
+ |A
50
+ |B
51
+ |===
52
+
53
+ [width=575]
54
+ |===
55
+ |A
56
+ |B
57
+ |===
58
+
59
+ INPUT
60
+ #{BLANK_HDR}
61
+ <sections>
62
+ <table id='_' width='75%'>
63
+ <tbody>
64
+ <tr>
65
+ <td valign='top' align='left'>A</td>
66
+ </tr>
67
+ <tr>
68
+ <td valign='top' align='left'>B</td>
69
+ </tr>
70
+ </tbody>
71
+ </table>
72
+ <table id='_' width='75'>
73
+ <tbody>
74
+ <tr>
75
+ <td valign='top' align='left'>A</td>
76
+ </tr>
77
+ <tr>
78
+ <td valign='top' align='left'>B</td>
79
+ </tr>
80
+ </tbody>
81
+ </table>
82
+ <table id='_' width='575'>
83
+ <tbody>
84
+ <tr>
85
+ <td valign='top' align='left'>A</td>
86
+ </tr>
87
+ <tr>
88
+ <td valign='top' align='left'>B</td>
89
+ </tr>
90
+ </tbody>
91
+ </table>
92
+ </sections>
93
+ </standard-document>
94
+
95
+ OUTPUT
96
+ end
97
+
98
+ it "processes column widths in tables" do
99
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
100
+ #{ASCIIDOC_BLANK_HDR}
101
+ [cols=".<,.^,^.>"]
102
+ |===
103
+ |A |B |C
104
+
105
+ |1 |2 |3
106
+ |===
107
+
108
+ [cols="3"]
109
+ |===
110
+ |A |B |C
111
+
112
+ |1 |2 |3
113
+ |===
114
+
115
+
116
+ [cols="1,2,6"]
117
+ |===
118
+ |A |B |C
119
+
120
+ |1 |2 |3
121
+ |===
122
+ INPUT
123
+ #{BLANK_HDR}
124
+ <sections>
125
+ <table id='_'>
126
+ <thead>
127
+ <tr>
128
+ <th valign='top' align='left'>A</th>
129
+ <th valign='middle' align='left'>B</th>
130
+ <th valign='bottom' align='center'>C</th>
131
+ </tr>
132
+ </thead>
133
+ <tbody>
134
+ <tr>
135
+ <td valign='top' align='left'>1</td>
136
+ <td valign='middle' align='left'>2</td>
137
+ <td valign='bottom' align='center'>3</td>
138
+ </tr>
139
+ </tbody>
140
+ </table>
141
+ <table id='_'>
142
+ <thead>
143
+ <tr>
144
+ <th valign='top' align='left'>A</th>
145
+ <th valign='top' align='left'>B</th>
146
+ <th valign='top' align='left'>C</th>
147
+ </tr>
148
+ </thead>
149
+ <tbody>
150
+ <tr>
151
+ <td valign='top' align='left'>1</td>
152
+ <td valign='top' align='left'>2</td>
153
+ <td valign='top' align='left'>3</td>
154
+ </tr>
155
+ </tbody>
156
+ </table>
157
+ <table id='_'>
158
+ <colgroup>
159
+ <col width='11.1111%'/>
160
+ <col width='22.2222%'/>
161
+ <col width='66.6667%'/>
162
+ </colgroup>
163
+ <thead>
164
+ <tr>
165
+ <th valign='top' align='left'>A</th>
166
+ <th valign='top' align='left'>B</th>
167
+ <th valign='top' align='left'>C</th>
168
+ </tr>
169
+ </thead>
170
+ <tbody>
171
+ <tr>
172
+ <td valign='top' align='left'>1</td>
173
+ <td valign='top' align='left'>2</td>
174
+ <td valign='top' align='left'>3</td>
175
+ </tr>
176
+ </tbody>
177
+ </table>
178
+ </sections>
179
+ </standard-document>
180
+ OUTPUT
181
+ end
182
+
183
+
38
184
  it "inserts header rows in a table with a name and no header" do
39
185
  expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
40
186
  #{ASCIIDOC_BLANK_HDR}
@@ -3,20 +3,20 @@ diagram MyView {
3
3
 
4
4
  enum AddressClassProfile {
5
5
  imlicistAttributeProfile: CharacterString [0..1] {
6
- definition
6
+ definition {
7
7
  this is multiline with `ascidoc`
8
8
  comments
9
9
  and list
10
- end definition
10
+ }
11
11
  }
12
12
  }
13
13
 
14
14
  class AttributeProfile {
15
15
  +addressClassProfile: CharacterString [0..1]
16
16
  imlicistAttributeProfile: CharacterString [0..1] {
17
- definition this is attribute definition
17
+ definition { this is attribute definition
18
18
  with multiply lines
19
- end definition
19
+ }
20
20
  }
21
21
  }
22
22
  }