metanorma-standoc 2.2.6 → 2.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/lib/metanorma/standoc/base.rb +3 -5
  3. data/lib/metanorma/standoc/biblio.rng +5 -0
  4. data/lib/metanorma/standoc/cleanup.rb +17 -17
  5. data/lib/metanorma/standoc/cleanup_amend.rb +2 -2
  6. data/lib/metanorma/standoc/cleanup_biblio.rb +2 -1
  7. data/lib/metanorma/standoc/cleanup_maths.rb +12 -4
  8. data/lib/metanorma/standoc/cleanup_section.rb +19 -9
  9. data/lib/metanorma/standoc/cleanup_symbols.rb +14 -7
  10. data/lib/metanorma/standoc/cleanup_text.rb +10 -4
  11. data/lib/metanorma/standoc/cleanup_toc.rb +1 -2
  12. data/lib/metanorma/standoc/cleanup_xref.rb +55 -14
  13. data/lib/metanorma/standoc/inline.rb +27 -12
  14. data/lib/metanorma/standoc/isodoc.rng +46 -12
  15. data/lib/metanorma/standoc/ref_utility.rb +1 -0
  16. data/lib/metanorma/standoc/render.rb +10 -1
  17. data/lib/metanorma/standoc/section.rb +10 -3
  18. data/lib/metanorma/standoc/utils.rb +6 -1
  19. data/lib/metanorma/standoc/validate.rb +1 -1
  20. data/lib/metanorma/standoc/version.rb +1 -1
  21. data/metanorma-standoc.gemspec +5 -2
  22. metadata +4 -128
  23. data/.github/workflows/automerge.yml +0 -31
  24. data/.github/workflows/rake.yml +0 -15
  25. data/.github/workflows/release.yml +0 -24
  26. data/Rakefile +0 -8
  27. data/bin/rspec +0 -18
  28. data/spec/assets/a1.adoc +0 -8
  29. data/spec/assets/a2.adoc +0 -10
  30. data/spec/assets/a3.adoc +0 -9
  31. data/spec/assets/a3a.adoc +0 -7
  32. data/spec/assets/a4.adoc +0 -4
  33. data/spec/assets/boilerplate.xml +0 -4
  34. data/spec/assets/codes.yml +0 -695
  35. data/spec/assets/correct.png +0 -0
  36. data/spec/assets/corrupt.png +0 -0
  37. data/spec/assets/header.html +0 -7
  38. data/spec/assets/html-override.css +0 -1
  39. data/spec/assets/html.scss +0 -13
  40. data/spec/assets/htmlcover.html +0 -4
  41. data/spec/assets/htmlintro.html +0 -5
  42. data/spec/assets/i18n.yaml +0 -17
  43. data/spec/assets/iso.adoc +0 -10
  44. data/spec/assets/iso.headless.html +0 -33
  45. data/spec/assets/iso.xml +0 -8
  46. data/spec/assets/iso123.rxl +0 -107
  47. data/spec/assets/rice_image1.png +0 -0
  48. data/spec/assets/scripts.html +0 -3
  49. data/spec/assets/std.css +0 -2
  50. data/spec/assets/word-override.css +0 -1
  51. data/spec/assets/word.scss +0 -13
  52. data/spec/assets/wordcover.html +0 -3
  53. data/spec/assets/wordintro.html +0 -4
  54. data/spec/assets/xref_error.adoc +0 -8
  55. data/spec/examples/103_01_02.html +0 -247
  56. data/spec/examples/codes_table.html +0 -3174
  57. data/spec/examples/datamodel/address_class_profile.adoc +0 -5
  58. data/spec/examples/datamodel/address_class_profile.presentation.xml +0 -14
  59. data/spec/examples/datamodel/address_component_profile.adoc +0 -5
  60. data/spec/examples/datamodel/blank_definition_profile.adoc +0 -5
  61. data/spec/examples/datamodel/common_models_diagram.adoc +0 -5
  62. data/spec/examples/datamodel/models/models/AddressClassProfile.yml +0 -90
  63. data/spec/examples/datamodel/models/models/AddressComponentProfile.yml +0 -63
  64. data/spec/examples/datamodel/models/models/AddressComponentSpecification.yml +0 -15
  65. data/spec/examples/datamodel/models/models/AddressProfile.yml +0 -36
  66. data/spec/examples/datamodel/models/models/AttributeProfile.yml +0 -32
  67. data/spec/examples/datamodel/models/models/InterchangeAddressClassProfile.yml +0 -79
  68. data/spec/examples/datamodel/models/models/Localization copy.yml +0 -23
  69. data/spec/examples/datamodel/models/models/Localization.yml +0 -23
  70. data/spec/examples/datamodel/models/models/ProfileCompliantAddress.yml +0 -36
  71. data/spec/examples/datamodel/models/models/ProfileCompliantAddressComponent.yml +0 -15
  72. data/spec/examples/datamodel/models/models/Signature.yml +0 -20
  73. data/spec/examples/datamodel/models/models/SignatureBlankDefinition.yml +0 -20
  74. data/spec/examples/datamodel/models/models/TextDirectionCode copy.yml +0 -16
  75. data/spec/examples/datamodel/models/models/TextDirectionCode.yml +0 -16
  76. data/spec/examples/datamodel/models/models/Validity.yml +0 -14
  77. data/spec/examples/datamodel/models/models/iso19160-1/Address.yml +0 -22
  78. data/spec/examples/datamodel/models/models/iso19160-1/AddressComponent.yml +0 -2
  79. data/spec/examples/datamodel/models/style.uml.inc +0 -37
  80. data/spec/examples/datamodel/models/views/CommonModels.yml +0 -9
  81. data/spec/examples/datamodel/models/views/TopDown.yml +0 -62
  82. data/spec/examples/datamodel/top_down_diagram.adoc +0 -5
  83. data/spec/examples/english.yaml +0 -69
  84. data/spec/examples/iso_123_.xml +0 -46
  85. data/spec/examples/iso_123_all_parts.xml +0 -46
  86. data/spec/examples/iso_123_no_year_note.xml +0 -47
  87. data/spec/examples/iso_124_.xml +0 -42
  88. data/spec/examples/iso_216_.xml +0 -48
  89. data/spec/examples/iso_iec_12382_.xml +0 -49
  90. data/spec/examples/rice.adoc +0 -715
  91. data/spec/examples/rice.preview.html +0 -1877
  92. data/spec/examples/rice.sh +0 -4
  93. data/spec/examples/rice_images/rice_image1.png +0 -0
  94. data/spec/examples/rice_images/rice_image2.png +0 -0
  95. data/spec/examples/rice_images/rice_image3_1.png +0 -0
  96. data/spec/examples/rice_images/rice_image3_2.png +0 -0
  97. data/spec/examples/rice_images/rice_image3_3.png +0 -0
  98. data/spec/fixtures/action_schemaexpg1.svg +0 -122
  99. data/spec/fixtures/datamodel_description_sections_tree.xml +0 -327
  100. data/spec/fixtures/diagram_definitions.lutaml +0 -22
  101. data/spec/fixtures/macros_datamodel/address_class_profile.xml +0 -149
  102. data/spec/fixtures/macros_datamodel/address_component_profile.xml +0 -71
  103. data/spec/fixtures/macros_datamodel/blank_definition_profile.xml +0 -51
  104. data/spec/fixtures/macros_datamodel/common_models_diagram.xml +0 -7
  105. data/spec/fixtures/macros_datamodel/top_down_diagram.xml +0 -7
  106. data/spec/fixtures/test.exp +0 -121
  107. data/spec/fixtures/test.xmi +0 -9250
  108. data/spec/metanorma/base_spec.rb +0 -1125
  109. data/spec/metanorma/biblio_spec.rb +0 -1012
  110. data/spec/metanorma/blank_spec.rb +0 -37
  111. data/spec/metanorma/blocks_spec.rb +0 -1784
  112. data/spec/metanorma/cleanup_blocks_spec.rb +0 -1099
  113. data/spec/metanorma/cleanup_sections_spec.rb +0 -1849
  114. data/spec/metanorma/cleanup_spec.rb +0 -1931
  115. data/spec/metanorma/cleanup_terms_spec.rb +0 -1543
  116. data/spec/metanorma/datamodel/attributes_table_preprocessor_spec.rb +0 -111
  117. data/spec/metanorma/datamodel/diagram_preprocessor_spec.rb +0 -72
  118. data/spec/metanorma/inline_spec.rb +0 -785
  119. data/spec/metanorma/isobib_cache_spec.rb +0 -742
  120. data/spec/metanorma/lists_spec.rb +0 -232
  121. data/spec/metanorma/macros_concept_spec.rb +0 -1052
  122. data/spec/metanorma/macros_json2text_spec.rb +0 -10
  123. data/spec/metanorma/macros_plantuml_spec.rb +0 -402
  124. data/spec/metanorma/macros_spec.rb +0 -1183
  125. data/spec/metanorma/macros_yaml2text_spec.rb +0 -10
  126. data/spec/metanorma/processor_spec.rb +0 -96
  127. data/spec/metanorma/refs_spec.rb +0 -2807
  128. data/spec/metanorma/reqt_spec.rb +0 -130
  129. data/spec/metanorma/section_spec.rb +0 -1325
  130. data/spec/metanorma/table_spec.rb +0 -474
  131. data/spec/metanorma/validate_spec.rb +0 -886
  132. data/spec/spec_helper.rb +0 -290
  133. data/spec/support/shared_examples/structured_data_2_text_preprocessor.rb +0 -781
  134. data/spec/vcr_cassettes/bsi16341.yml +0 -486
  135. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +0 -611
  136. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +0 -149
  137. data/spec/vcr_cassettes/hide_refs.yml +0 -587
  138. data/spec/vcr_cassettes/isobib_get_123.yml +0 -149
  139. data/spec/vcr_cassettes/isobib_get_123_1.yml +0 -295
  140. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +0 -385
  141. data/spec/vcr_cassettes/isobib_get_123_2.yml +0 -295
  142. data/spec/vcr_cassettes/isobib_get_123_2001.yml +0 -149
  143. data/spec/vcr_cassettes/isobib_get_124.yml +0 -149
  144. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +0 -367
  145. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +0 -560
  146. data/spec/vcr_cassettes/std-link.yml +0 -149
