metanorma-standoc 1.10.2 → 1.10.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -316,6 +316,40 @@ 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
+ INPUT
327
+ output = <<~OUTPUT
328
+ #{BLANK_HDR}
329
+ <sections>
330
+ <p id='_'>
331
+ &#8220;ppt&#8221;,
332
+ <index>
333
+ <primary>ppt</primary>
334
+ </index>
335
+ </p>
336
+ <p id='_'>
337
+ &#8220;ppm&#8221;,
338
+ <index>
339
+ <primary>ppm</primary>
340
+ </index>
341
+ &#8220;ppt&#8221;
342
+ <index>
343
+ <primary>ppt</primary>
344
+ </index>
345
+ </p>
346
+ </sections>
347
+ </standard-document>
348
+ OUTPUT
349
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
350
+ .to be_equivalent_to xmlpp(output)
351
+ end
352
+
319
353
  it "removes empty text elements" do
320
354
  input = <<~INPUT
321
355
  #{ASCIIDOC_BLANK_HDR}
@@ -486,7 +520,7 @@ RSpec.describe Asciidoctor::Standoc do
486
520
  output = <<~OUTPUT
487
521
  #{BLANK_HDR}
488
522
  <sections><formula id="_">
489
- <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>
523
+ <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
524
  <note id="_">
491
525
  <p id="_">That formula does not do much</p>
492
526
  </note></formula>
@@ -517,7 +551,7 @@ RSpec.describe Asciidoctor::Standoc do
517
551
  output = <<~OUTPUT
518
552
  #{BLANK_HDR}
519
553
  <sections><formula id="_">
520
- <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></formula>
554
+ <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
555
  <note id="_">
522
556
  <p id="_">That formula does not do much</p>
523
557
  </note>
