metanorma-standoc 1.9.0 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) 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 -8
  5. data/lib/asciidoctor/standoc/base.rb +31 -35
  6. data/lib/asciidoctor/standoc/biblio.rng +1 -0
  7. data/lib/asciidoctor/standoc/blocks.rb +25 -9
  8. data/lib/asciidoctor/standoc/blocks_notes.rb +41 -24
  9. data/lib/asciidoctor/standoc/cleanup.rb +59 -84
  10. data/lib/asciidoctor/standoc/cleanup_block.rb +63 -85
  11. data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +28 -15
  12. data/lib/asciidoctor/standoc/cleanup_footnotes.rb +1 -0
  13. data/lib/asciidoctor/standoc/cleanup_image.rb +71 -0
  14. data/lib/asciidoctor/standoc/cleanup_inline.rb +117 -77
  15. data/lib/asciidoctor/standoc/cleanup_maths.rb +36 -27
  16. data/lib/asciidoctor/standoc/cleanup_ref.rb +31 -15
  17. data/lib/asciidoctor/standoc/cleanup_ref_dl.rb +1 -1
  18. data/lib/asciidoctor/standoc/cleanup_reqt.rb +47 -0
  19. data/lib/asciidoctor/standoc/cleanup_section.rb +77 -135
  20. data/lib/asciidoctor/standoc/cleanup_section_names.rb +75 -0
  21. data/lib/asciidoctor/standoc/cleanup_terms.rb +19 -18
  22. data/lib/asciidoctor/standoc/converter.rb +7 -2
  23. data/lib/asciidoctor/standoc/datamodel/plantuml_renderer.rb +67 -66
  24. data/lib/asciidoctor/standoc/front.rb +35 -18
  25. data/lib/asciidoctor/standoc/front_contributor.rb +70 -45
  26. data/lib/asciidoctor/standoc/inline.rb +45 -34
  27. data/lib/asciidoctor/standoc/isodoc.rng +209 -4
  28. data/lib/asciidoctor/standoc/lists.rb +4 -2
  29. data/lib/asciidoctor/standoc/macros.rb +11 -11
  30. data/lib/asciidoctor/standoc/macros_form.rb +63 -0
  31. data/lib/asciidoctor/standoc/macros_plantuml.rb +19 -21
  32. data/lib/asciidoctor/standoc/macros_terms.rb +33 -23
  33. data/lib/asciidoctor/standoc/ref.rb +87 -112
  34. data/lib/asciidoctor/standoc/ref_date_id.rb +62 -0
  35. data/lib/asciidoctor/standoc/ref_sect.rb +20 -17
  36. data/lib/asciidoctor/standoc/section.rb +3 -1
  37. data/lib/asciidoctor/standoc/term_lookup_cleanup.rb +40 -27
  38. data/lib/asciidoctor/standoc/terms.rb +25 -18
  39. data/lib/asciidoctor/standoc/utils.rb +35 -9
  40. data/lib/asciidoctor/standoc/validate.rb +48 -33
  41. data/lib/metanorma-standoc.rb +0 -1
  42. data/lib/metanorma/standoc/version.rb +1 -1
  43. data/metanorma-standoc.gemspec +4 -4
  44. data/spec/asciidoctor/base_spec.rb +701 -508
  45. data/spec/asciidoctor/blocks_spec.rb +831 -738
  46. data/spec/asciidoctor/cleanup_sections_spec.rb +51 -14
  47. data/spec/asciidoctor/cleanup_spec.rb +889 -682
  48. data/spec/asciidoctor/inline_spec.rb +62 -14
  49. data/spec/asciidoctor/isobib_cache_spec.rb +404 -358
  50. data/spec/asciidoctor/lists_spec.rb +149 -137
  51. data/spec/asciidoctor/macros_plantuml_spec.rb +8 -8
  52. data/spec/asciidoctor/macros_spec.rb +923 -503
  53. data/spec/asciidoctor/macros_yaml2text_spec.rb +1 -1
  54. data/spec/asciidoctor/refs_dl_spec.rb +4 -4
  55. data/spec/asciidoctor/refs_spec.rb +1528 -1533
  56. data/spec/asciidoctor/section_spec.rb +405 -299
  57. data/spec/asciidoctor/table_spec.rb +6 -6
  58. data/spec/asciidoctor/validate_spec.rb +342 -304
  59. data/spec/spec_helper.rb +13 -9
  60. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +54 -54
  61. data/spec/vcr_cassettes/isobib_get_123.yml +13 -13
  62. data/spec/vcr_cassettes/isobib_get_123_1.yml +25 -25
  63. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +37 -37
  64. data/spec/vcr_cassettes/isobib_get_123_2001.yml +12 -12
  65. data/spec/vcr_cassettes/isobib_get_124.yml +13 -13
  66. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +14 -14
  67. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +46 -46
  68. metadata +16 -15
  69. data/lib/liquid/custom_blocks/key_iterator.rb +0 -21
  70. data/lib/liquid/custom_blocks/with_json_nested_context.rb +0 -18
  71. data/lib/liquid/custom_blocks/with_yaml_nested_context.rb +0 -19
  72. data/lib/liquid/custom_filters/values.rb +0 -7
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
  RSpec.describe Asciidoctor::Standoc do
