metanorma-standoc 2.0.1 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/lib/metanorma/standoc/base.rb +61 -22
  3. data/lib/metanorma/standoc/basicdoc.rng +5 -3
  4. data/lib/metanorma/standoc/biblio.rng +7 -5
  5. data/lib/metanorma/standoc/blocks.rb +3 -3
  6. data/lib/metanorma/standoc/cleanup_boilerplate.rb +3 -3
  7. data/lib/metanorma/standoc/cleanup_image.rb +117 -3
  8. data/lib/metanorma/standoc/cleanup_ref.rb +32 -3
  9. data/lib/metanorma/standoc/cleanup_ref_dl.rb +20 -16
  10. data/lib/metanorma/standoc/cleanup_section.rb +2 -2
  11. data/lib/metanorma/standoc/cleanup_terms_designations.rb +4 -2
  12. data/lib/metanorma/standoc/cleanup_text.rb +0 -22
  13. data/lib/metanorma/standoc/cleanup_xref.rb +82 -13
  14. data/lib/metanorma/standoc/converter.rb +2 -0
  15. data/lib/metanorma/standoc/inline.rb +21 -12
  16. data/lib/metanorma/standoc/isodoc.rng +142 -4
  17. data/lib/metanorma/standoc/macros.rb +14 -1
  18. data/lib/metanorma/standoc/macros_embed.rb +72 -0
  19. data/lib/metanorma/standoc/ref.rb +11 -7
  20. data/lib/metanorma/standoc/ref_utility.rb +2 -1
  21. data/lib/metanorma/standoc/render.rb +7 -3
  22. data/lib/metanorma/standoc/table.rb +8 -10
  23. data/lib/metanorma/standoc/term_lookup_cleanup.rb +9 -6
  24. data/lib/metanorma/standoc/terms.rb +10 -7
  25. data/lib/metanorma/standoc/utils.rb +3 -1
  26. data/lib/metanorma/standoc/validate.rb +7 -2
  27. data/lib/metanorma/standoc/version.rb +1 -1
  28. data/spec/assets/a1.adoc +8 -0
  29. data/spec/assets/a2.adoc +8 -0
  30. data/spec/assets/a3.adoc +9 -0
  31. data/spec/assets/a4.adoc +4 -0
  32. data/spec/metanorma/base_spec.rb +1 -1
  33. data/spec/metanorma/cleanup_blocks_spec.rb +136 -0
  34. data/spec/metanorma/cleanup_spec.rb +13 -13
  35. data/spec/metanorma/cleanup_terms_spec.rb +1 -1
  36. data/spec/metanorma/inline_spec.rb +31 -0
  37. data/spec/metanorma/isobib_cache_spec.rb +2 -2
  38. data/spec/metanorma/macros_plantuml_spec.rb +41 -42
  39. data/spec/metanorma/macros_spec.rb +288 -2
  40. data/spec/metanorma/processor_spec.rb +17 -13
  41. data/spec/metanorma/refs_spec.rb +633 -461
  42. data/spec/metanorma/section_spec.rb +1 -1
  43. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +48 -48
  44. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +13 -13
  45. data/spec/vcr_cassettes/hide_refs.yml +100 -100
  46. data/spec/vcr_cassettes/isobib_get_123.yml +12 -12
  47. data/spec/vcr_cassettes/isobib_get_123_1.yml +25 -25
  48. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +35 -35
  49. data/spec/vcr_cassettes/isobib_get_123_2001.yml +11 -11
  50. data/spec/vcr_cassettes/isobib_get_124.yml +13 -13
  51. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +18 -18
  52. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +86 -66
  53. metadata +7 -2
@@ -92,7 +92,7 @@ module Metanorma
92
92
  end
93
93
  end
94
94
 
