metanorma-standoc 1.10.1 → 1.10.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/asciidoctor/standoc/cleanup.rb +61 -0
- data/lib/asciidoctor/standoc/converter.rb +4 -0
- data/lib/asciidoctor/standoc/datamodel/diagram_preprocessor.rb +22 -21
- data/lib/asciidoctor/standoc/isodoc.rng +12 -0
- data/lib/asciidoctor/standoc/macros.rb +18 -0
- data/lib/asciidoctor/standoc/ref.rb +60 -56
- data/lib/asciidoctor/standoc/reqt.rb +39 -27
- data/lib/asciidoctor/standoc/reqt.rng +7 -0
- data/lib/asciidoctor/standoc/term_lookup_cleanup.rb +1 -1
- data/lib/asciidoctor/standoc/validate_section.rb +2 -1
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +1 -1
- data/spec/asciidoctor/blocks_spec.rb +45 -25
- data/spec/asciidoctor/cleanup_sections_spec.rb +899 -864
- data/spec/asciidoctor/cleanup_spec.rb +56 -6
- data/spec/asciidoctor/macros_plantuml_spec.rb +165 -104
- data/spec/asciidoctor/macros_spec.rb +277 -0
- data/spec/fixtures/datamodel_description_sections_tree.xml +327 -0
- data/spec/fixtures/test.xmi +9250 -0
- data/spec/support/shared_examples/structured_data_2_text_preprocessor.rb +34 -34
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +50 -50
- data/spec/vcr_cassettes/isobib_get_123.yml +11 -11
- data/spec/vcr_cassettes/isobib_get_123_1.yml +23 -23
- data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +35 -35
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +12 -12
- data/spec/vcr_cassettes/isobib_get_124.yml +11 -11
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +14 -14
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +46 -46
- metadata +6 -4
@@ -316,6 +316,56 @@ RSpec.describe Asciidoctor::Standoc do
|
|
316
316
|
.to be_equivalent_to xmlpp(output)
|
317
317
|
end
|
318
318
|
|
319
|
+
it "ignores tags when applying smartquotes" do
|
320
|
+
input = <<~INPUT
|
321
|
+
#{ASCIIDOC_BLANK_HDR}
|
322
|
+
|
323
|
+
"((ppt))",
|
324
|
+
|
325
|
+
"((ppm))", "((ppt))"
|
326
|
+
|
327
|
+
"((ppm))" 
|
328
|
+
|
329
|
+
....
|
330
|
+
((ppm))",
|
331
|
+
....
|
332
|
+
INPUT
|
333
|
+
output = <<~OUTPUT
|
334
|
+
#{BLANK_HDR}
|
335
|
+
<sections>
|
336
|
+
<p id='_'>
|
337
|
+
“ppt”,
|
338
|
+
<index>
|
339
|
+
<primary>ppt</primary>
|
340
|
+
</index>
|
341
|
+
</p>
|
342
|
+
<p id='_'>
|
343
|
+
“ppm”,
|
344
|
+
<index>
|
345
|
+
<primary>ppm</primary>
|
346
|
+
</index>
|
347
|
+
“ppt”
|
348
|
+
<index>
|
349
|
+
<primary>ppt</primary>
|
350
|
+
</index>
|
351
|
+
</p>
|
352
|
+
<p id='_'>
|
353
|
+
“ppm
|
354
|
+
<index>
|
355
|
+
<primary>ppm</primary>
|
356
|
+
</index>
|
357
|
+
“ 
|
358
|
+
</p>
|
359
|
+
<figure id='_'>
|
360
|
+
<pre id='_'>((ppm))",</pre>
|
361
|
+
</figure>
|
362
|
+
</sections>
|
363
|
+
</standard-document>
|
364
|
+
OUTPUT
|
365
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
366
|
+
.to be_equivalent_to xmlpp(output)
|
367
|
+
end
|
368
|
+
|
319
369
|
it "removes empty text elements" do
|
320
370
|
input = <<~INPUT
|
321
371
|
#{ASCIIDOC_BLANK_HDR}
|
@@ -486,7 +536,7 @@ RSpec.describe Asciidoctor::Standoc do
|
|
486
536
|
output = <<~OUTPUT
|
487
537
|
#{BLANK_HDR}
|
488
538
|
<sections><formula id="_">
|
489
|
-
<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>r</mi><mo>=</mo><mn>1</mn><
|
539
|
+
<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>r</mi><mo>=</mo><mn>1</mn><mo>%</mo><mi>r</mi><mo>=</mo><mn>1</mn><mo>%</mo></math></stem>
|
490
540
|
<note id="_">
|
491
541
|
<p id="_">That formula does not do much</p>
|
492
542
|
</note></formula>
|
@@ -517,7 +567,7 @@ RSpec.describe Asciidoctor::Standoc do
|
|
517
567
|
output = <<~OUTPUT
|
518
568
|
#{BLANK_HDR}
|
519
569
|
<sections><formula id="_">
|
520
|
-
<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>r</mi><mo>=</mo><mn>1</mn><
|
570
|
+
<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>r</mi><mo>=</mo><mn>1</mn><mo>%</mo><mi>r</mi><mo>=</mo><mn>1</mn><mo>%</mo></math></stem></formula>
|
521
571
|
<note id="_">
|
522
572
|
<p id="_">That formula does not do much</p>
|
523
573
|
</note>
|
@@ -1935,7 +1985,7 @@ RSpec.describe Asciidoctor::Standoc do
|
|
1935
1985
|
<dd>
|
1936
1986
|
<p id='_'>Definition 7</p>
|
1937
1987
|
</dd>
|
1938
|
-
<dt id="symbol
|
1988
|
+
<dt id="symbol-_-n-">
|
1939
1989
|
<stem type='MathML'>
|
1940
1990
|
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
1941
1991
|
<mi>n</mi>
|
@@ -1997,7 +2047,7 @@ RSpec.describe Asciidoctor::Standoc do
|
|
1997
2047
|
<dd>
|
1998
2048
|
<p id='_'>Definition 5</p>
|
1999
2049
|
</dd>
|
2000
|
-
<dt id='symbol
|
2050
|
+
<dt id='symbol-_-xm-'><stem type='MathML'>
|
2001
2051
|
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
2002
2052
|
<msub>
|
2003
2053
|
<mrow>
|
@@ -2012,7 +2062,7 @@ RSpec.describe Asciidoctor::Standoc do
|
|
2012
2062
|
<dd>
|
2013
2063
|
<p id='_'>Definition 4</p>
|
2014
2064
|
</dd>
|
2015
|
-
<dt id='symbol
|
2065
|
+
<dt id='symbol-_-x1-'><stem type='MathML'>
|
2016
2066
|
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
2017
2067
|
<msub>
|
2018
2068
|
<mrow>
|
@@ -2031,7 +2081,7 @@ RSpec.describe Asciidoctor::Standoc do
|
|
2031
2081
|
<dd>
|
2032
2082
|
<p id='_'>Definition 2</p>
|
2033
2083
|
</dd>
|
2034
|
-
<dt id='symbol
|
2084
|
+
<dt id='symbol-_-α-'>
|
2035
2085
|
<stem type='MathML'>
|
2036
2086
|
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
2037
2087
|
<mi>α</mi>
|
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
RSpec.describe Asciidoctor::Standoc do
|
4
4
|
it "processes the PlantUML macro" do
|
5
|
-
|
5
|
+
input = <<~INPUT
|
6
6
|
#{ASCIIDOC_BLANK_HDR}
|
7
7
|
|
8
8
|
[plantuml]
|
@@ -36,24 +36,27 @@ RSpec.describe Asciidoctor::Standoc do
|
|
36
36
|
@enduml
|
37
37
|
....
|
38
38
|
INPUT
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
39
|
+
output = <<~OUTPUT
|
40
|
+
#{BLANK_HDR}
|
41
|
+
<sections><figure id="_">
|
42
|
+
<image src="plantuml/_.png" id="_" mimetype="image/png" height="auto" width="auto"/>
|
43
|
+
</figure>
|
44
|
+
<figure id="_">
|
45
|
+
<image src="plantuml/_.png" id="_" mimetype="image/png" height="auto" width="auto"/>
|
46
|
+
</figure>
|
47
|
+
<figure id="_">
|
48
|
+
<image src="plantuml/filename.png" id="_" mimetype="image/png" height="auto" width="auto"/>
|
49
|
+
</figure>
|
50
|
+
</sections>
|
51
|
+
</standard-document>
|
52
52
|
OUTPUT
|
53
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))
|
54
|
+
.gsub(%r{plantuml/plantuml[^./]+\.}, "plantuml/_.")))
|
55
|
+
.to be_equivalent_to xmlpp(output)
|
53
56
|
end
|
54
57
|
|
55
58
|
it "processes the PlantUML macro with imagesdir" do
|
56
|
-
|
59
|
+
input = <<~INPUT
|
57
60
|
= Document title
|
58
61
|
Author
|
59
62
|
:docfile: test.adoc
|
@@ -72,18 +75,22 @@ RSpec.describe Asciidoctor::Standoc do
|
|
72
75
|
Alice <-- Bob: another authentication Response
|
73
76
|
@enduml
|
74
77
|
....
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
</
|
82
|
-
</
|
83
|
-
|
84
|
-
|
78
|
+
INPUT
|
79
|
+
output = <<~OUTPUT
|
80
|
+
#{BLANK_HDR}
|
81
|
+
<sections>
|
82
|
+
<figure id="_">
|
83
|
+
<image src="spec/assets/_.png" id="_" mimetype="image/png" height="auto" width="auto"/>
|
84
|
+
</figure>
|
85
|
+
</sections>
|
86
|
+
</standard-document>
|
87
|
+
OUTPUT
|
88
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))
|
89
|
+
.gsub(%r{spec/assets/[^./]+\.}, "spec/assets/_.")))
|
90
|
+
.to be_equivalent_to xmlpp(output)
|
91
|
+
end
|
85
92
|
|
86
|
-
context
|
93
|
+
context "when lutaml_diagram" do
|
87
94
|
let(:input) do
|
88
95
|
<<~"OUTPUT"
|
89
96
|
= Document title
|
@@ -106,13 +113,13 @@ OUTPUT
|
|
106
113
|
end
|
107
114
|
let(:output) do
|
108
115
|
<<~"OUTPUT"
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
+
#{BLANK_HDR}
|
117
|
+
<sections>
|
118
|
+
<figure id="_">
|
119
|
+
<image src="spec/assets/_.png" id="_" mimetype="image/png" height="auto" width="auto"/>
|
120
|
+
</figure>
|
121
|
+
</sections>
|
122
|
+
</standard-document>
|
116
123
|
OUTPUT
|
117
124
|
end
|
118
125
|
|
@@ -120,12 +127,54 @@ OUTPUT
|
|
120
127
|
expect(
|
121
128
|
xmlpp(
|
122
129
|
strip_guid(Asciidoctor.convert(input, *OPTIONS))
|
123
|
-
.gsub(%r{".+spec
|
124
|
-
|
130
|
+
.gsub(%r{".+spec/assets/lutaml/[^./]+\.},
|
131
|
+
'"spec/assets/_.'),
|
132
|
+
),
|
133
|
+
)
|
134
|
+
.to(be_equivalent_to(xmlpp(output)))
|
135
|
+
end
|
136
|
+
|
137
|
+
context "when inline macro, path supplied as the second arg" do
|
138
|
+
let(:example_file) { fixtures_path('diagram_definitions.lutaml') }
|
139
|
+
let(:input) do
|
140
|
+
<<~TEXT
|
141
|
+
= Document title
|
142
|
+
Author
|
143
|
+
:docfile: test.adoc
|
144
|
+
:nodoc:
|
145
|
+
:novalid:
|
146
|
+
:no-isobib:
|
147
|
+
:imagesdir: spec/assets
|
148
|
+
|
149
|
+
lutaml_diagram::#{example_file}[]
|
150
|
+
|
151
|
+
TEXT
|
152
|
+
end
|
153
|
+
let(:output) do
|
154
|
+
<<~TEXT
|
155
|
+
#{BLANK_HDR}
|
156
|
+
<sections>
|
157
|
+
<figure id="_">
|
158
|
+
<image src="spec/assets/_.png" id="_" mimetype="image/png" height="auto" width="auto"/>
|
159
|
+
</figure>
|
160
|
+
</sections>
|
161
|
+
</standard-document>
|
162
|
+
TEXT
|
163
|
+
end
|
164
|
+
|
165
|
+
it "correctly renders input" do
|
166
|
+
expect(
|
167
|
+
xmlpp(
|
168
|
+
strip_guid(Asciidoctor.convert(input, *OPTIONS))
|
169
|
+
.gsub(%r{".+spec/assets/lutaml/[^./]+\.},
|
170
|
+
'"spec/assets/_.'),
|
171
|
+
),
|
172
|
+
).to(be_equivalent_to(xmlpp(output)))
|
173
|
+
end
|
125
174
|
end
|
126
175
|
end
|
127
176
|
|
128
|
-
context
|
177
|
+
context "when lutaml_uml_attributes_table" do
|
129
178
|
let(:example_file) { fixtures_path("diagram_definitions.lutaml") }
|
130
179
|
let(:input) do
|
131
180
|
<<~"OUTPUT"
|
@@ -142,59 +191,61 @@ OUTPUT
|
|
142
191
|
end
|
143
192
|
let(:output) do
|
144
193
|
<<~"OUTPUT"
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
194
|
+
#{BLANK_HDR}
|
195
|
+
<sections>
|
196
|
+
<clause id='_' inline-header='false' obligation='normative'>
|
197
|
+
<title>AttributeProfile</title>
|
198
|
+
<table id='_'>
|
199
|
+
<name>AttributeProfile attributes</name>
|
200
|
+
<thead>
|
201
|
+
<tr>
|
202
|
+
<th valign='top' align='left'>Name</th>
|
203
|
+
<th valign='top' align='left'>Definition</th>
|
204
|
+
<th valign='top' align='left'>Mandatory/ Optional/ Conditional</th>
|
205
|
+
<th valign='top' align='left'>Max Occur</th>
|
206
|
+
<th valign='top' align='left'>Data Type</th>
|
207
|
+
</tr>
|
208
|
+
</thead>
|
209
|
+
<tbody>
|
210
|
+
<tr>
|
211
|
+
<td valign='top' align='left'>addressClassProfile</td>
|
212
|
+
<td valign='top' align='left'></td>
|
213
|
+
<td valign='top' align='left'>O</td>
|
214
|
+
<td valign='top' align='left'>1</td>
|
215
|
+
<td valign='top' align='left'>
|
216
|
+
<tt>CharacterString</tt>
|
217
|
+
</td>
|
218
|
+
</tr>
|
219
|
+
<tr>
|
220
|
+
<td valign='top' align='left'>imlicistAttributeProfile</td>
|
221
|
+
<td valign='top' align='left'>this is attribute definition with multiply lines</td>
|
222
|
+
<td valign='top' align='left'>O</td>
|
223
|
+
<td valign='top' align='left'>1</td>
|
224
|
+
<td valign='top' align='left'>
|
225
|
+
<tt>CharacterString</tt>
|
226
|
+
</td>
|
227
|
+
</tr>
|
228
|
+
</tbody>
|
229
|
+
</table>
|
230
|
+
</clause>
|
231
|
+
</sections>
|
232
|
+
</standard-document>
|
184
233
|
OUTPUT
|
185
234
|
end
|
186
235
|
|
187
236
|
it "processes the lutaml_uml_attributes_table macro" do
|
188
237
|
expect(
|
189
238
|
xmlpp(
|
190
|
-
strip_guid(Asciidoctor.convert(input, *OPTIONS))
|
239
|
+
strip_guid(Asciidoctor.convert(input, *OPTIONS)),
|
240
|
+
),
|
241
|
+
)
|
191
242
|
.to(be_equivalent_to(xmlpp(output)))
|
192
243
|
end
|
193
244
|
end
|
194
245
|
|
195
246
|
it "processes the PlantUML macro with PlantUML disabled" do
|
196
247
|
mock_plantuml_disabled
|
197
|
-
|
248
|
+
input = <<~INPUT
|
198
249
|
#{ASCIIDOC_BLANK_HDR}
|
199
250
|
|
200
251
|
[plantuml]
|
@@ -208,9 +259,11 @@ OUTPUT
|
|
208
259
|
@enduml
|
209
260
|
....
|
210
261
|
INPUT
|
262
|
+
expect { Asciidoctor.convert(input, *OPTIONS) }
|
263
|
+
.to output(%r{PlantUML not installed}).to_stderr
|
211
264
|
|
212
265
|
mock_plantuml_disabled
|
213
|
-
|
266
|
+
input = <<~INPUT
|
214
267
|
#{ASCIIDOC_BLANK_HDR}
|
215
268
|
|
216
269
|
[plantuml]
|
@@ -224,23 +277,26 @@ OUTPUT
|
|
224
277
|
@enduml
|
225
278
|
....
|
226
279
|
INPUT
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
Alice
|
235
|
-
|
236
|
-
|
237
|
-
|
280
|
+
output = <<~OUTPUT
|
281
|
+
#{BLANK_HDR}
|
282
|
+
<sections>
|
283
|
+
<sourcecode id="_" lang="plantuml">@startuml
|
284
|
+
Alice -> Bob: Authentication Request
|
285
|
+
Bob --> Alice: Authentication Response
|
286
|
+
|
287
|
+
Alice -> Bob: Another authentication Request
|
288
|
+
Alice <-- Bob: another authentication Response
|
289
|
+
@enduml</sourcecode>
|
290
|
+
</sections>
|
291
|
+
</standard-document>
|
238
292
|
OUTPUT
|
293
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
294
|
+
.to be_equivalent_to xmlpp(output)
|
239
295
|
end
|
240
296
|
|
241
297
|
it "processes the PlantUML macro with localdir unwritable" do
|
242
298
|
mock_localdir_unwritable
|
243
|
-
|
299
|
+
input = <<~INPUT
|
244
300
|
#{ASCIIDOC_BLANK_HDR}
|
245
301
|
|
246
302
|
[plantuml]
|
@@ -254,9 +310,11 @@ Alice <-- Bob: another authentication Response
|
|
254
310
|
@enduml
|
255
311
|
....
|
256
312
|
INPUT
|
313
|
+
expect { Asciidoctor.convert(input, *OPTIONS) }
|
314
|
+
.to output(%r{not writable for PlantUML}).to_stderr
|
257
315
|
|
258
316
|
mock_localdir_unwritable
|
259
|
-
|
317
|
+
input = <<~INPUT
|
260
318
|
#{ASCIIDOC_BLANK_HDR}
|
261
319
|
|
262
320
|
[plantuml]
|
@@ -270,26 +328,29 @@ Alice <-- Bob: another authentication Response
|
|
270
328
|
@enduml
|
271
329
|
....
|
272
330
|
INPUT
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
Alice
|
281
|
-
|
282
|
-
|
283
|
-
|
331
|
+
output = <<~OUTPUT
|
332
|
+
#{BLANK_HDR}
|
333
|
+
<sections>
|
334
|
+
<sourcecode id="_" lang="plantuml">@startuml
|
335
|
+
Alice -> Bob: Authentication Request
|
336
|
+
Bob --> Alice: Authentication Response
|
337
|
+
|
338
|
+
Alice -> Bob: Another authentication Request
|
339
|
+
Alice <-- Bob: another authentication Response
|
340
|
+
@enduml</sourcecode>
|
341
|
+
</sections>
|
342
|
+
</standard-document>
|
284
343
|
OUTPUT
|
344
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
345
|
+
.to be_equivalent_to xmlpp(output)
|
285
346
|
end
|
286
347
|
|
287
348
|
private
|
288
349
|
|
289
350
|
def mock_plantuml_disabled
|
290
|
-
expect(Asciidoctor::Standoc::PlantUMLBlockMacroBackend)
|
351
|
+
expect(Asciidoctor::Standoc::PlantUMLBlockMacroBackend)
|
352
|
+
.to receive(:plantuml_installed?) do
|
291
353
|
raise "PlantUML not installed"
|
292
|
-
false
|
293
354
|
end
|
294
355
|
end
|
295
356
|
|