metanorma-standoc 2.0.3 → 2.0.5.1

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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/lib/metanorma/standoc/base.rb +73 -23
  3. data/lib/metanorma/standoc/blocks.rb +1 -1
  4. data/lib/metanorma/standoc/blocks_notes.rb +2 -2
  5. data/lib/metanorma/standoc/cleanup_amend.rb +33 -30
  6. data/lib/metanorma/standoc/cleanup_boilerplate.rb +29 -5
  7. data/lib/metanorma/standoc/cleanup_ref.rb +31 -2
  8. data/lib/metanorma/standoc/cleanup_ref_dl.rb +25 -16
  9. data/lib/metanorma/standoc/cleanup_section.rb +1 -1
  10. data/lib/metanorma/standoc/cleanup_terms_designations.rb +4 -2
  11. data/lib/metanorma/standoc/cleanup_text.rb +39 -17
  12. data/lib/metanorma/standoc/cleanup_xref.rb +70 -8
  13. data/lib/metanorma/standoc/converter.rb +2 -1
  14. data/lib/metanorma/standoc/inline.rb +21 -12
  15. data/lib/metanorma/standoc/isodoc.rng +63 -3
  16. data/lib/metanorma/standoc/macros.rb +14 -2
  17. data/lib/metanorma/standoc/macros_embed.rb +35 -14
  18. data/lib/metanorma/standoc/macros_note.rb +4 -3
  19. data/lib/metanorma/standoc/processor.rb +6 -1
  20. data/lib/metanorma/standoc/ref.rb +14 -15
  21. data/lib/metanorma/standoc/ref_utility.rb +6 -5
  22. data/lib/metanorma/standoc/render.rb +7 -3
  23. data/lib/metanorma/standoc/table.rb +8 -10
  24. data/lib/metanorma/standoc/term_lookup_cleanup.rb +10 -6
  25. data/lib/metanorma/standoc/utils.rb +3 -1
  26. data/lib/metanorma/standoc/validate.rb +79 -10
  27. data/lib/metanorma/standoc/version.rb +1 -1
  28. data/metanorma-standoc.gemspec +2 -2
  29. data/spec/assets/a2.adoc +4 -2
  30. data/spec/assets/a3.adoc +2 -2
  31. data/spec/assets/a3a.adoc +7 -0
  32. data/spec/metanorma/base_spec.rb +1 -1
  33. data/spec/metanorma/cleanup_spec.rb +31 -20
  34. data/spec/metanorma/cleanup_terms_spec.rb +16 -4
  35. data/spec/metanorma/inline_spec.rb +31 -0
  36. data/spec/metanorma/macros_plantuml_spec.rb +41 -42
  37. data/spec/metanorma/macros_spec.rb +206 -4
  38. data/spec/metanorma/processor_spec.rb +17 -13
  39. data/spec/metanorma/refs_spec.rb +129 -2
  40. data/spec/metanorma/validate_spec.rb +108 -0
  41. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +45 -45
  42. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +10 -10
  43. data/spec/vcr_cassettes/hide_refs.yml +39 -39
  44. data/spec/vcr_cassettes/isobib_get_123.yml +12 -12
  45. data/spec/vcr_cassettes/isobib_get_123_1.yml +23 -23
  46. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +28 -28
  47. data/spec/vcr_cassettes/isobib_get_123_2001.yml +11 -11
  48. data/spec/vcr_cassettes/isobib_get_124.yml +12 -12
  49. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +18 -18
  50. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +75 -65
  51. metadata +10 -9
@@ -49,9 +49,79 @@ module Metanorma
49
49
  iev_validate(doc.root)
50
50
  concept_validate(doc, "concept", "refterm")
51
51
  concept_validate(doc, "related", "preferred//name")
52
+ table_validate(doc)
52
53
  @fatalerror.empty? or clean_abort(@fatalerror.join("\n"), doc.to_xml)
53
54
  end
54
55
 