95
- def term_source_attrs(_node, seen_xref)
95
+ def termsource_origin_attrs(_node, seen_xref)
96
96
  { case: seen_xref.children[0]["case"],
97
97
  droploc: seen_xref.children[0]["droploc"],
98
98
  bibitemid: seen_xref.children[0]["target"],
@@ -103,7 +103,7 @@ module Metanorma
103
103
  if seen_xref.children[0].name == "concept"
104
104
  xml_t.origin { |o| o << seen_xref.children[0].to_xml }
105
105
  else
106
- attrs = term_source_attrs(node, seen_xref)
106
+ attrs = termsource_origin_attrs(node, seen_xref)
107
107
  attrs.delete(:text)
108
108
  xml_t.origin **attr_code(attrs) do |o|
109
109
  o << seen_xref.children[0].children.to_xml
@@ -135,13 +135,16 @@ module Metanorma
135
135
  matched
136
136
  end
137
137
 
138
+ def termsource_attrs(node, matched)
139
+ status = node.attr("status") ||
140
+ (matched[:text] ? "modified" : "identical")
141
+ { status: status, type: node.attr("type") || "authoritative" }
142
+ end
143
+
138
144
  def termsource(node)
139
- matched = extract_termsource_refs(node.content, node) || return
145
+ matched = extract_termsource_refs(node.content, node) or return
140
146
  noko do |xml|
141
- status = node.attr("status") ||
142
- (matched[:text] ? "modified" : "identical")
143
- attrs = { status: status, type: node.attr("type") || "authoritative" }
144
- xml.termsource **attrs do |xml_t|
147
+ xml.termsource **termsource_attrs(node, matched) do |xml_t|
145
148
  seen_xref = Nokogiri::XML.fragment(matched[:xref])
146
149
  add_term_source(node, xml_t, seen_xref, matched)
147
150
  end
@@ -32,7 +32,9 @@ module Metanorma
32
32
  doc = ::Nokogiri::XML.parse(NOKOHEAD)
33
33
  fragment = doc.fragment("")
34
34
  ::Nokogiri::XML::Builder.with fragment, &block
35
- fragment.to_xml(encoding: "US-ASCII", indent: 0).lines.map do |l|
35
+ fragment.to_xml(encoding: "US-ASCII", indent: 0,
36
+ save_with: Nokogiri::XML::Node::SaveOptions::AS_XML)
37
+ .lines.map do |l|
36
38
  l.gsub(/>\n$/, ">").gsub(/\s*\n$/m, " ").gsub("&#150;", "\u0096")
37
39
  .gsub("&#151;", "\u0097").gsub("&#x96;", "\u0096")
38
40
  .gsub("&#x97;", "\u0097")
@@ -120,20 +120,25 @@ module Metanorma
120
120
  end
121
121
  end
122
122
 
123
+ SVG_NS = "http://www.w3.org/2000/svg".freeze
124
+
123
125
  # RelaxNG cannot cope well with wildcard attributes. So we strip
124
126
  # any attributes from FormattedString instances (which can contain
125
127
  # xs:any markup, and are signalled with @format) before validation.
126
128
  def formattedstr_strip(doc)
127
129
  doc.xpath("//*[@format] | //stem | //bibdata//description | "\
128
130
  "//formattedref | //bibdata//note | //bibdata/abstract | "\
129
- "//bibitem/abstract | //bibitem/note | //misc-container")
130
- .each do |n|
131
+ "//bibitem/abstract | //bibitem/note | //misc-container",
132
+ "m" => SVG_NS).each do |n|
131
133
  n.elements.each do |e|
132
134
  e.traverse do |e1|
133
135
  e1.element? and e1.each { |k, _v| e1.delete(k) }
134
136
  end
135
137
  end
136
138
  end
139
+ doc.xpath("//m:svg", "m" => SVG_NS).each do |n|
140
+ n.replace("<svg/>")
141
+ end
137
142
  doc
138
143
  end
139
144
 
@@ -19,6 +19,6 @@ module Metanorma
19
19
  end
20
20
 
21
21
  module Standoc
22
- VERSION = "2.0.1".freeze
22
+ VERSION = "2.0.4".freeze
23
23
  end
24
24
  end
@@ -0,0 +1,8 @@
1
+ = X
2
+ A
3
+
4
+ == Clause 1
5
+
6
+ X
7
+
8
+ embed::spec/assets/a2.adoc[]
@@ -0,0 +1,8 @@
1
+ = X
2
+ A
3
+
4
+ == Clause 2
5
+
6
+ X
7
+
8
+ embed::spec/assets/a3.adoc[]
@@ -0,0 +1,9 @@
1
+ = X
2
+ A
3
+
4
+ == Clause 3
5
+
6
+ X
7
+
8
+ include::spec/assets/a4.adoc[]
9
+
@@ -0,0 +1,4 @@
1
+ == Clause 4
2
+
3
+ X
4
+
@@ -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
 