@@ -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
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", *OPTIONS)).gsub(%r{plantuml/plantuml[^./]+\.}, "plantuml/_."))).to be_equivalent_to xmlpp(<<~"OUTPUT")
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
- #{BLANK_HDR}
40
- <sections><figure id="_">
41
- <image src="plantuml/_.png" id="_" mimetype="image/png" height="auto" width="auto"/>
42
- </figure>
43
- <figure id="_">
44
- <image src="plantuml/_.png" id="_" mimetype="image/png" height="auto" width="auto"/>
45
- </figure>
46
- <figure id="_">
47
- <image src="plantuml/filename.png" id="_" mimetype="image/png" height="auto" width="auto"/>
48
- </figure>
49
- </sections>
50
-
51
- </standard-document>
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
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", *OPTIONS)).gsub(%r{spec/assets/[^./]+\.}, "spec/assets/_."))).to be_equivalent_to xmlpp(<<~"OUTPUT")
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
- INPUT
76
- #{BLANK_HDR}
77
- <sections>
78
- <figure id="_">
79
- <image src="spec/assets/_.png" id="_" mimetype="image/png" height="auto" width="auto"/>
80
- </figure>
81
- </sections>
82
- </standard-document>
83
- OUTPUT
84
- end
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 'when lutaml_diagram' do
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
- #{BLANK_HDR}
110
- <sections>
111
- <figure id="_">
112
- <image src="spec/assets/_.png" id="_" mimetype="image/png" height="auto" width="auto"/>
113
- </figure>
114
- </sections>
115
- </standard-document>
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\/assets\/lutaml\/[^.\/]+\.}, %q("spec/assets/_.))))
124
- .to(be_equivalent_to xmlpp(output))
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 'when lutaml_uml_attributes_table' do
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
- #{BLANK_HDR}
146
- <sections>
147
- <clause id='_' inline-header='false' obligation='normative'>
148
- <title>AttributeProfile</title>
149
- <table id='_'>
150
- <name>AttributeProfile attributes</name>
151
- <thead>
152
- <tr>
153
- <th valign='top' align='left'>Name</th>
154
- <th valign='top' align='left'>Definition</th>
155
- <th valign='top' align='left'>Mandatory/ Optional/ Conditional</th>
156
- <th valign='top' align='left'>Max Occur</th>
157
- <th valign='top' align='left'>Data Type</th>
158
- </tr>
159
- </thead>
160
- <tbody>
161
- <tr>
162
- <td valign='top' align='left'>addressClassProfile</td>
163
- <td valign='top' align='left'>TODO: enum ‘s definition</td>
164
- <td valign='top' align='left'>O</td>
165
- <td valign='top' align='left'>1</td>
166
- <td valign='top' align='left'>
167
- <tt>CharacterString</tt>
168
- </td>
169
- </tr>
170
- <tr>
171
- <td valign='top' align='left'>imlicistAttributeProfile</td>
172
- <td valign='top' align='left'>this is attribute definition with multiply lines</td>
173
- <td valign='top' align='left'>O</td>
174
- <td valign='top' align='left'>1</td>
175
- <td valign='top' align='left'>
176
- <tt>CharacterString</tt>
177
- </td>
178
- </tr>
179
- </tbody>
180
- </table>
181
- </clause>
182
- </sections>
183
- </standard-document>
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
- expect { Asciidoctor.convert(<<~"INPUT", *OPTIONS) }.to output(%r{PlantUML not installed}).to_stderr
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
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", *OPTIONS)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
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
- #{BLANK_HDR}
228
- <sections>
229
- <sourcecode id="_" lang="plantuml">@startuml
230
- Alice -&gt; Bob: Authentication Request
231
- Bob --&gt; Alice: Authentication Response
232
-
233
- Alice -&gt; Bob: Another authentication Request
234
- Alice &lt;-- Bob: another authentication Response
235
- @enduml</sourcecode>
236
- </sections>
237
- </standard-document>
280
+ output = <<~OUTPUT
281
+ #{BLANK_HDR}
282
+ <sections>
283
+ <sourcecode id="_" lang="plantuml">@startuml
284
+ Alice -&gt; Bob: Authentication Request
285
+ Bob --&gt; Alice: Authentication Response
286
+
287
+ Alice -&gt; Bob: Another authentication Request
288
+ Alice &lt;-- 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
- expect { Asciidoctor.convert(<<~"INPUT", *OPTIONS) }.to output(%r{not writable for PlantUML}).to_stderr
299
+ input = <<~INPUT
244
300
  #{ASCIIDOC_BLANK_HDR}
245
301
 
246
302
  [plantuml]
@@ -254,9 +310,11 @@ Alice &lt;-- 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
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", *OPTIONS)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
317
+ input = <<~INPUT
260
318
  #{ASCIIDOC_BLANK_HDR}
261
319
 
262
320
  [plantuml]
@@ -270,26 +328,29 @@ Alice &lt;-- Bob: another authentication Response
270
328
  @enduml
271
329
  ....
272
330
  INPUT
273
- #{BLANK_HDR}
274
- <sections>
275
- <sourcecode id="_" lang="plantuml">@startuml
276
- Alice -&gt; Bob: Authentication Request
277
- Bob --&gt; Alice: Authentication Response
278
-
279
- Alice -&gt; Bob: Another authentication Request
280
- Alice &lt;-- Bob: another authentication Response
281
- @enduml</sourcecode>
282
- </sections>
283
- </standard-document>
331
+ output = <<~OUTPUT
332
+ #{BLANK_HDR}
333
+ <sections>
334
+ <sourcecode id="_" lang="plantuml">@startuml
335
+ Alice -&gt; Bob: Authentication Request
336
+ Bob --&gt; Alice: Authentication Response
337
+
338
+ Alice -&gt; Bob: Another authentication Request
339
+ Alice &lt;-- 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).to receive(:plantuml_installed?) do
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
 
@@ -1131,6 +1131,105 @@ RSpec.describe Asciidoctor::Standoc do
1131
1131
  .to be_equivalent_to xmlpp(output)