56
+ def table_validate(doc)
57
+ doc.xpath("//table[colgroup]").each do |t|
58
+ maxrowcols_validate(t, t.xpath("./colgroup/col").size)
59
+ end
60
+ doc.xpath("//table[.//*[@colspan] | .//*[@rowspan]]").each do |t|
61
+ maxrowcols_validate(t, max_td_count(t))
62
+ end
63
+ end
64
+
65
+ def max_td_count(table)
66
+ max = 0
67
+ table.xpath(".//tr").each do |tr|
68
+ n = tr.xpath("./td | ./th").size
69
+ max < n and max = n
70
+ end
71
+ max
72
+ end
73
+
74
+ def maxrowcols_validate(table, maxcols)
75
+ cells2d = table.xpath(".//tr").each_with_object([]) { |_r, m| m << {} }
76
+ table.xpath(".//tr").each_with_index do |tr, r|
77
+ curr = 0
78
+ tr.xpath("./td | ./th").each do |td|
79
+ curr = maxcols_validate1(td, r, curr, cells2d, maxcols)
80
+ end
81
+ end
82
+ maxrows_validate(table, cells2d)
83
+ end
84
+
85
+ # code doesn't actually do anything, since Asciidoctor refuses to generate
86
+ # table with inconsistent column count
87
+ def maxcols_validate1(tcell, row, curr, cells2d, maxcols)
88
+ rs = tcell&.attr("rowspan")&.to_i || 1
89
+ cs = tcell&.attr("colspan")&.to_i || 1
90
+ curr = table_tracker_update(cells2d, row, curr, rs, cs)
91
+ maxcols_check(curr + cs - 1, maxcols, tcell)
92
+ curr + cs
93
+ end
94
+
95
+ def table_tracker_update(cells2d, row, curr, rowspan, colspan)
96
+ cells2d[row] ||= {}
97
+ while cells2d[row][curr]
98
+ curr += 1
99
+ end
100
+ (row..(row + rowspan - 1)).each do |y2|
101
+ cells2d[y2] ||= {}
102
+ (curr..(curr + colspan - 1)).each { |x2| cells2d[y2][x2] = 1 }
103
+ end
104
+ curr
105
+ end
106
+
107
+ def maxrows_validate(table, cells2d)
108
+ if cells2d.any? { |x| x.size != cells2d.first.size }
109
+ @log.add("Table", table,
110
+ "Table rows in table are inconsistent: check rowspan")
111
+ @fatalerror << "Table rows in table are inconsistent: check rowspan"
112
+ end
113
+ end
114
+
115
+ # if maxcols or maxrows negative, do not check them
116
+ def maxcols_check(col, maxcols, tcell)
117
+ if maxcols.positive? && col > maxcols
118
+ @log.add("Table", tcell, "Table exceeds maximum number of columns "\
119
+ "defined (#{maxcols})")
120
+ @fatalerror << "Table exceeds maximum number of columns defined "\
121
+ "(#{maxcols})"
122
+ end
123
+ end
124
+
55
125
  def norm_ref_validate(doc)
56
126
  found = false
57
127
  doc.xpath("//references[@normative = 'true']/bibitem").each do |b|
@@ -71,10 +141,9 @@ module Metanorma
71
141
  next if doc.at("//term[@id = '#{x['target']}']")
72
142
  next if doc.at("//definitions//dt[@id = '#{x['target']}']")
73
143
 
74
- ref = x&.at("../#{refterm}")&.text
75
144
  @log.add("Anchors", x,
76
- "#{tag.capitalize} #{ref} is pointing to "\
77
- "#{x['target']}, which is not a term or symbol")
145
+ "#{tag.capitalize} #{x&.at("../#{refterm}")&.text} is "\
146
+ "pointing to #{x['target']}, which is not a term or symbol")
78
147
  found = true
79
148
  end
80
149
  found and
@@ -122,23 +191,23 @@ module Metanorma
122
191
 
123
192
  SVG_NS = "http://www.w3.org/2000/svg".freeze