@@ -1,886 +0,0 @@
1
- require "spec_helper"
2
- require "fileutils"
3
-
4
- RSpec.describe Metanorma::Standoc do
5
- it "generates error file" do
6
- FileUtils.rm_f "spec/assets/xref_error.err"
7
- Asciidoctor.convert_file "spec/assets/xref_error.adoc",
8
- { attributes: { "backend" => "standoc" }, safe: 0,
9
- header_footer: true,
10
- requires: ["metanorma-standoc"],
11
- failure_level: 4, mkdirs: true, to_file: nil }
12
- expect(File.exist?("spec/assets/xref_error.err")).to be true
13
- end
14
-
15
- it "provides context for log" do
16
- FileUtils.rm_f "test.xml"
17
- FileUtils.rm_f "test.err"
18
- begin
19
- input = <<~INPUT
20
- = Document title
21
- Author
22
- :docfile: test.adoc
23
- :nodoc:
24
- :no-pdf:
25
-
26
- [[abc]]
27
- == Clause 1
28
-
29
- [[abc]]
30
- == Clause 2
31
- INPUT
32
- expect do
33
- Asciidoctor.convert(input, *OPTIONS)
34
- end.to raise_error(SystemExit)
35
- rescue SystemExit
36
- end
37
- expect(File.read("test.err"))
38
- .to include "Anchor abc has already been used at line"
39
- expect(File.read("test.err"))
40
- .to include %(\t<clause id="abc" inline-header="false" obligation="normative">)
41
- end
42
-
43
- it "warns about missing fields in asciibib" do
44
- FileUtils.rm_f "test.err"
45
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
46
- #{VALIDATING_BLANK_HDR}
47
-
48
- [bibliography]
49
- == Normative References
50
-
51
- [%bibitem]
52
- === Standard
53
- id:: iso123
54
- type:: standard
55
- contributor::
56
- role::: publisher
57
- organization:::
58
- name:::: ISO
59
- contributor::
60
- role::: author
61
- person:::
62
- name::::
63
- +
64
- --
65
- completename::
66
- language::: en
67
- content::: Fred
68
- --
69
- contributor::
70
- role::: author
71
- person:::
72
- name::::
73
- completename::::: Jack
74
- INPUT
75
- errf = File.read("test.err")
76
- expect(errf)
77
- .to include "Reference iso123 is missing a document identifier (docid)"
78
- end
79
-
80
- it "warns about missing fields in asciibib" do
81
- FileUtils.rm_f "test.err"
82
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
83
- #{VALIDATING_BLANK_HDR}
84
-
85
- [bibliography]
86
- == Normative References
87
-
88
- [%bibitem]
89
- === Standard
90
- type:: standard
91
- contributor::
92
- role::: publisher
93
- organization:::
94
- name:::: ISO
95
- INPUT
96
- errf = File.read("test.err")
97
- expect(errf).to include "The following reference is missing an anchor"
98
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
99
- #{VALIDATING_BLANK_HDR}
100
-
101
- [bibliography]
102
- == Normative References
103
-
104
- [[x]]
105
- [%bibitem]
106
- === Standard
107
- type:: standard
108
- contributor::
109
- role::: publisher
110
- organization:::
111
- name:::: ISO
112
- INPUT
113
- errf = File.read("test.err")
114
- expect(errf).not_to include "The following reference is missing an anchor"
115
- end
116
-
117
- # it "warns about malformed LaTeX" do
118
- # FileUtils.rm_f "test.err"
119
- # Asciidoctor.convert(<<~"INPUT", *OPTIONS)
120
- # #{VALIDATING_BLANK_HDR}
121
- #
122
- # == Clause 1
123
- #
124
- # latexmath:[\\[ \\text{Odd integer = 51, \\quad \\text{Even integers } = 50 \\]]
125
- #
126
- # === Clause 1.1
127
- #
128
- # Subclause
129
- # INPUT
130
- # expect(File.read("test.err")).to include "latexmlmath failed to process equation"
131
- # end
132
-
133
- # it "warns about reparsing LaTeX" do
134
- # FileUtils.rm_f "test.err"
135
- # expect { Asciidoctor.convert(<<~"INPUT", *OPTIONS) }.to output(/Retrying/).to_stderr
136
- # #{VALIDATING_BLANK_HDR}
137
- #
138
- # == Clause 1
139
- #
140
- # [latexmath]
141
- # ++++
142
- # \\pmatrix{ \\hat{e}_{\\xi} \\cr \\hat{e}_{\\eta}
143
- # \\cr \\hat{e}_{\\zeta} } = {\\bf T} \\pmatrix{ \\hat{e}_x \\cr \\hat{e}_y \\cr \\hat{e}_z },
144
- # ++++
145
- #
146
- # === Clause 1.1
147
- #
148
- # Subclause
149
- # INPUT
150
- # end
151
-
152
- it "warns about hanging paragraphs" do
153
- FileUtils.rm_f "test.err"
154
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
155
- #{VALIDATING_BLANK_HDR}
156
-
157
- == Clause 1
158
-
159
- Paragraph
160
-
161
- === Clause 1.1
162
-
163
- Subclause
164
- INPUT
165
- expect(File.read("test.err")).to include "Hanging paragraph in clause"
166
- end
167
-
168
- it "warns that video is a skipped node" do
169
- FileUtils.rm_f "test.err"
170
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
171
- #{VALIDATING_BLANK_HDR}
172
-
173
- video::video_file.mp4[]
174
- INPUT
175
- expect(File.read("test.err")).to include "converter missing for video node"
176
- end
177
-
178
- it "warns that figure does not have title" do
179
- FileUtils.rm_f "test.err"
180
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
181
- #{VALIDATING_BLANK_HDR}
182
-
183
- image::spec/examples/rice_images/rice_image1.png[]
184
- INPUT
185
- expect(File.read("test.err")).to include "Figure should have title"
186
- end
187
-
188
- it "warns that callouts do not match annotations" do
189
- FileUtils.rm_f "test.err"
190
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
191
- #{VALIDATING_BLANK_HDR}
192
- [source,ruby]
193
- --
194
- puts "Hello, world." <1>
195
- %w{a b c}.each do |x|
196
- puts x
197
- end
198
- --
199
- <1> This is one callout
200
- <2> This is another callout
201
- INPUT
202
- expect(File.read("test.err"))
203
- .to include "mismatch of callouts and annotations"
204
- end
205
-
206
- it "warns that term source is not a real reference" do
207
- FileUtils.rm_f "test.err"
208
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
209
- #{VALIDATING_BLANK_HDR}
210
-
211
- [.source]
212
- <<iso123>>
213
- INPUT
214
- expect(File.read("test.err"))
215
- .to include "iso123 does not have a corresponding anchor ID in the bibliography"
216
- end
217
-
218
- it "warns of Non-reference in bibliography" do
219
- FileUtils.rm_f "test.err"
220
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
221
- #{VALIDATING_BLANK_HDR}
222
-
223
- == Normative References
224
- * I am not a reference
225
- INPUT
226
- expect(File.read("test.err")).to include "no anchor on reference"
227
- end
228
-
229
- it "warns that Table should have title" do
230
- FileUtils.rm_f "test.err"
231
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
232
- #{VALIDATING_BLANK_HDR}
233
-
234
- |===
235
- |a |b |c
236
- |===
237
- INPUT
238
- expect(File.read("test.err")).to include "Table should have title"
239
- end
240
-
241
- it "validates document against ISO XML schema" do
242
- FileUtils.rm_f "test.err"
243
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
244
- #{VALIDATING_BLANK_HDR}
245
-
246
- [align=mid-air]
247
- Para
248
- INPUT
249
- expect(File.read("test.err"))
250
- .to include 'value of attribute "align" is invalid; must be equal to'
251
- end
252
-
253
- it "Warning if terms mismatches IEV" do
254
- FileUtils.rm_f "test.err"
255
- FileUtils.mv File.expand_path("~/.iev/cache"),
256
- File.expand_path("~/.iev.pstore1"), force: true
257
- FileUtils.rm_f "test_iev/pstore"
258
- mock_open_uri("103-01-02")
259
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
260
- = Document title
261
- Author
262
- :docfile: test.adoc
263
- :no-pdf:
264
-
265
- [bibliography]
266
- == Normative References
267
- * [[[iev,IEV]]], _iev_
268
-
269
- == Terms and definitions
270
- === Automation
271
-
272
- [.source]
273
- <<iev,clause="103-01-02">>
274
- INPUT
275
- expect(File.read("test.err"))
276
- .to include 'Term "automation" does not match IEV 103-01-02 "functional"'
277
- FileUtils.mv File.expand_path("~/.iev.pstore1"),
278
- File.expand_path("~/.iev/cache"), force: true
279
- end
280
-
281
- it "No warning if English term matches IEV" do
282
- FileUtils.rm_f "test.err"
283
- FileUtils.mv File.expand_path("~/.iev/cache"),
284
- File.expand_path("~/.iev.pstore1"), force: true
285
- FileUtils.rm_f "test_iev/cache"
286
- mock_open_uri("103-01-02")
287
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
288
- = Document title
289
- Author
290
- :docfile: test.adoc
291
- :no-pdf:
292
-
293
- [bibliography]
294
- == Normative References
295
- * [[[iev,IEV]]], _iev_
296
-
297
- == Terms and definitions
298
- === Functional
299
-
300
- [.source]
301
- <<iev,clause="103-01-02">>
302
- INPUT
303
- expect(File.read("test.err")).not_to include "does not match IEV 103-01-02"
304
- FileUtils.mv File.expand_path("~/.iev.pstore1"),
305
- File.expand_path("~/.iev/cache"), force: true
306
- end
307
-
308
- it "No warning if French term matches IEV" do
309
- FileUtils.rm_f "test.err"
310
- FileUtils.mv File.expand_path("~/.iev/cache"),
311
- File.expand_path("~/.iev.pstore1"), force: true
312
- FileUtils.rm_f "test_iev/cache"
313
- mock_open_uri("103-01-02")
314
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
315
- = Document title
316
- Author
317
- :docfile: test.adoc
318
- :nodoc:
319
- :language: fr
320
-
321
- [bibliography]
322
- == Normative References
323
- * [[[iev,IEV]]], _iev_
324
-
325
- == Terms and definitions
326
- === Fonctionnelle, f
327
-
328
- [.source]
329
- <<iev,clause="103-01-02">>
330
- INPUT
331
- expect(File.read("test.err"))
332
- .not_to include "does not match IEV 103-01-02"
333
- FileUtils.mv File.expand_path("~/.iev.pstore1"),
334
- File.expand_path("~/.iev/cache"), force: true
335
- end
336
-
337
- # it "No warning if attributes on formatted strong or stem extraneous to Metanomra XML" do
338
- # expect { Metanorma::Standoc::Converter.new(nil,nil).validate(Nokogiri::XML(<<~INPUT)) }.not_to output('found attribute "close", but no attributes allowed here').to_stderr
339
- # <standard-document>
340
- # <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mfenced open="(" close=")"><mi>r</mi></mfenced></stem>
341
- # </standard-document>
342
- # INPUT
343
- # end
344
-
345
- it "warns and aborts if concept attributes are malformed" do
346
- FileUtils.rm_f "test.xml"
347
- FileUtils.rm_f "test.err"
348
- begin
349
- input = <<~INPUT
350
- = Document title
351
- Author
352
- :docfile: test.adoc
353
- :nodoc:
354
-
355
- == Symbols and Abbreviated Terms
356
- [[def]]DEF:: def
357
-
358
- {{<<def>>,term,option="noital"}}
359
- INPUT
360
- expect do
361
- Asciidoctor.convert(input, *OPTIONS)
362
- end.to raise_error(RuntimeError)
363
- rescue SystemExit, RuntimeError
364
- end
365
- expect(File.read("test.err"))
366
- .to include 'processing {{&lt;&lt;def&gt;&gt;,term,option="noital"}}: error processing ,term,option="noital" as CSV'
367
- expect(File.exist?("test.xml")).to be false
368
- end
369
-
370
- it "warns and aborts if concept/xref does not point to term or definition" do
371
- FileUtils.rm_f "test.xml"
372
- FileUtils.rm_f "test.err"
373
- begin
374
- input = <<~INPUT
375
- = Document title
376
- Author
377
- :docfile: test.adoc
378
- :nodoc:
379
-
380
- [[abc]]
381
- == Clause 1
382
- [[ghi]]A:: B
383
-
384
- == Terms and Definitions
385
-
386
- [[jkl]]
387
- === Term1
388
-
389
- ==== Term2
390
-
391
- == Symbols and Abbreviated Terms
392
- [[def]]DEF:: def
393
-
394
- {{<<jkl>>,term1}}
395
- {{<<abc>>,term}}
396
- {{<<def>>,term}}
397
- {{<<ghi>>,term}}
398
- {{Terms and Definitions}}
399
- INPUT
400
- expect do
401
- Asciidoctor.convert(input, *OPTIONS)
402
- end.to raise_error(SystemExit)
403
- rescue SystemExit
404
- end
405
- expect(File.read("test.err"))
406
- .to include %(Term reference to `Terms-and-Definitions` missing: "Terms-and-Definitions" is not defined in document. Did you mean to point to a subterm?)
407
- expect(File.read("test.err"))
408
- .to include "Concept term1 is pointing to jkl, which is not a term or symbol. Did you mean to point to a subterm?"
409
- expect(File.read("test.err"))
410
- .to include "Concept term is pointing to abc, which is not a term or symbol"
411
- expect(File.read("test.err"))
412
- .not_to include "Concept term is pointing to def, which is not a term or symbol"
413
- expect(File.read("test.err"))
414
- .to include "Concept term is pointing to ghi, which is not a term or symbol"
415
- expect(File.exist?("test.xml")).to be false
416
- end
417
-
418
- it "warns and aborts if related/xref does not point to term or definition" do
419
- FileUtils.rm_f "test.xml"
420
- FileUtils.rm_f "test.err"
421
- begin
422
- input = <<~INPUT
423
- = Document title
424
- Author
425
- :docfile: test.adoc
426
- :nodoc:
427
-
428
- [[abc]]
429
- == Clause 1
430
- [[ghi]]A:: B
431
-
432
- == Symbols and Abbreviated Terms
433
- [[def]]DEF:: def
434
-
435
- related:see[<<abc>>,term]
436
- related:see[<<def>>,term]
437
- related:see[<<ghi>>,term]
438
- INPUT
439
- expect do
440
- Asciidoctor.convert(input, *OPTIONS)
441
- end.to raise_error(SystemExit)
442
- rescue SystemExit
443
- end
444
- expect(File.read("test.err"))
445
- .to include "Related term is pointing to abc, which is not a term or symbol"
446
- expect(File.read("test.err"))
447
- .not_to include "Related term is pointing to def, which is not a term or symbol"
448
- expect(File.read("test.err"))
449
- .to include "Related term is pointing to ghi, which is not a term or symbol"
450
- expect(File.exist?("test.xml")).to be false
451
- end
452
-
453
- it "warns and aborts if id used twice" do
454
- FileUtils.rm_f "test.xml"
455
- FileUtils.rm_f "test.err"
456
- begin
457
- input = <<~INPUT
458
- = Document title
459
- Author
460
- :docfile: test.adoc
461
- :nodoc:
462
-
463
- [[abc]]
464
- == Clause 1
465
-
466
- [[abc]]
467
- == Clause 2
468
- INPUT
469
- expect do
470
- Asciidoctor.convert(input, *OPTIONS)
471
- end.to raise_error(SystemExit)
472
- rescue SystemExit
473
- end
474
- expect(File.read("test.err"))
475
- .to include "Anchor abc has already been used at line"
476
- expect(File.exist?("test.xml")).to be false
477
- end
478
-
479
- it "warns and aborts if numeric normative reference" do
480
- FileUtils.rm_f "test.xml"
481
- FileUtils.rm_f "test.err"
482
- begin
483
- input = <<~INPUT
484
- = Document title
485
- Author
486
- :docfile: test.adoc
487
- :nodoc:
488
-
489
- [bibliography]
490
- == Normative references
491
- * [[[A,1]]]
492
- INPUT
493
- expect do
494
- Asciidoctor.convert(input, *OPTIONS)
495
- end.to raise_error(SystemExit)
496
- rescue SystemExit
497
- end
498
- expect(File.read("test.err"))
499
- .to include "Numeric reference in normative references"
500
- expect(File.exist?("test.xml")).to be false
501
- end
502
-
503
- it "does not warn and abort if columns and rows not out of bounds" do
504
- FileUtils.rm_f "test.xml"
505
- FileUtils.rm_f "test.err"
506
- begin
507
- input = <<~INPUT
508
- = Document title
509
- Author
510
- :docfile: test.adoc
511
- :nodoc:
512
-
513
- == Clause
514
-
515
- [cols="1,1,1,1"]
516
- |===
517
- 3.2+| a | a
518
- | a
519
- | a | a | a | a
520
- |===
521
- INPUT
522
- expect do
523
- Asciidoctor.convert(input, *OPTIONS)
524
- end.not_to raise_error(SystemExit)
525
- rescue SystemExit
526
- end
527
- expect(File.read("test.err"))
528
- .not_to include "Table exceeds maximum number of columns defined"
529
- expect(File.read("test.err"))
530
- .not_to include "Table rows in table are inconsistent: check rowspan"
531
- expect(File.read("test.err"))
532
- .not_to include "Table rows in table cannot go outside thead: check rowspan"
533
- end
534
-
535
- it "warns if rowspan goes across thead" do
536
- FileUtils.rm_f "test.xml"
537
- FileUtils.rm_f "test.err"
538
- begin
539
- input = <<~INPUT
540
- = Document title
541
- Author
542
- :docfile: test.adoc
543
- :nodoc:
544
-
545
- == Clause
546
-
547
- [cols="1,1,1,1",headerrows=2]
548
- |===
549
- 3.3+| a | a
550
-
551
- | a
552
- | a | a | a | a
553
- |===
554
- INPUT
555
- expect do
556
- Asciidoctor.convert(input, *OPTIONS)
557
- end.to raise_error(SystemExit)
558
- rescue SystemExit
559
- end
560
- expect(File.read("test.err"))
561
- .to include "Table rows in table cannot go outside thead: check rowspan"
562
- end
563
-
564
- xit "warns and aborts if columns out of bounds against colgroup" do
565
- FileUtils.rm_f "test.xml"
566
- FileUtils.rm_f "test.err"
567
- begin
568
- input = <<~INPUT
569
- = Document title
570
- Author
571
- :docfile: test.adoc
572
- :nodoc:
573
-
574
- [cols="1,1,1,1"]
575
- |===
576
- 5+| a
577
-
578
- | a 4+| a
579
- | a | a |a |a
580
- |===
581
- INPUT
582
- expect { Asciidoctor.convert(input, *OPTIONS) }.to raise_error(SystemExit)
583
- rescue SystemExit
584
- end
585
- expect(File.read("test.err"))
586
- .to include "Table exceeds maximum number of columns defined (4)"
587
- expect(File.read("test.err"))
588
- .not_to include "Table rows in table are inconsistent: check rowspan"
589
- end
590
-
591
- xit "warns and aborts if columns out of bounds against cell count per row" do
592
- FileUtils.rm_f "test.xml"
593
- FileUtils.rm_f "test.err"
594
- begin
595
- input = <<~INPUT
596
- = Document title
597
- Author
598
- :docfile: test.adoc
599
- :nodoc:
600
-
601
- |===
602
- 2.3+| a | a
603
-
604
- | a | a | a
605
- | a | a | a
606
- |===
607
- INPUT
608
- expect { Asciidoctor.convert(input, *OPTIONS) }.to raise_error(SystemExit)
609
- rescue SystemExit
610
- end
611
- expect(File.read("test.err"))
612
- .to include "Table exceeds maximum number of columns defined (3)"
613
- expect(File.read("test.err"))
614
- .not_to include "Table rows in table are inconsistent: check rowspan"
615
- end
616
-
617
- it "warns and aborts if rows out of bounds" do
618
- FileUtils.rm_f "test.xml"
619
- FileUtils.rm_f "test.err"
620
- begin
621
- input = <<~INPUT
622
- = Document title
623
- Author
624
- :docfile: test.adoc
625
- :nodoc:
626
-
627
- |===
628
- .4+| a | a | a | a
629
-
630
- | a | a | a
631
- | a | a | a
632
- |===
633
- INPUT
634
- expect { Asciidoctor.convert(input, *OPTIONS) }.to raise_error(SystemExit)
635
- rescue SystemExit
636
- end
637
- expect(File.read("test.err"))
638
- .not_to include "Table exceeds maximum number of columns defined"
639
- expect(File.read("test.err"))
640
- .to include "Table rows in table are inconsistent: check rowspan"
641
- end
642
-
643
- it "err file succesfully created for docfile path" do
644
- FileUtils.rm_rf "test"
645
- FileUtils.mkdir_p "test"
646
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
647
- = Document title
648
- Author
649
- :docfile: test#{File::ALT_SEPARATOR || File::SEPARATOR}test.adoc
650
- :nodoc:
651
-
652
- == Clause 1
653
-
654
- Paragraph
655
-
656
- === Clause 1.1
657
-
658
- Subclause
659
- INPUT
660
-
661
- expect(File.read("test/test.err")).to include "Hanging paragraph in clause"
662
- end
663
-
664
- it "Warning if no block for footnoteblock" do
665
- FileUtils.rm_f "test.err"
666
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
667
- = Document title
668
- Author
669
- :docfile: test.adoc
670
- :no-pdf:
671
-
672
- footnoteblock:[id1]
673
-
674
- [[id2]]
675
- [NOTE]
676
- --
677
- |===
678
- |a |b
679
-
680
- |c |d
681
- |===
682
-
683
- * A
684
- * B
685
- * C
686
- --
687
- INPUT
688
- expect(File.read("test.err"))
689
- .to include "Could not resolve footnoteblock:[id1]"
690
- end
691
-
692
- it "Warning if xref/@target does not point to a real identifier" do
693
- FileUtils.rm_f "test.err"
694
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
695
- = Document title
696
- Author
697
- :docfile: test.adoc
698
- :no-pdf:
699
-
700
- <<id1>>
701
-
702
- [[id2]]
703
- [NOTE]
704
- --
705
- |===
706
- |a |b
707
-
708
- |c |d
709
- |===
710
-
711
- * A
712
- * B
713
- * C
714
- --
715
- INPUT
716
- expect(File.read("test.err"))
717
- .to include "Crossreference target id1 is undefined"
718
- end
719
-
720
- it "Warning if metadata deflist not after a designation" do
721
- FileUtils.rm_f "test.err"
722
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
723
- = Document title
724
- Author
725
- :docfile: test.adoc
726
- :no-pdf:
727
-
728
- == Terms and definitions
729
-
730
- === Term 1
731
-
732
- Definition
733
-
734
- [%metadata]
735
- language:: fr
736
- INPUT
737
- expect(File.read("test.err"))
738
- .to include "Metadata definition list does not follow a term designation"
739
- end
740
-
741
- it "Warning if related term missing" do
742
- FileUtils.rm_f "test.err"
743
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
744
- #{VALIDATING_BLANK_HDR}
745
-
746
- == Terms and definitions
747
-
748
- === Term 1
749
-
750
- related:see[xyz]
751
-
752
- Definition
753
-
754
- INPUT
755
- expect(File.read("test.err"))
756
- .to include "Error: Term reference to `xyz` missing:"
757
- expect(File.read("test.err"))
758
- .not_to include "Did you mean to point to a subterm?"
759
-
760
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
761
- #{VALIDATING_BLANK_HDR}
762
-
763
- [[xyz]]
764
- == Terms and definitions
765
-
766
- === Term 1
767
-
768
- related:see[xyz]
769
-
770
- Definition
771
-
772
- INPUT
773
- expect(File.read("test.err"))
774
- .to include "Error: Term reference to `xyz` missing:"
775
- expect(File.read("test.err"))
776
- .to include "Did you mean to point to a subterm?"
777
-
778
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
779
- #{VALIDATING_BLANK_HDR}
780
-
781
- == Terms and definitions
782
-
783
- === Term 1
784
-
785
- symbol:[xyz]
786
-
787
- Definition
788
-
789
- INPUT
790
- expect(File.read("test.err"))
791
- .to include "Symbol reference in `symbol[xyz]` missing:"
792
-
793
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
794
- #{VALIDATING_BLANK_HDR}
795
-
796
- == Terms and definitions
797
-
798
- === Term 1
799
-
800
- related:see[xyz]
801
- symbol:[xyz1]
802
-
803
- Definition
804
-
805
- === xyz
806
-
807
- == Symbols and abbreviated terms
808
-
809
- xyz1:: B
810
-
811
- INPUT
812
- expect(File.read("test.err"))
813
- .not_to include "Error: Term reference to `xyz` missing:"
814
- expect(File.read("test.err"))
815
- .not_to include "Symbol reference in `symbol[xyz]` missing:"
816
- end
817
-
818
- it "warns if corrupt PNG" do
819
- FileUtils.rm_f "test.xml"
820
- FileUtils.rm_f "test.err"
821
-
822
- input = <<~INPUT
823
- = Document title
824
- Author
825
- :docfile: test.adoc
826
- :no-pdf:
827
-
828
- == Clause
829
- image::spec/assets/corrupt.png[]
830
-
831
- INPUT
832
- Asciidoctor.convert(input, *OPTIONS)
833
- expect(File.read("test.err"))
834
- .to include "Corrupt PNG image"
835
- expect(File.exist?("test.xml")).to be true
836
- end
837
-
838
- it "does not warn if not corrupt PNG" do
839
- FileUtils.rm_f "test.xml"
840
- FileUtils.rm_f "test.err"
841
-
842
- input = <<~INPUT
843
- = Document title
844
- Author
845
- :docfile: test.adoc
846
- :no-pdf:
847
-
848
- == Clause
849
- image::spec/assets/correct.png[]
850
-
851
- INPUT
852
-
853
- Asciidoctor.convert(input, *OPTIONS)
854
- expect(File.read("test.err"))
855
- .not_to include "Corrupt PNG image"
856
- expect(File.exist?("test.xml")).to be true
857
- end
858
-
859
- it "warns and aborts if images does not exist" do
860
- FileUtils.rm_f "test.xml"
861
- FileUtils.rm_f "test.err"
862
-
863
- begin
864
- input = <<~INPUT
865
- = Document title
866
- Author
867
- :docfile: test.adoc
868
- :no-pdf:
869
-
870
- == Clause
871
- image::spec/assets/nonexistent.png[]
872
-
873
- INPUT
874
-
875
- expect do
876
- Asciidoctor.convert(input, *OPTIONS)
877
- end.to raise_error(SystemExit)
878
- rescue SystemExit
879
- end
880
-
881
- warn File.read("test.err")
882
- expect(File.read("test.err"))
883
- .to include "Image not found"
884
- expect(File.exist?("test.xml")).to be false
885
- end
886
- end