4
4
  it "processes basic tables" do
5
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
5
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", *OPTIONS)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
6
6
  #{ASCIIDOC_BLANK_HDR}
7
7
  .Table Name
8
8
  |===
@@ -36,7 +36,7 @@ RSpec.describe Asciidoctor::Standoc do
36
36
  end
37
37
 
38
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")
39
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", *OPTIONS)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
40
40
  #{ASCIIDOC_BLANK_HDR}
41
41
  [width=75%]
42
42
  |===
@@ -96,7 +96,7 @@ RSpec.describe Asciidoctor::Standoc do
96
96
  end
97
97
 
98
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")
99
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", *OPTIONS)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
100
100
  #{ASCIIDOC_BLANK_HDR}
101
101
  [cols=".<,.^,^.>"]
102
102
  |===
@@ -182,7 +182,7 @@ RSpec.describe Asciidoctor::Standoc do
182
182
 
183
183
 
184
184
  it "inserts header rows in a table with a name and no header" do
185
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
185
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", *OPTIONS)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
186
186
  #{ASCIIDOC_BLANK_HDR}
187
187
  [headerrows=2]
188
188
  .Table Name
@@ -222,7 +222,7 @@ RSpec.describe Asciidoctor::Standoc do
222
222
 
223
223
 
224
224
  it "inserts header rows in a table without a name and no header" do
225
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
225
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", *OPTIONS)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
226
226
  #{ASCIIDOC_BLANK_HDR}
227
227
  [headerrows=2]
228
228
  |===
@@ -258,7 +258,7 @@ RSpec.describe Asciidoctor::Standoc do
258
258
  end
259
259
 
260
260
  it "processes complex tables" do
261
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
261
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", *OPTIONS)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
262
262
  #{ASCIIDOC_BLANK_HDR}
263
263
  [cols="<.^,^.<,^.>,^,^",options="header,footer",headerrows=2,alt="An extensive summary, and illustration, of tables",subsequence="A",options="unnumbered",summary="This is an extremely long, convoluted summary",width=70%,number="3",keep-with-next=true,keep-lines-together=true]
264
264
  .Maximum _permissible_ mass fraction of defects
@@ -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", backend: :standoc, header_footer: true) }.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", backend: :standoc, header_footer: true)
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", backend: :standoc, header_footer: true)
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", backend: :standoc, header_footer: true)
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", backend: :standoc, header_footer: true)
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", backend: :standoc, header_footer: true) }.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", backend: :standoc, header_footer: true)
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", backend: :standoc, header_footer: true)
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", backend: :standoc, header_footer: true)
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", backend: :standoc, header_footer: true)
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,261 @@ 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", backend: :standoc, header_footer: true)
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", backend: :standoc, header_footer: true)
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", backend: :standoc, header_footer: true)
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", backend: :standoc, header_footer: true)
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", backend: :standoc, header_footer: true)
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", backend: :standoc, header_footer: true)
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", backend: :standoc, header_footer: true)
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", backend: :standoc, header_footer: true) }.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", backend: :standoc, header_footer: true) }.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", backend: :standoc, header_footer: true)
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
316
+
317
+ [bibliography]
318
+ == Normative References
319
+ * [[[iev,IEV]]], _iev_
381
320
 