124
193
 
194
+ WILDCARD_ATTRS =
195
+ "//*[@format] | //stem | //bibdata//description | "\
196
+ "//formattedref | //bibdata//note | //bibdata/abstract | "\
197
+ "//bibitem/abstract | //bibitem/note | //misc-container".freeze
198
+
125
199
  # RelaxNG cannot cope well with wildcard attributes. So we strip
126
200
  # any attributes from FormattedString instances (which can contain
127
201
  # xs:any markup, and are signalled with @format) before validation.
128
202
  def formattedstr_strip(doc)
129
- doc.xpath("//*[@format] | //stem | //bibdata//description | "\
130
- "//formattedref | //bibdata//note | //bibdata/abstract | "\
131
- "//bibitem/abstract | //bibitem/note | //misc-container",
132
- "m" => SVG_NS).each do |n|
203
+ doc.xpath(WILDCARD_ATTRS, "m" => SVG_NS).each do |n|
133
204
  n.elements.each do |e|
134
205
  e.traverse do |e1|
135
206
  e1.element? and e1.each { |k, _v| e1.delete(k) }
136
207
  end
137
208
  end
138
209
  end
139
- doc.xpath("//m:svg", "m" => SVG_NS).each do |n|
140
- n.replace("<svg/>")
141
- end
210
+ doc.xpath("//m:svg", "m" => SVG_NS).each { |n| n.replace("<svg/>") }
142
211
  doc
143
212
  end
144
213
 
@@ -19,6 +19,6 @@ module Metanorma
19
19
  end
20
20
 
21
21
  module Standoc
22
- VERSION = "2.0.3".freeze
22
+ VERSION = "2.0.5.1".freeze
23
23
  end
24
24
  end
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.add_dependency "asciidoctor", "~> 2.0.0"
30
30
  spec.add_dependency "iev", "~> 0.3.0"
31
31
  spec.add_dependency "isodoc", "~> 2.0.0"
32
- spec.add_dependency "metanorma-plugin-datastruct"
32
+ spec.add_dependency "metanorma-plugin-datastruct", "~> 0.2.0"
33
33
  spec.add_dependency "metanorma-plugin-lutaml"
34
34
  spec.add_dependency "ruby-jing"
35
35
  # relaton-cli not just relaton, to avoid circular reference in metanorma
@@ -52,6 +52,6 @@ Gem::Specification.new do |spec|
52
52
  spec.add_development_dependency "sassc", "2.4.0"
53
53
  spec.add_development_dependency "simplecov", "~> 0.15"
54
54
  spec.add_development_dependency "timecop", "~> 0.9"
55
- spec.add_development_dependency "vcr", "~> 5.0.0"
55
+ spec.add_development_dependency "vcr", "~> 6.1.0"
56
56
  spec.add_development_dependency "webmock"
57
57
  end
data/spec/assets/a2.adoc CHANGED
@@ -1,8 +1,10 @@
1
- = X
2
- A
1
+ = A2
2
+ A2
3
3
 
4
4
  == Clause 2
5
5
 
6
6
  X
7
7
 
8
8
  embed::spec/assets/a3.adoc[]
9
+
10
+ embed::spec/assets/a3a.adoc[]
data/spec/assets/a3.adoc CHANGED
@@ -1,5 +1,5 @@
1
- = X
2
- A
1
+ = A3
2
+ A3
3
3
 
4
4
  == Clause 3
5
5
 
@@ -0,0 +1,7 @@
1
+ = A3a
2
+ A3a
3
+
4
+ == Clause 3a
5
+
6
+ X
7
+
@@ -1051,7 +1051,7 @@ QU1FOiB0ZXN0Cgo=
1051
1051
  .new(:standoc, header_footer: true)
1052
1052
  .doc_extract_attributes(node)
1053
1053
 
1054
- expect(options.dig(:mn2pdf, :font_manifest))
1054
+ expect(options[:font_manifest])
1055
1055
  .to eq(node[Metanorma::Standoc::Base::FONTS_MANIFEST])
