metanorma-standoc 1.9.3 → 1.10.2

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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +3 -13
  3. data/.hound.yml +3 -1
  4. data/.rubocop.yml +4 -6
  5. data/lib/asciidoctor/standoc/base.rb +3 -1
  6. data/lib/asciidoctor/standoc/blocks.rb +1 -1
  7. data/lib/asciidoctor/standoc/cleanup.rb +1 -2
  8. data/lib/asciidoctor/standoc/cleanup_block.rb +0 -1
  9. data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +2 -2
  10. data/lib/asciidoctor/standoc/cleanup_footnotes.rb +0 -1
  11. data/lib/asciidoctor/standoc/cleanup_inline.rb +117 -77
  12. data/lib/asciidoctor/standoc/cleanup_maths.rb +0 -1
  13. data/lib/asciidoctor/standoc/cleanup_ref.rb +7 -0
  14. data/lib/asciidoctor/standoc/cleanup_section.rb +13 -81
  15. data/lib/asciidoctor/standoc/cleanup_section_names.rb +75 -0
  16. data/lib/asciidoctor/standoc/cleanup_terms.rb +19 -18
  17. data/lib/asciidoctor/standoc/converter.rb +1 -0
  18. data/lib/asciidoctor/standoc/front.rb +0 -1
  19. data/lib/asciidoctor/standoc/front_contributor.rb +66 -42
  20. data/lib/asciidoctor/standoc/inline.rb +45 -34
  21. data/lib/asciidoctor/standoc/isodoc.rng +65 -7
  22. data/lib/asciidoctor/standoc/macros.rb +7 -5
  23. data/lib/asciidoctor/standoc/macros_plantuml.rb +21 -23
  24. data/lib/asciidoctor/standoc/macros_terms.rb +60 -23
  25. data/lib/asciidoctor/standoc/section.rb +19 -12
  26. data/lib/asciidoctor/standoc/term_lookup_cleanup.rb +69 -30
  27. data/lib/asciidoctor/standoc/terms.rb +1 -1
  28. data/lib/asciidoctor/standoc/utils.rb +0 -1
  29. data/lib/asciidoctor/standoc/validate.rb +22 -8
  30. data/lib/isodoc/html/html_titlepage.html +81 -0
  31. data/lib/isodoc/html/htmlstyle.css +983 -0
  32. data/lib/isodoc/html/htmlstyle.scss +714 -0
  33. data/lib/isodoc/html/scripts.html +71 -0
  34. data/lib/metanorma/standoc/processor.rb +16 -7
  35. data/lib/metanorma/standoc/version.rb +1 -1
  36. data/metanorma-standoc.gemspec +2 -2
  37. data/spec/asciidoctor/base_spec.rb +693 -553
  38. data/spec/asciidoctor/blocks_spec.rb +6 -6
  39. data/spec/asciidoctor/cleanup_spec.rb +899 -688
  40. data/spec/asciidoctor/inline_spec.rb +62 -14
  41. data/spec/asciidoctor/isobib_cache_spec.rb +4 -6
  42. data/spec/asciidoctor/lists_spec.rb +147 -135
  43. data/spec/asciidoctor/macros_json2text_spec.rb +1 -1
  44. data/spec/asciidoctor/macros_spec.rb +714 -168
  45. data/spec/asciidoctor/refs_spec.rb +1527 -1532
  46. data/spec/asciidoctor/validate_spec.rb +352 -304
  47. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +51 -51
  48. data/spec/vcr_cassettes/isobib_get_123.yml +14 -14
  49. data/spec/vcr_cassettes/isobib_get_123_1.yml +27 -27
  50. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +36 -36
  51. data/spec/vcr_cassettes/isobib_get_123_2001.yml +12 -12
  52. data/spec/vcr_cassettes/isobib_get_124.yml +13 -13
  53. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +14 -14
  54. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +46 -46
  55. metadata +10 -5