1132
1132
  end
1133
1133
 
1134
+ it "processes ToC form macros" do
1135
+ input = <<~INPUT
1136
+ #{ASCIIDOC_BLANK_HDR}
1137
+
1138
+ [[clause1]]
1139
+ == Clause 1
1140
+
1141
+ [[clause1A]]
1142
+ === Clause 1A
1143
+
1144
+ [[clause1Aa]]
1145
+ ==== Clause 1Aa
1146
+
1147
+ [[clause1Ab]]
1148
+ ==== Clause 1Ab
1149
+
1150
+ [[clause1B]]
1151
+ === Clause 1B
1152
+
1153
+ [[clause1Ba]]
1154
+ ==== Clause 1Ba
1155
+
1156
+ [[clause2]]
1157
+ == Clause 2
1158
+
1159
+ And introducing:
1160
+ toc:["//clause[@id = 'clause1'\\]/clause/title","//clause[@id = 'clause1'\\]/clause/clause/title:2"]
1161
+
1162
+ toc:["//clause[@id = 'clause1'\\]/clause/title"]
1163
+ INPUT
1164
+ output = <<~OUTPUT
1165
+ #{BLANK_HDR}
1166
+ <sections>
1167
+ <clause id='clause1' inline-header='false' obligation='normative'>
1168
+ <title>Clause 1</title>
1169
+ <clause id='clause1A' inline-header='false' obligation='normative'>
1170
+ <title>Clause 1A</title>
1171
+ <clause id='clause1Aa' inline-header='false' obligation='normative'>
1172
+ <title>Clause 1Aa</title>
1173
+ </clause>
1174
+ <clause id='clause1Ab' inline-header='false' obligation='normative'>
1175
+ <title>Clause 1Ab</title>
1176
+ </clause>
1177
+ </clause>
1178
+ <clause id='clause1B' inline-header='false' obligation='normative'>
1179
+ <title>Clause 1B</title>
1180
+ <clause id='clause1Ba' inline-header='false' obligation='normative'>
1181
+ <title>Clause 1Ba</title>
1182
+ </clause>
1183
+ </clause>
1184
+ </clause>
1185
+ <clause id='clause2' inline-header='false' obligation='normative'>
1186
+ <title>Clause 2</title>
1187
+ <p id='_'>And introducing: </p>
1188
+ <toc>
1189
+ <ul id='_'>
1190
+ <li>
1191
+ <xref target='clause1A'>Clause 1A</xref>
1192
+ </li>
1193
+ <li>
1194
+ <ul id='_'>
1195
+ <li>
1196
+ <xref target='clause1Aa'>Clause 1Aa</xref>
1197
+ </li>
1198
+ <li>
1199
+ <xref target='clause1Ab'>Clause 1Ab</xref>
1200
+ </li>
1201
+ </ul>
1202
+ </li>
1203
+ <li>
1204
+ <xref target='clause1B'>Clause 1B</xref>
1205
+ </li>
1206
+ <li>
1207
+ <ul id='_'>
1208
+ <li>
1209
+ <xref target='clause1Ba'>Clause 1Ba</xref>
1210
+ </li>
1211
+ </ul>
1212
+ </li>
1213
+ </ul>
1214
+ </toc>
1215
+ <toc>
1216
+ <ul id='_'>
1217
+ <li>
1218
+ <xref target='clause1A'>Clause 1A</xref>
1219
+ </li>
1220
+ <li>
1221
+ <xref target='clause1B'>Clause 1B</xref>
1222
+ </li>
1223
+ </ul>
1224
+ </toc>
1225
+ </clause>
1226
+ </sections>
1227
+ </standard-document>
1228
+ OUTPUT
1229
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
1230
+ .to be_equivalent_to xmlpp(output)
1231
+ end
1232
+
1134
1233
  describe "term inline macros" do
1135
1234
  subject(:convert) do
1136
1235
  xmlpp(