1056
1056
  end
1057
1057
 
@@ -9,13 +9,21 @@ RSpec.describe Metanorma::Standoc do
9
9
  == "Quotation" A's
10
10
 
11
11
  '24:00:00'.
12
+
13
+ _emphasis_ *strong* `monospace` "double quote" 'single quote'
12
14
  INPUT
13
15
  output = <<~OUTPUT
14
- #{BLANK_HDR}
16
+ #{BLANK_HDR}
15
17
  <sections>
16
18
  <clause id="_" inline-header="false" obligation="normative">
17
19
  <title>“Quotation” A’s</title>
18
20
  <p id='_'>‘24:00:00’.</p>
21
+ <p id='_'>
22
+ <em>emphasis</em>
23
+ <strong>strong</strong>
24
+ <tt>monospace</tt>
25
+ “double quote” ‘single quote’
26
+ </p>
19
27
  </clause>
20
28
  </sections>
21
29
  </standard-document>
@@ -149,6 +157,10 @@ RSpec.describe Metanorma::Standoc do
149
157
  input = <<~INPUT
150
158
  #{ASCIIDOC_BLANK_HDR}
151
159
 
160
+ "*word*",
161
+
162
+ "link:http://example.com[]",
163
+
152
164
  "((ppt))",
153
165
 
154
166
  "((ppm))", "((ppt))"
@@ -160,16 +172,16 @@ RSpec.describe Metanorma::Standoc do
160
172
  ....
161
173
  INPUT
162
174
  output = <<~OUTPUT
163
- #{BLANK_HDR}
164
- <sections>
165
- <p id='_'>
166
- &#8220;ppt&#8221;,
175
+ #{BLANK_HDR}
176
+ <sections>
177
+ <p id='_'>“<strong>word</strong>”,</p>
178
+ <p id='_'>“<link target='http://example.com'/>”,</p>
179
+ <p id='_'>&#8220;ppt&#8221;,
167
180
  <index>
168
181
  <primary>ppt</primary>
169
182
  </index>
170
183
  </p>
171
- <p id='_'>
172
- &#8220;ppm&#8221;,
184
+ <p id='_'>&#8220;ppm&#8221;,
173
185
  <index>
174
186
  <primary>ppm</primary>
175
187
  </index>
@@ -178,12 +190,11 @@ RSpec.describe Metanorma::Standoc do
178
190
  <primary>ppt</primary>
179
191
  </index>
180
192
  </p>
181
- <p id='_'>
182
- &#8220;ppm
193
+ <p id='_'>&#8220;ppm
183
194
  <index>
184
195
  <primary>ppm</primary>
185
196
  </index>
186
- &#8220;&#160;
197
+ &#8221;&#160;
187
198
  </p>
188
199
  <figure id='_'>
189
200
  <pre id='_'>((ppm))",</pre>
@@ -282,7 +293,7 @@ RSpec.describe Metanorma::Standoc do
282
293
  </localityStack>
283
294
  the reference,xyz</eref>
284
295
  <eref type='inline' bibitemid='iso216' citeas='ISO 216'>
285
- <localityStack>
296
+ <localityStack connective="and">
286
297
  <locality type='whole'/>
287
298
  <locality type='clause'>
288
299
  <referenceFrom>3</referenceFrom>
@@ -298,7 +309,7 @@ RSpec.describe Metanorma::Standoc do
298
309
  <referenceFrom>the reference</referenceFrom>
299
310
  </locality>
300
311
  </localityStack>
301
- <localityStack>
312
+ <localityStack connective="and">
302
313
  <locality type='whole'/>
303
314
  <locality type='clause'>
304
315
  <referenceFrom>3</referenceFrom>
@@ -1116,7 +1127,7 @@ RSpec.describe Metanorma::Standoc do
1116
1127
  <dd>
1117
1128
  <p id='_'>Definition 7</p>
1118
1129
  </dd>