382
- Paragraph
321
+ == Terms and definitions
322
+ === Fonctionnelle, f
383
323
 
384
- === Clause 1.1
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
385
331
 
386
- Subclause
387
- INPUT
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
388
339
 
389
- expect(File.read("test/test.err")).to include "Hanging paragraph in clause"
390
- end
340
+ it "warns and aborts if concept/xref does not point to term" 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:
391
349
 
392
- it "Warning if no block for footnoteblock" do
393
- FileUtils.rm_f "test.err"
394
- Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
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
350
+ [[abc]]
351
+ == Clause 1
417
352
 
353
+ {{<<abc>>,term}}
354
+ INPUT
355
+ expect { Asciidoctor.convert(input, *OPTIONS) }.to raise_error(SystemExit)
356
+ rescue SystemExit
357
+ end
358
+ expect(File.read("test.err"))
359
+ .to include "Concept term is pointing to abc, which is not a term"
360
+ expect(File.exist?("test.xml")).to be false
361
+ end
362
+
363
+ it "warns and aborts if id used twice" do
364
+ FileUtils.rm_f "test.xml"
365
+ FileUtils.rm_f "test.err"
366
+ begin
367
+ input = <<~INPUT
368
+ = Document title
369
+ Author
370
+ :docfile: test.adoc
371
+ :nodoc:
372
+
373
+ [[abc]]
374
+ == Clause 1
375
+
376
+ [[abc]]
377
+ == Clause 2
378
+ INPUT
379
+ expect { Asciidoctor.convert(input, *OPTIONS) }.to raise_error(SystemExit)
380
+ rescue SystemExit
381
+ end
382
+ expect(File.read("test.err"))
383
+ .to include "Anchor abc has already been used at line"
384
+ expect(File.exist?("test.xml")).to be false
385
+ end
386
+
387
+ it "warns and aborts if numeric normative reference" do
388
+ FileUtils.rm_f "test.xml"
389
+ FileUtils.rm_f "test.err"
390
+ begin
391
+ input = <<~INPUT
392
+ = Document title
393
+ Author
394
+ :docfile: test.adoc
395
+ :nodoc:
396
+
397
+ [bibliography]
398
+ == Normative references
399
+ * [[[A,1]]]
400
+ INPUT
401
+ expect { Asciidoctor.convert(input, *OPTIONS) }.to raise_error(SystemExit)
402
+ rescue SystemExit
403
+ end
404
+ expect(File.read("test.err"))
405
+ .to include "Numeric reference in normative references"
406
+ expect(File.exist?("test.xml")).to be false
407
+ end
408
+
409
+ it "err file succesfully created for docfile path" do
410
+ FileUtils.rm_rf "test"
411
+ FileUtils.mkdir_p "test"
412
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
413
+ = Document title
414
+ Author
415
+ :docfile: test#{File::ALT_SEPARATOR || File::SEPARATOR}test.adoc
416
+ :nodoc:
417
+
418
+ == Clause 1
419
+
420
+ Paragraph
421
+
422
+ === Clause 1.1
423
+
424
+ Subclause
425
+ INPUT
426
+
427
+ expect(File.read("test/test.err")).to include "Hanging paragraph in clause"
428
+ end
429
+
430
+ it "Warning if no block for footnoteblock" do
431
+ FileUtils.rm_f "test.err"
432
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
433
+ = Document title
434
+ Author
435
+ :docfile: test.adoc
436
+
437
+ footnoteblock:[id1]
438
+
439
+ [[id2]]
440
+ [NOTE]
441
+ --
442
+ |===
443
+ |a |b
444
+
445
+ |c |d
446
+ |===
447
+
448
+ * A
449
+ * B
450
+ * C
451
+ --
452
+ INPUT
453
+ expect(File.read("test.err"))
454
+ .to include "Could not resolve footnoteblock:[id1]"
455
+ end
418
456
  end