@@ -4,38 +4,45 @@ require "fileutils"
4
4
 
5
5
  RSpec.describe Asciidoctor::Standoc do
6
6
  it "generates error file" do
7
- FileUtils.rm_f "spec/assets/xref_error.err"
8
- Asciidoctor.convert_file "spec/assets/xref_error.adoc", {:attributes=>{"backend"=>"standoc"}, :safe=>0, :header_footer=>true, :requires=>["metanorma-standoc"], :failure_level=>4, :mkdirs=>true, :to_file=>nil}
9
- expect(File.exist?("spec/assets/xref_error.err")).to be true
7
+ FileUtils.rm_f "spec/assets/xref_error.err"
8
+ Asciidoctor.convert_file "spec/assets/xref_error.adoc",
9
+ { attributes: { "backend" => "standoc" }, safe: 0,
10
+ header_footer: true,
11
+ requires: ["metanorma-standoc"],
12
+ failure_level: 4, mkdirs: true, to_file: nil }
13
+ expect(File.exist?("spec/assets/xref_error.err")).to be true
10
14
  end
11
15
 
12
16
  it "provides context for log" do
13
- FileUtils.rm_f "test.xml"
14
- FileUtils.rm_f "test.err"
15
- begin
16
- expect { Asciidoctor.convert(<<~"INPUT", *OPTIONS) }.to raise_error(SystemExit)
17
- = Document title
18
- Author
19
- :docfile: test.adoc
20
- :nodoc:
21
-
22
- [[abc]]
23
- == Clause 1
24
-
25
- [[abc]]
26
- == Clause 2
27
- INPUT
28
- rescue SystemExit
17
+ FileUtils.rm_f "test.xml"
18
+ FileUtils.rm_f "test.err"
19
+ begin
20
+ input = <<~INPUT
21
+ = Document title
22
+ Author
23
+ :docfile: test.adoc
24
+ :nodoc:
25
+
26
+ [[abc]]
27
+ == Clause 1
28
+
29
+ [[abc]]
30
+ == Clause 2
31
+ INPUT
32
+ expect { Asciidoctor.convert(input, *OPTIONS) }.to raise_error(SystemExit)
33
+ rescue SystemExit
34
+ end
35
+ expect(File.read("test.err"))
36
+ .to include "Anchor abc has already been used at line"
37
+ expect(File.read("test.err"))
38
+ .to include %(\t<clause id="abc" inline-header="false" obligation="normative">)
29
39
  end
30
- expect(File.read("test.err")).to include "Anchor abc has already been used at line"
31
- expect(File.read("test.err")).to include %(\t<clause id="abc" inline-header="false" obligation="normative">)
32
- end
33
40
 
34
41
  it "warns about missing fields in asciibib" do
35
- FileUtils.rm_f "test.err"
36
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
42
+ FileUtils.rm_f "test.err"
43
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
37
44
  #{VALIDATING_BLANK_HDR}
38
-
45
+
39
46
  [bibliography]
40
47
  == Normative References
41
48
 
@@ -43,7 +50,7 @@ end
43
50
  === Standard
44
51
  id:: iso123
45
52
  type:: standard
46
- contributor::
53
+ contributor::
47
54
  role::: publisher
48
55
  organization:::
49
56
  name:::: ISO
@@ -62,17 +69,17 @@ end
62
69
  person:::
63
70
  name::::
64
71
  completename::::: Jack
65
-
66
72
  INPUT
67
- errf = File.read("test.err")
68
- expect(errf).to include "Reference iso123 is missing a document identifier (docid)"
73
+ errf = File.read("test.err")
74
+ expect(errf)
75
+ .to include "Reference iso123 is missing a document identifier (docid)"
69
76
  end
70
77
 
71
- it "warns about missing fields in asciibib" do
72
- FileUtils.rm_f "test.err"
73
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
78
+ it "warns about missing fields in asciibib" do
79
+ FileUtils.rm_f "test.err"
80
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
74
81
  #{VALIDATING_BLANK_HDR}