1119
- <dt id="symbol-_-n-">
1130
+ <dt id="symbol-n">
1120
1131
  <stem type='MathML'>
1121
1132
  <math xmlns='http://www.w3.org/1998/Math/MathML'>
1122
1133
  <mi>n</mi>
@@ -1178,7 +1189,7 @@ RSpec.describe Metanorma::Standoc do
1178
1189
  <dd>
1179
1190
  <p id='_'>Definition 5</p>
1180
1191
  </dd>
1181
- <dt id='symbol-_-xm-'><stem type='MathML'>
1192
+ <dt id='symbol-x-m'><stem type='MathML'>
1182
1193
  <math xmlns='http://www.w3.org/1998/Math/MathML'>
1183
1194
  <msub>
1184
1195
  <mrow>
@@ -1193,7 +1204,7 @@ RSpec.describe Metanorma::Standoc do
1193
1204
  <dd>
1194
1205
  <p id='_'>Definition 4</p>
1195
1206
  </dd>
1196
- <dt id='symbol-_-x1-'><stem type='MathML'>
1207
+ <dt id='symbol-x-1'><stem type='MathML'>
1197
1208
  <math xmlns='http://www.w3.org/1998/Math/MathML'>
1198
1209
  <msub>
1199
1210
  <mrow>
@@ -1212,7 +1223,7 @@ RSpec.describe Metanorma::Standoc do
1212
1223
  <dd>
1213
1224
  <p id='_'>Definition 2</p>
1214
1225
  </dd>
1215
- <dt id='symbol-_-__x3b1_-'>
1226
+ <dt id='symbol-__x3b1_'>
1216
1227
  <stem type='MathML'>
1217
1228
  <math xmlns='http://www.w3.org/1998/Math/MathML'>
1218
1229
  <mi>α</mi>
@@ -1829,13 +1840,13 @@ RSpec.describe Metanorma::Standoc do
1829
1840
  </ext>
1830
1841
  </bibdata>
1831
1842
  <preface>
1832
- <note id='_f91b621e-d8cb-30bf-eef6-7d0150204829'>
1843
+ <note id='_2cfe95f6-7ad6-aa57-8207-6f7d7928aa8e'>
1833
1844
  <p id='_76d95913-a379-c60f-5144-1f09655cafa6'>
1834
1845
  Note which is very important
1835
1846
  <xref target='_76d95913-a379-c60f-5144-1f09655cafa6'/>
1836
1847
  </p>
1837
1848
  </note>
1838
- <foreword id='_0826616f-13a4-0634-baee-5003c5534175' obligation='informative'>
1849
+ <foreword id='_96b556cb-657c-985b-351b-ed70d8bd6fdd' obligation='informative'>
1839
1850
  <title>Foreword</title>
1840
1851
  <p id='_d2f825bf-3e18-6143-8777-34e59928d48c'>Foreword</p>
1841
1852
  </foreword>
@@ -1845,7 +1856,7 @@ RSpec.describe Metanorma::Standoc do
1845
1856
  </introduction>
1846
1857
  </preface>
1847
1858
  <sections>
1848
- <admonition id='_068def71-3ec8-0395-8853-0e2d3ef5b841' type='important'>
1859
+ <admonition id='_6abb9105-854c-e79c-c351-73a56d6ca81f' type='important'>
1849
1860
  <p id='_69ec375e-c992-5be3-76dd-a2311f9bb6cc'>Notice which is very important</p>
1850
1861
  </admonition>
1851
1862
  <clause id='_scope' type='scope' inline-header='false' obligation='normative'>
@@ -1858,7 +1869,7 @@ RSpec.describe Metanorma::Standoc do
1858
1869
  input1 = xmlpp(Asciidoctor.convert(input, *OPTIONS))
1859
1870
  .sub(/<p id='([^']+)'>(\s+)Note which is very important(\s+)<xref target='a'/,
1860
1871
  "<p id='\\1'>\\2Note which is very important\\3<xref target='\\1'")