@@ -1039,4 +1039,140 @@ RSpec.describe Metanorma::Standoc do
1039
1039
  annotation_id = output.at("//xmlns:annotation/@id").text
1040
1040
  expect(callout_id).to eq(annotation_id)
1041
1041
  end
1042
+ it "deduplicates identifiers in inline SVGs" do
1043
+ input = <<~INPUT
1044
+ #{BLANK_HDR}
1045
+ <sections>
1046
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 256 256">
1047
+ <defs>
1048
+ <linearGradient id="gradient1">
1049
+ <stop class="stop1" offset="0%" xlink:href="#gradient1"/>
1050
+ <stop class="stop2" offset="100%"/>
1051
+ <style>url(#gradient1)</style>
1052
+ </linearGradient>
1053
+ </defs>
1054
+ <circle fill="url(#gradient1)" cx="128" cy="128" r="100" />
1055
+ </svg>
1056
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 256 256">
1057
+ <defs>
1058
+ <linearGradient id="gradient2">
1059
+ <stop class="stop1" offset="0%" xlink:href="#gradient2"/>
1060
+ <stop class="stop2" offset="100%"/>
1061
+ <style>url(#gradient2)</style>
1062
+ </linearGradient>
1063
+ </defs>
1064
+ <circle fill="url(#gradient2)" cx="128" cy="128" r="100" />
1065
+ </svg>
1066
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 256 256">
1067
+ <defs>
1068
+ <linearGradient id="gradient1">
1069
+ <stop class="stop1" offset="0%" xlink:href="#gradient1"/>
1070
+ <stop class="stop2" offset="100%"/>
1071
+ <style>url(#gradient1)</style>
1072
+ </linearGradient>
1073
+ </defs>
1074
+ <circle fill="url(#gradient1)" cx="128" cy="128" r="100" />
1075
+ </svg>
1076
+ </sections>
1077
+ </standard-document>
1078
+ INPUT
1079
+ output = <<~OUTPUT
1080
+ #{BLANK_HDR}
1081
+ <sections>
1082
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" viewBox="0 0 256 256">
1083
+ <defs>
1084
+ <linearGradient id="gradient1_inject_0">
1085
+ <stop class="stop1" offset="0%" xlink:href="#gradient1_inject_0"/>
1086
+ <stop class="stop2" offset="100%"/>
1087
+ <style>url(#gradient1_inject_0)</style>
1088
+ </linearGradient>
1089
+ </defs>
1090
+ <circle fill="url(#gradient1_inject_0)" cx="128" cy="128" r="100"/>
1091
+ </svg>
1092
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" viewBox="0 0 256 256">
1093
+ <defs>
1094
+ <linearGradient id="gradient2">
1095
+ <stop class="stop1" offset="0%" xlink:href="#gradient2"/>
1096
+ <stop class="stop2" offset="100%"/>
1097
+ <style>url(#gradient2)</style>
1098
+ </linearGradient>
1099
+ </defs>
1100
+ <circle fill="url(#gradient2)" cx="128" cy="128" r="100"/>
1101
+ </svg>
1102
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" viewBox="0 0 256 256">
1103
+ <defs>
1104
+ <linearGradient id="gradient1_inject_2">
1105
+ <stop class="stop1" offset="0%" xlink:href="#gradient1_inject_2"/>
1106
+ <stop class="stop2" offset="100%"/>
1107
+ <style>url(#gradient1_inject_2)</style>
1108
+ </linearGradient>
1109
+ </defs>
1110
+ <circle fill="url(#gradient1_inject_2)" cx="128" cy="128" r="100"/>
1111
+ </svg>
1112
+ </sections>
1113
+ </standard-document>
1114
+ OUTPUT
1115
+ expect(Metanorma::Standoc::Converter.new(nil, *OPTIONS)
1116
+ .cleanup(Nokogiri::XML(input)).to_xml)
1117
+ .to be_equivalent_to xmlpp(output)
1118
+ end
1119
+
1120
+ it "deduplicates identifiers in embedded SVGs" do
1121
+ input = <<~INPUT
1122
+ #{ASCIIDOC_BLANK_HDR.sub(/:data-uri-image: false/, ':data-uri-image: true')}
1123
+
1124
+ image::spec/fixtures/action_schemaexpg1.svg[]
1125
+
1126
+ image::spec/examples/rice_images/rice_image1.png[]
1127
+
1128
+ image::spec/fixtures/action_schemaexpg1.svg[]
1129
+ INPUT
1130
+
1131
+ output = <<~OUTPUT
1132
+ #{BLANK_HDR}
1133
+ <sections>
1134
+ <figure id='_'>
1135
+ <svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' id='Layer_1' x='0px' y='0px' viewBox='0 0 595.28 841.89' style='enable-background:new 0 0 595.28 841.89;' xml:space='preserve'>
1136
+ <style/>
1137
+ <image/>
1138
+ <a xlink:href='mn://action_schema'>
1139
+ <rect x='123.28' y='273.93' class='st0' width='88.05' height='41.84'/>
1140
+ </a>
1141
+ <a xlink:href='mn://basic_attribute_schema'>
1142
+ <rect x='324.69' y='450.52' class='st0' width='132.62' height='40.75'/>
1143
+ </a>
1144
+ <a xlink:href='mn://support_resource_schema'>
1145
+ <rect x='324.69' y='528.36' class='st0' width='148.16' height='40.75'/>
1146
+ </a>
1147
+ </svg>
1148
+ </figure>
1149
+ <figure id='_'>
1150
+ <image/>
1151
+ </figure>
1152
+ <figure id='_'>
1153
+ <svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' id='Layer_1_inject_1' x='0px' y='0px' viewBox='0 0 595.28 841.89' style='enable-background:new 0 0 595.28 841.89;' xml:space='preserve'>
1154
+ <style/>
1155
+ <image/>
1156
+ <a xlink:href='mn://action_schema'>
1157
+ <rect x='123.28' y='273.93' class='st0' width='88.05' height='41.84'/>
1158
+ </a>
1159
+ <a xlink:href='mn://basic_attribute_schema'>
1160
+ <rect x='324.69' y='450.52' class='st0' width='132.62' height='40.75'/>
1161
+ </a>
1162
+ <a xlink:href='mn://support_resource_schema'>
1163
+ <rect x='324.69' y='528.36' class='st0' width='148.16' height='40.75'/>
1164
+ </a>
1165
+ </svg>
1166
+ </figure>
1167
+ </sections>
1168
+ </standard-document>
1169
+ OUTPUT
1170
+ xml = Nokogiri::XML(Asciidoctor.convert(input, *OPTIONS))
1171
+ xml.xpath("//*[local-name() = 'image']").each do |x|
1172
+ x.replace("<image/>")
1173
+ end
1174
+ expect(xmlpp(strip_guid(xml.to_xml)
1175
+ .gsub(%r{<style.*?</style>}m, "<style/>")))
1176
+ .to be_equivalent_to xmlpp(output)
1177
+ end
1042
1178
  end
@@ -282,7 +282,7 @@ RSpec.describe Metanorma::Standoc do
282
282
  </localityStack>
283
283
  the reference,xyz</eref>
284
284
  <eref type='inline' bibitemid='iso216' citeas='ISO 216'>
285
- <localityStack>
285
+ <localityStack connective="and">
286
286
  <locality type='whole'/>
287
287
  <locality type='clause'>
288
288
  <referenceFrom>3</referenceFrom>
@@ -298,7 +298,7 @@ RSpec.describe Metanorma::Standoc do
298
298
  <referenceFrom>the reference</referenceFrom>
299
299
  </locality>
300
300
  </localityStack>
301
- <localityStack>
301
+ <localityStack connective="and">
302
302
  <locality type='whole'/>
303
303
  <locality type='clause'>
304
304
  <referenceFrom>3</referenceFrom>
@@ -585,7 +585,7 @@ RSpec.describe Metanorma::Standoc do
585
585
  <title type='main' format='text/plain' language='en' script='Latn'>International Electrotechnical Vocabulary (IEV) — Part 102: Mathematics — General concepts and linear algebra</title>
586
586
  <uri type="src">https://webstore.iec.ch/publication/160</uri>
587
587
  <uri type="obp">/preview/info_iec60050-102%7Bed1.0%7Db.pdf</uri>
588
- <docidentifier type="IEC">IEC 60050-102:2007</docidentifier>
588
+ <docidentifier type="IEC" primary="true">IEC 60050-102:2007</docidentifier>
589
589
  <docidentifier type='URN'>urn:iec:std:iec:60050-102:2007:::en</docidentifier>
590
590
  <date type="published">
591
591
  <on>2007-08-27</on>
@@ -624,7 +624,7 @@ RSpec.describe Metanorma::Standoc do
624
624
  <title type="main" format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary (IEV) — Part 103: Mathematics — Functions</title>
625
625
  <uri type="src">https://webstore.iec.ch/publication/161</uri>
626
626
  <uri type="obp">/preview/info_iec60050-103%7Bed1.0%7Db.pdf</uri>
627
- <docidentifier type="IEC">IEC 60050-103:2009</docidentifier>
627
+ <docidentifier type="IEC" primary="true">IEC 60050-103:2009</docidentifier>
628
628
  <docidentifier type='URN'>urn:iec:std:iec:60050-103:2009:::en</docidentifier>
629
629
  <date type="published">
630
630
  <on>2009-12-14</on>
@@ -1116,7 +1116,7 @@ RSpec.describe Metanorma::Standoc do
1116
1116
  <dd>
1117
1117
  <p id='_'>Definition 7</p>
1118
1118
  </dd>
1119
- <dt id="symbol-_-n-">
1119
+ <dt id="symbol-n">
1120
1120
  <stem type='MathML'>
1121
1121
  <math xmlns='http://www.w3.org/1998/Math/MathML'>
1122
1122
  <mi>n</mi>
@@ -1178,7 +1178,7 @@ RSpec.describe Metanorma::Standoc do
1178
1178
  <dd>
1179
1179
  <p id='_'>Definition 5</p>
1180
1180
  </dd>
1181
- <dt id='symbol-_-xm-'><stem type='MathML'>
1181
+ <dt id='symbol-x-m'><stem type='MathML'>
1182
1182
  <math xmlns='http://www.w3.org/1998/Math/MathML'>
1183
1183
  <msub>
1184
1184
  <mrow>
@@ -1193,7 +1193,7 @@ RSpec.describe Metanorma::Standoc do
1193
1193
  <dd>
1194
1194
  <p id='_'>Definition 4</p>
1195
1195
  </dd>
1196
- <dt id='symbol-_-x1-'><stem type='MathML'>
1196
+ <dt id='symbol-x-1'><stem type='MathML'>
1197
1197
  <math xmlns='http://www.w3.org/1998/Math/MathML'>
1198
1198
  <msub>
1199
1199
  <mrow>
@@ -1212,7 +1212,7 @@ RSpec.describe Metanorma::Standoc do
1212
1212
  <dd>
1213
1213
  <p id='_'>Definition 2</p>
1214
1214
  </dd>
1215
- <dt id='symbol-_-__x3b1_-'>
1215
+ <dt id='symbol-__x3b1_'>
1216
1216
  <stem type='MathML'>
1217
1217
  <math xmlns='http://www.w3.org/1998/Math/MathML'>
1218
1218
  <mi>α</mi>
@@ -1288,7 +1288,7 @@ RSpec.describe Metanorma::Standoc do
1288
1288
  <sourcecode id='L__xf6_we'>
1289
1289
  <name>
1290
1290
  See
1291
- <eref type='inline' bibitemid='L__xf6_wner2016' citeas='L&#246;wner et al. 2016'/>
1291
+ <eref type='inline' bibitemid='L__xf6_wner2016' citeas='L&amp;#xf6;wner et al. 2016'/>
1292
1292
  </name>
1293
1293
  ABC
1294
1294
  </sourcecode>
@@ -1829,13 +1829,13 @@ RSpec.describe Metanorma::Standoc do
1829
1829
  </ext>
1830
1830
  </bibdata>
1831
1831
  <preface>
1832
- <note id='_f91b621e-d8cb-30bf-eef6-7d0150204829'>
1832
+ <note id='_2cfe95f6-7ad6-aa57-8207-6f7d7928aa8e'>
1833
1833
  <p id='_76d95913-a379-c60f-5144-1f09655cafa6'>
1834
1834
  Note which is very important
1835
1835
  <xref target='_76d95913-a379-c60f-5144-1f09655cafa6'/>
1836
1836
  </p>
1837
1837
  </note>
1838
- <foreword id='_0826616f-13a4-0634-baee-5003c5534175' obligation='informative'>
1838
+ <foreword id='_96b556cb-657c-985b-351b-ed70d8bd6fdd' obligation='informative'>
1839
1839
  <title>Foreword</title>
1840
1840
  <p id='_d2f825bf-3e18-6143-8777-34e59928d48c'>Foreword</p>
1841
1841
  </foreword>
@@ -1845,7 +1845,7 @@ RSpec.describe Metanorma::Standoc do
1845
1845
  </introduction>
1846
1846
  </preface>
1847
1847
  <sections>
1848
- <admonition id='_068def71-3ec8-0395-8853-0e2d3ef5b841' type='important'>
1848
+ <admonition id='_6abb9105-854c-e79c-c351-73a56d6ca81f' type='important'>
1849
1849
  <p id='_69ec375e-c992-5be3-76dd-a2311f9bb6cc'>Notice which is very important</p>
1850
1850
  </admonition>
1851
1851
  <clause id='_scope' type='scope' inline-header='false' obligation='normative'>
@@ -1858,7 +1858,7 @@ RSpec.describe Metanorma::Standoc do
1858
1858
  input1 = xmlpp(Asciidoctor.convert(input, *OPTIONS))
1859
1859
  .sub(/<p id='([^']+)'>(\s+)Note which is very important(\s+)<xref target='a'/,
1860
1860
  "<p id='\\1'>\\2Note which is very important\\3<xref target='\\1'")
1861
- expect(input1)
1861
+ expect(xmlpp(input1))
1862
1862
  .to be_equivalent_to xmlpp(output)
1863
1863
  end
1864
1864
 
@@ -728,7 +728,7 @@ RSpec.describe Metanorma::Standoc do
728
728
  <terms id='_' obligation='normative'>
729
729
  <title>Terms and definitions</title>
730
730
  <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
731
- <term id='term-_-t90-'>
731
+ <term id='term-t90'>
732
732
  <preferred>
733
733
  <letter-symbol>
734
734
  <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}
@@ -49,7 +49,7 @@ ISO_124_DATED = <<~XML.freeze
49
49
  <uri type="src">https://www.iso.org/standard/61884.html</uri>
50
50
  <uri type="obp">https://www.iso.org/obp/ui/#!iso:std:61884:en</uri>
51
51
  <uri type="rss">https://www.iso.org/contents/data/standard/06/18/61884.detail.rss</uri>
52
- <docidentifier type="ISO">ISO 124:2014</docidentifier>
52
+ <docidentifier type="ISO" primary="true">ISO 124:2014</docidentifier>
53
53
  <docidentifier type='URN'>urn:iso:std:iso:124:stage-90.93:ed-7:en</docidentifier>
54
54
  <docnumber>124</docnumber>
55
55
  <date type="published">
@@ -208,7 +208,7 @@ ISO_123_DATED = <<~XML.freeze
208
208
  <uri type="src">https://www.iso.org/standard/23281.html</uri>
209
209
  <uri type="obp">https://www.iso.org/obp/ui/#!iso:std:23281:en</uri>
210
210
  <uri type="rss">https://www.iso.org/contents/data/standard/02/32/23281.detail.rss</uri>
211
- <docidentifier type="ISO">ISO 123:2001</docidentifier>
211
+ <docidentifier type="ISO" primary="true">ISO 123:2001</docidentifier>
212
212
  <docidentifier type='URN'>urn:iso:std:iso:123:stage-90.93:ed-3:en</docidentifier>
213
213
  <docnumber>123</docnumber>
214
214
  <date type="published">
@@ -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