75
-
82
+
76
83
  [bibliography]
77
84
  == Normative References
78
85
 
@@ -83,10 +90,10 @@ end
83
90
  role::: publisher
84
91
  organization:::
85
92
  name:::: ISO
86
- INPUT
87
- errf = File.read("test.err")
88
- expect(errf).to include "The following reference is missing an anchor"
89
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
93
+ INPUT
94
+ errf = File.read("test.err")
95
+ expect(errf).to include "The following reference is missing an anchor"
96
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
90
97
  #{VALIDATING_BLANK_HDR}
91
98
 
92
99
  [bibliography]
@@ -100,89 +107,85 @@ INPUT
100
107
  role::: publisher
101
108
  organization:::
102
109
  name:::: ISO
103
- INPUT
104
- errf = File.read("test.err")
105
- expect(errf).not_to include "The following reference is missing an anchor"
106
- end
107
-
108
- =begin
109
- it "warns about malformed LaTeX" do
110
- FileUtils.rm_f "test.err"
111
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
112
- #{VALIDATING_BLANK_HDR}
113
-
114
- == Clause 1
115
-
116
- latexmath:[\\[ \\text{Odd integer = 51, \\quad \\text{Even integers } = 50 \\]]
117
-
118
- === Clause 1.1
119
-
120
- Subclause
121
- INPUT
122
- expect(File.read("test.err")).to include "latexmlmath failed to process equation"
110
+ INPUT
111
+ errf = File.read("test.err")
112
+ expect(errf).not_to include "The following reference is missing an anchor"
123
113
  end
124
- =end
125
-
126
- =begin
127
- it "warns about reparsing LaTeX" do
128
- FileUtils.rm_f "test.err"
129
- expect { Asciidoctor.convert(<<~"INPUT", *OPTIONS) }.to output(/Retrying/).to_stderr
130
- #{VALIDATING_BLANK_HDR}
131
-
132
- == Clause 1
133
-
134
- [latexmath]
135
- ++++
136
- \\pmatrix{ \\hat{e}_{\\xi} \\cr \\hat{e}_{\\eta}
137
- \\cr \\hat{e}_{\\zeta} } = {\\bf T} \\pmatrix{ \\hat{e}_x \\cr \\hat{e}_y \\cr \\hat{e}_z },
138
- ++++
139
114
 
140
- === Clause 1.1
141
-
142
- Subclause
143
- INPUT
144
- end
145
- =end
115
+ # it "warns about malformed LaTeX" do
116
+ # FileUtils.rm_f "test.err"
117
+ # Asciidoctor.convert(<<~"INPUT", *OPTIONS)
118
+ # #{VALIDATING_BLANK_HDR}
119
+ #
120
+ # == Clause 1
121
+ #
122
+ # latexmath:[\\[ \\text{Odd integer = 51, \\quad \\text{Even integers } = 50 \\]]
123
+ #
124
+ # === Clause 1.1
125
+ #
126
+ # Subclause
127
+ # INPUT
128
+ # expect(File.read("test.err")).to include "latexmlmath failed to process equation"
129
+ # end
130
+
131
+ # it "warns about reparsing LaTeX" do
132
+ # FileUtils.rm_f "test.err"
133
+ # expect { Asciidoctor.convert(<<~"INPUT", *OPTIONS) }.to output(/Retrying/).to_stderr
134
+ # #{VALIDATING_BLANK_HDR}
135
+ #
136
+ # == Clause 1
137
+ #
138
+ # [latexmath]
139
+ # ++++
140
+ # \\pmatrix{ \\hat{e}_{\\xi} \\cr \\hat{e}_{\\eta}
141
+ # \\cr \\hat{e}_{\\zeta} } = {\\bf T} \\pmatrix{ \\hat{e}_x \\cr \\hat{e}_y \\cr \\hat{e}_z },
142
+ # ++++
143
+ #
144
+ # === Clause 1.1
145
+ #
146
+ # Subclause
147
+ # INPUT
148
+ # end
146
149
 
147
150
  it "warns about hanging paragraphs" do
148
- FileUtils.rm_f "test.err"
149
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
150
- #{VALIDATING_BLANK_HDR}
151
+ FileUtils.rm_f "test.err"
152
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
153
+ #{VALIDATING_BLANK_HDR}
151
154
 
152
- == Clause 1
155
+ == Clause 1
153
156
 
154
- Paragraph
157
+ Paragraph
155
158
 
156
- === Clause 1.1
159
+ === Clause 1.1
157
160
 
158
- Subclause
159
- INPUT
160
- expect(File.read("test.err")).to include "Hanging paragraph in clause"
161
+ Subclause
162
+ INPUT
163
+ expect(File.read("test.err")).to include "Hanging paragraph in clause"
161
164
  end
162
165
 
163
166
  it "warns that video is a skipped node" do
164
- FileUtils.rm_f "test.err"
165
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
166
- #{VALIDATING_BLANK_HDR}
167
+ FileUtils.rm_f "test.err"
168
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
169
+ #{VALIDATING_BLANK_HDR}
167
170
 
168
- video::video_file.mp4[]
169
- INPUT
170
- expect(File.read("test.err")).to include "converter missing for video node"
171
+ video::video_file.mp4[]
172
+ INPUT
173
+ expect(File.read("test.err")).to include "converter missing for video node"
171
174
  end
172
175
 
173
- it "warns that figure does not have title" do
174
- FileUtils.rm_f "test.err"
175
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
176
- #{VALIDATING_BLANK_HDR}
176
+ it "warns that figure does not have title" do
177
+ FileUtils.rm_f "test.err"
178
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
179
+ #{VALIDATING_BLANK_HDR}
177
180
 
178
- image::spec/examples/rice_images/rice_image1.png[]
179
- INPUT
180
- expect(File.read("test.err")).to include "Figure should have title"
181
- end
181
+ image::spec/examples/rice_images/rice_image1.png[]
182
+ INPUT
183
+ expect(File.read("test.err")).to include "Figure should have title"
184
+ end
182
185
 
183
- it "warns that callouts do not match annotations" do
184
- FileUtils.rm_f "test.err"
185
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
186
+ it "warns that callouts do not match annotations" do
187
+ FileUtils.rm_f "test.err"
188
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
186
189
  #{VALIDATING_BLANK_HDR}
187
190
  [source,ruby]
188
191
  --
@@ -193,226 +196,271 @@ it "warns that callouts do not match annotations" do
193
196
  --
194
197
  <1> This is one callout
195
198
  <2> This is another callout
196
- INPUT
197
- expect(File.read("test.err")).to include "mismatch of callouts and annotations"
198
- end
199
+ INPUT
200
+ expect(File.read("test.err"))
201
+ .to include "mismatch of callouts and annotations"
202
+ end
199
203
 
200
- it "warns that term source is not a real reference" do
201
- FileUtils.rm_f "test.err"
202
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
203
- #{VALIDATING_BLANK_HDR}
204
+ it "warns that term source is not a real reference" do
205
+ FileUtils.rm_f "test.err"
206
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
207
+ #{VALIDATING_BLANK_HDR}
204
208
 
205
- [.source]
206
- <<iso123>>
207
- INPUT
208
- expect(File.read("test.err")).to include "iso123 does not have a corresponding anchor ID in the bibliography"
209
- end
209
+ [.source]
210
+ <<iso123>>
211
+ INPUT
212
+ expect(File.read("test.err"))
213
+ .to include "iso123 does not have a corresponding anchor ID in the bibliography"
214
+ end
210
215
 
211
- it "warns of Non-reference in bibliography" do
212
- FileUtils.rm_f "test.err"
213
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
214
- #{VALIDATING_BLANK_HDR}
216
+ it "warns of Non-reference in bibliography" do
217
+ FileUtils.rm_f "test.err"
218
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
219
+ #{VALIDATING_BLANK_HDR}
215
220
 
216
- == Normative References
217
- * I am not a reference
218
- INPUT
219
- expect(File.read("test.err")).to include "no anchor on reference"
220
- end
221
+ == Normative References
222
+ * I am not a reference
223
+ INPUT
224
+ expect(File.read("test.err")).to include "no anchor on reference"
225
+ end
221
226
 
222
- it "warns that Table should have title" do
223
- FileUtils.rm_f "test.err"
224
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
225
- #{VALIDATING_BLANK_HDR}
227
+ it "warns that Table should have title" do
228
+ FileUtils.rm_f "test.err"
229
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
230
+ #{VALIDATING_BLANK_HDR}
226
231
 
227
- |===
228
- |a |b |c
229
- |===
230
- INPUT
231
- expect(File.read("test.err")).to include "Table should have title"
232
- end
232
+ |===
233
+ |a |b |c
234
+ |===
235
+ INPUT
236
+ expect(File.read("test.err")).to include "Table should have title"
237
+ end
233
238
 
234
- it "validates document against ISO XML schema" do
235
- FileUtils.rm_f "test.err"
236
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
237
- #{VALIDATING_BLANK_HDR}
239
+ it "validates document against ISO XML schema" do
240
+ FileUtils.rm_f "test.err"
241
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
242
+ #{VALIDATING_BLANK_HDR}
238
243
 
239
- [align=mid-air]
240
- Para
241
- INPUT
242
- expect(File.read("test.err")).to include 'value of attribute "align" is invalid; must be equal to'
243
- end
244
+ [align=mid-air]
245
+ Para
246
+ INPUT
247
+ expect(File.read("test.err"))
248
+ .to include 'value of attribute "align" is invalid; must be equal to'
249
+ end
244
250
 
245
- it "Warning if terms mismatches IEV" do
246
- FileUtils.rm_f "test.err"
247
- FileUtils.mv File.expand_path("~/.iev/cache"), File.expand_path("~/.iev.pstore1"), force: true
248
- FileUtils.rm_f "test_iev/pstore"
249
- mock_open_uri('103-01-02')
250
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
251
- = Document title
252
- Author
253
- :docfile: test.adoc
254
-
255
- [bibliography]
256
- == Normative References
257
- * [[[iev,IEV]]], _iev_
258
-
259
- == Terms and definitions
260
- === Automation
261
-
262
- [.source]
263
- <<iev,clause="103-01-02">>
264
- INPUT
265
- expect(File.read("test.err")).to include 'Term "automation" does not match IEV 103-01-02 "functional"'
266
- FileUtils.mv File.expand_path("~/.iev.pstore1"), File.expand_path("~/.iev/cache"), force: true
267
- end
251
+ it "Warning if terms mismatches IEV" do
252
+ FileUtils.rm_f "test.err"
253
+ FileUtils.mv File.expand_path("~/.iev/cache"),
254
+ File.expand_path("~/.iev.pstore1"), force: true
255
+ FileUtils.rm_f "test_iev/pstore"
256
+ mock_open_uri("103-01-02")
257
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
258
+ = Document title
259
+ Author
260
+ :docfile: test.adoc
268
261
 
269
- it "No warning if English term matches IEV" do
270
- FileUtils.rm_f "test.err"
271
- FileUtils.mv File.expand_path("~/.iev/cache"), File.expand_path("~/.iev.pstore1"), force: true
272
- FileUtils.rm_f "test_iev/cache"
273
- mock_open_uri('103-01-02')
274
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
275
- = Document title
276
- Author
277
- :docfile: test.adoc
278
-
279
- [bibliography]
280
- == Normative References
281
- * [[[iev,IEV]]], _iev_
282
-
283
- == Terms and definitions
284
- === Functional
285
-
286
- [.source]
287
- <<iev,clause="103-01-02">>
288
- INPUT
289
- expect(File.read("test.err")).not_to include "does not match IEV 103-01-02"
290
- FileUtils.mv File.expand_path("~/.iev.pstore1"), File.expand_path("~/.iev/cache"), force: true
291
- end
262
+ [bibliography]
263
+ == Normative References
264
+ * [[[iev,IEV]]], _iev_
292
265
 
293
- it "No warning if French term matches IEV" do
294
- FileUtils.rm_f "test.err"
295
- FileUtils.mv File.expand_path("~/.iev/cache"), File.expand_path("~/.iev.pstore1"), force: true
296
- FileUtils.rm_f "test_iev/cache"
297
- mock_open_uri('103-01-02')
298
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
299
- = Document title
300
- Author
301
- :docfile: test.adoc
302
- :nodoc:
303
- :language: fr
304
-
305
- [bibliography]
306
- == Normative References
307
- * [[[iev,IEV]]], _iev_
308
-
309
- == Terms and definitions
310
- === Fonctionnelle, f
311
-
312
- [.source]
313
- <<iev,clause="103-01-02">>
314
- INPUT
315
- expect(File.read("test.err")).not_to include "does not match IEV 103-01-02"
316
- FileUtils.mv File.expand_path("~/.iev.pstore1"), File.expand_path("~/.iev/cache"), force: true
317
- end
266
+ == Terms and definitions
267
+ === Automation
318
268
 
319
- =begin
320
- it "No warning if attributes on formatted strong or stem extraneous to Metanomra XML" do
321
- expect { Asciidoctor::Standoc::Converter.new(nil,nil).validate(Nokogiri::XML(<<~INPUT)) }.not_to output('found attribute "close", but no attributes allowed here').to_stderr
322
- <standard-document>
323
- <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mfenced open="(" close=")"><mi>r</mi></mfenced></stem>
324
- </standard-document>
325
- INPUT
326
- end
327
- =end
328
-
329
- it "warns and aborts if id used twice" do
330
- FileUtils.rm_f "test.xml"
331
- FileUtils.rm_f "test.err"
332
- begin
333
- expect { Asciidoctor.convert(<<~"INPUT", *OPTIONS) }.to raise_error(SystemExit)
334
- = Document title
335
- Author
336
- :docfile: test.adoc
337
- :nodoc:
338
-
339
- [[abc]]
340
- == Clause 1
341
-
342
- [[abc]]
343
- == Clause 2
344
- INPUT
345
- rescue SystemExit
269
+ [.source]
270
+ <<iev,clause="103-01-02">>
271
+ INPUT
272
+ expect(File.read("test.err"))
273
+ .to include 'Term "automation" does not match IEV 103-01-02 "functional"'
274
+ FileUtils.mv File.expand_path("~/.iev.pstore1"),
275
+ File.expand_path("~/.iev/cache"), force: true
346
276
  end
347
- expect(File.read("test.err")).to include "Anchor abc has already been used at line"
348
- expect(File.exist?("test.xml")).to be false
349
- end
350
277
 
351
- it "warns and aborts if numeric normative reference" do
352
- FileUtils.rm_f "test.xml"
353
- FileUtils.rm_f "test.err"
354
- begin
355
- expect { Asciidoctor.convert(<<~"INPUT", *OPTIONS) }.to raise_error(SystemExit)
356
- = Document title
357
- Author
358
- :docfile: test.adoc
359
- :nodoc:
360
-
361
- [bibliography]
362
- == Normative references
363
- * [[[A,1]]]
364
- INPUT
365
- rescue SystemExit
278
+ it "No warning if English term matches IEV" do
279
+ FileUtils.rm_f "test.err"
280
+ FileUtils.mv File.expand_path("~/.iev/cache"),
281
+ File.expand_path("~/.iev.pstore1"), force: true
282
+ FileUtils.rm_f "test_iev/cache"
283
+ mock_open_uri("103-01-02")
284
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
285
+ = Document title
286
+ Author
287
+ :docfile: test.adoc
288
+
289
+ [bibliography]
290
+ == Normative References
291
+ * [[[iev,IEV]]], _iev_
292
+
293
+ == Terms and definitions
294
+ === Functional
295
+
296
+ [.source]
297
+ <<iev,clause="103-01-02">>
298
+ INPUT
299
+ expect(File.read("test.err")).not_to include "does not match IEV 103-01-02"
300
+ FileUtils.mv File.expand_path("~/.iev.pstore1"),
301
+ File.expand_path("~/.iev/cache"), force: true
366
302
  end
367
- expect(File.read("test.err")).to include "Numeric reference in normative references"
368
- expect(File.exist?("test.xml")).to be false
369
- end
370
303
 
371
- it "err file succesfully created for docfile path" do
372
- FileUtils.rm_rf "test"
373
- FileUtils.mkdir_p "test"
374
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
375
- = Document title
376
- Author
377
- :docfile: test#{File::ALT_SEPARATOR || File::SEPARATOR}test.adoc
378
- :nodoc:
379
-
380
- == Clause 1
304
+ it "No warning if French term matches IEV" do
305
+ FileUtils.rm_f "test.err"
306
+ FileUtils.mv File.expand_path("~/.iev/cache"),
307
+ File.expand_path("~/.iev.pstore1"), force: true
308
+ FileUtils.rm_f "test_iev/cache"
309
+ mock_open_uri("103-01-02")
310
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
311
+ = Document title
312
+ Author
313
+ :docfile: test.adoc
314
+ :nodoc:
315
+ :language: fr
381
316
 
382
- Paragraph
317
+ [bibliography]
318
+ == Normative References
319
+ * [[[iev,IEV]]], _iev_
383
320
 
384
- === Clause 1.1
321
+ == Terms and definitions
322
+ === Fonctionnelle, f
385
323
 
386
- Subclause
387
- INPUT
324
+ [.source]
325
+ <<iev,clause="103-01-02">>
326
+ INPUT
327
+ expect(File.read("test.err"))
328
+ .not_to include "does not match IEV 103-01-02"
329
+ FileUtils.mv File.expand_path("~/.iev.pstore1"), File.expand_path("~/.iev/cache"), force: true
330
+ end
388
331
 
389
- expect(File.read("test/test.err")).to include "Hanging paragraph in clause"
390
- end
332
+ # it "No warning if attributes on formatted strong or stem extraneous to Metanomra XML" do
333
+ # expect { Asciidoctor::Standoc::Converter.new(nil,nil).validate(Nokogiri::XML(<<~INPUT)) }.not_to output('found attribute "close", but no attributes allowed here').to_stderr
334
+ # <standard-document>
335
+ # <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mfenced open="(" close=")"><mi>r</mi></mfenced></stem>
336
+ # </standard-document>
337
+ # INPUT
338
+ # end
391
339
 
392
- it "Warning if no block for footnoteblock" do
393
- FileUtils.rm_f "test.err"
394
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
395
- = Document title
396
- Author
397
- :docfile: test.adoc
398
-
399
- footnoteblock:[id1]
400
-
401
- [[id2]]
402
- [NOTE]
403
- --
404
- |===
405
- |a |b
406
-
407
- |c |d
408
- |===
409
-
410
- * A
411
- * B
412
- * C
413
- --
414
- INPUT
415
- expect(File.read("test.err")).to include 'Could not resolve footnoteblock:[id1]'
416
- end
340
+ it "warns and aborts if concept/xref does not point to term or definition" do
341
+ FileUtils.rm_f "test.xml"
342
+ FileUtils.rm_f "test.err"
343
+ begin
344
+ input = <<~INPUT
345
+ = Document title
346
+ Author
347
+ :docfile: test.adoc
348
+ :nodoc:
349
+
350
+ [[abc]]
351
+ == Clause 1
352
+ [[ghi]]A:: B
353
+
354
+ == Symbols and Abbreviated Terms
355
+ [[def]]DEF:: def
356
+
357
+ {{<<abc>>,term}}
358
+ {{<<def>>,term}}
359
+ {{<<ghi>>,term}}
360
+ INPUT
361
+ expect { Asciidoctor.convert(input, *OPTIONS) }.to raise_error(SystemExit)
362
+ rescue SystemExit
363
+ end
364
+ expect(File.read("test.err"))
365
+ .to include "Concept term is pointing to abc, which is not a term or symbol"
366
+ expect(File.read("test.err"))
367
+ .not_to include "Concept term is pointing to def, which is not a term or symbol"
368
+ expect(File.read("test.err"))
369
+ .to include "Concept term is pointing to ghi, which is not a term or symbol"
370
+ expect(File.exist?("test.xml")).to be false
371
+ end
372
+
373
+ it "warns and aborts if id used twice" do
374
+ FileUtils.rm_f "test.xml"
375
+ FileUtils.rm_f "test.err"
376
+ begin
377
+ input = <<~INPUT
378
+ = Document title
379
+ Author
380
+ :docfile: test.adoc
381
+ :nodoc:
382
+
383
+ [[abc]]
384
+ == Clause 1
385
+
386
+ [[abc]]
387
+ == Clause 2
388
+ INPUT
389
+ expect { Asciidoctor.convert(input, *OPTIONS) }.to raise_error(SystemExit)
390
+ rescue SystemExit
391
+ end
392
+ expect(File.read("test.err"))
393
+ .to include "Anchor abc has already been used at line"
394
+ expect(File.exist?("test.xml")).to be false
395
+ end
396
+
397
+ it "warns and aborts if numeric normative reference" do
398
+ FileUtils.rm_f "test.xml"
399
+ FileUtils.rm_f "test.err"
400
+ begin
401
+ input = <<~INPUT
402
+ = Document title
403
+ Author
404
+ :docfile: test.adoc
405
+ :nodoc:
406
+
407
+ [bibliography]
408
+ == Normative references
409
+ * [[[A,1]]]
410
+ INPUT
411
+ expect { Asciidoctor.convert(input, *OPTIONS) }.to raise_error(SystemExit)
412
+ rescue SystemExit
413
+ end
414
+ expect(File.read("test.err"))
415
+ .to include "Numeric reference in normative references"
416
+ expect(File.exist?("test.xml")).to be false
417
+ end
418
+
419
+ it "err file succesfully created for docfile path" do
420
+ FileUtils.rm_rf "test"
421
+ FileUtils.mkdir_p "test"
422
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
423
+ = Document title
424
+ Author
425
+ :docfile: test#{File::ALT_SEPARATOR || File::SEPARATOR}test.adoc
426
+ :nodoc:
427
+
428
+ == Clause 1
429
+
430
+ Paragraph
417
431
 
432
+ === Clause 1.1
433
+
434
+ Subclause
435
+ INPUT
436
+
437
+ expect(File.read("test/test.err")).to include "Hanging paragraph in clause"
438
+ end
439
+
440
+ it "Warning if no block for footnoteblock" do
441
+ FileUtils.rm_f "test.err"
442
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
443
+ = Document title
444
+ Author
445
+ :docfile: test.adoc
446
+
447
+ footnoteblock:[id1]
448
+
449
+ [[id2]]
450
+ [NOTE]
451
+ --
452
+ |===
453
+ |a |b
454
+
455
+ |c |d
456
+ |===
457
+
458
+ * A
459
+ * B
460
+ * C
461
+ --
462
+ INPUT
463
+ expect(File.read("test.err"))
464
+ .to include "Could not resolve footnoteblock:[id1]"
465
+ end
418
466
  end