1861
- expect(input1)
1872
+ expect(xmlpp(input1))
1862
1873
  .to be_equivalent_to xmlpp(output)
1863
1874
  end
1864
1875
 
@@ -3,6 +3,7 @@ require "relaton_iec"
3
3
  require "fileutils"
4
4
 
5
5
  RSpec.describe Metanorma::Standoc do
6
+ =begin
6
7
  it "processes term and designation metadata and term sources" do
7
8
  input = <<~INPUT
8
9
  #{ASCIIDOC_BLANK_HDR}
@@ -180,8 +181,9 @@ RSpec.describe Metanorma::Standoc do
180
181
  expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
181
182
  .to be_equivalent_to xmlpp(output)
182
183
  end
183
-
184
- it "permits multiple preferred terms, and treats them as synonyms in concepts" do
184
+ =end
185
+ it "permits multiple preferred terms and admitted terms, "\
186
+ "and treats them as synonyms in concepts" do
185
187
  input = <<~INPUT
186
188
  #{ASCIIDOC_BLANK_HDR}
187
189
  == Terms and Definitions
@@ -209,6 +211,9 @@ RSpec.describe Metanorma::Standoc do
209
211
  {{First Designation}}
210
212
 
211
213
  {{Second Designation}}
214
+
215
+ {{Third Designation}}
216
+
212
217
  INPUT
213
218
  output = <<~OUTPUT
214
219
  #{BLANK_HDR}
@@ -279,11 +284,18 @@ RSpec.describe Metanorma::Standoc do
279
284
  </p>
280
285
  <p id='_'>
281
286
  <concept>
282
- <refterm>Second Designation</refterm>
287
+ <refterm>First Designation</refterm>
283
288
  <renderterm>Second Designation</renderterm>
284
289
  <xref target='term-first-designation'/>
285
290
  </concept>
286
291
  </p>
292
+ <p id='_'>
293
+ <concept>
294
+ <refterm>First Designation</refterm>
295
+ <renderterm>Third Designation</renderterm>
296
+ <xref target='term-first-designation'/>
297
+ </concept>
298
+ </p>
287
299
  </clause>
288
300
  </sections>
289
301
  </standard-document>
@@ -728,7 +740,7 @@ RSpec.describe Metanorma::Standoc do
728
740
  <terms id='_' obligation='normative'>
729
741
  <title>Terms and definitions</title>
730
742
  <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
731
- <term id='term-_-t90-'>
743
+ <term id='term-t90'>
732
744
  <preferred>
733
745
  <letter-symbol>
734
746
  <name>
@@ -444,6 +444,37 @@ RSpec.describe Metanorma::Standoc do
444
444
  .to be_equivalent_to(output)
445
445
  end
446
446
 
447
+ it "processes combinations of crossreferences" do
448
+ input = <<~INPUT
449
+ #{ASCIIDOC_BLANK_HDR}
450
+ == Section
451
+
452
+ <<ref1;to!ref2>>
453
+ <<from!ref1;to!ref2,text>>
454
+ <<ref1;ref2>>
455
+ <<ref1;and!ref2>>
456
+ <<ref1;or!ref2,text>>
457
+ <<from!ref1;to!ref2;and!ref3;to!ref4>>
458
+ INPUT
459
+ output = <<~OUTPUT
460
+ #{BLANK_HDR}
461
+ <sections>
462
+ <clause id="_" inline-header="false" obligation="normative">
463
+ <title>Section</title>
464
+ <p id="_"><xref target="ref1"><location target="ref1" connective="from"/><location target="ref2" connective="to"/></xref>
465
+ <xref target="ref1"><location target="ref1" connective="from"/><location target="ref2" connective="to"/>text</xref>
466
+ <xref target="ref1"><location target="ref1" connective="and"/><location target="ref2" connective="and"/></xref>
467
+ <xref target="ref1"><location target="ref1" connective="and"/><location target="ref2" connective="and"/></xref>
468
+ <xref target="ref1"><location target="ref1" connective="and"/><location target="ref2" connective="or"/>text</xref>
469
+ <xref target="ref1"><location target="ref1" connective="from"/><location target="ref2" connective="to"/><location target="ref3" connective="and"/><location target="ref4" connective="to"/></xref></p>
470
+ </clause>
471
+ </sections>
472
+ </standard-document>
473
+ OUTPUT
474
+ expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
475
+ .to be_equivalent_to(output)
476
+ end
477
+
447
478
  it "processes bibliographic anchors" do
448
479
  input = <<~INPUT
449
480
  #{ASCIIDOC_BLANK_HDR}
@@ -129,51 +129,50 @@ RSpec.describe Metanorma::Standoc do
129
129
  expect(
130
130
  xmlpp(
131
131
  strip_guid(Asciidoctor.convert(input, *OPTIONS))
132
- .gsub(%r{".+spec/assets/lutaml/[^./]+\.},
133
- '"spec/assets/_.'),
132
+ .gsub(%r{"[^".]+spec/assets/lutaml/[^./"]+\.png},
133
+ '"spec/assets/_.png'),
134
134
  ),
135
- )
136
- .to(be_equivalent_to(xmlpp(output)))
135
+ ).to(be_equivalent_to(xmlpp(output)))
137
136
  end
137
+ end
138
138
 
139
- context "when inline macro, path supplied as the second arg" do
140
- let(:example_file) { fixtures_path("diagram_definitions.lutaml") }
141
- let(:input) do
142
- <<~TEXT
143
- = Document title
144
- Author
145
- :docfile: test.adoc
146
- :nodoc:
147
- :novalid:
148
- :no-isobib:
149
- :imagesdir: spec/assets
150
- :data-uri-image: false
151
-
152
- lutaml_diagram::#{example_file}[]
153
-
154
- TEXT
155
- end
156
- let(:output) do
157
- <<~TEXT
158
- #{BLANK_HDR}
159
- <sections>
160
- <figure id="_">
161
- <image src="spec/assets/_.png" id="_" mimetype="image/png" height="auto" width="auto"/>
162
- </figure>
163
- </sections>
164
- </standard-document>
165
- TEXT
166
- end
167
-
168
- it "correctly renders input" do
169
- expect(
170
- xmlpp(
171
- strip_guid(Asciidoctor.convert(input, *OPTIONS))
172
- .gsub(%r{".+spec/assets/lutaml/[^./]+\.},
173
- '"spec/assets/_.'),
174
- ),
175
- ).to(be_equivalent_to(xmlpp(output)))
176
- end
139
+ context "when inline macro, path supplied as the second arg" do
140
+ let(:example_file) { fixtures_path("diagram_definitions.lutaml") }
141
+ let(:input) do
142
+ <<~TEXT
143
+ = Document title
144
+ Author
145
+ :docfile: test.adoc
146
+ :nodoc:
147
+ :novalid:
148
+ :no-isobib:
149
+ :imagesdir: spec/assets
150
+ :data-uri-image: false
151
+
152
+ lutaml_diagram::#{example_file}[]
153
+
154
+ TEXT
155
+ end
156
+ let(:output) do
157
+ <<~TEXT
158
+ #{BLANK_HDR}
159
+ <sections>
160
+ <figure id="_">
161
+ <image src="spec/assets/_.png" id="_" mimetype="image/png" height="auto" width="auto"/>
162
+ </figure>
163
+ </sections>
164
+ </standard-document>
165
+ TEXT
166
+ end
167
+
168
+ it "correctly renders input" do
169
+ expect(
170
+ xmlpp(
171
+ strip_guid(Asciidoctor.convert(input, *OPTIONS))
172
+ .gsub(%r{"[^".]+spec/assets/lutaml/[^./"]+\.png},
173
+ '"spec/assets/_.png'),
174
+ ),
175
+ ).to(be_equivalent_to(xmlpp(output)))
177
176
  end
178
177
  end
179
178