metanorma-standoc 2.0.2 → 2.0.5

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 (57) hide show
  1. checksums.yaml +4 -4
  2. data/lib/metanorma/standoc/base.rb +73 -23
  3. data/lib/metanorma/standoc/basicdoc.rng +5 -3
  4. data/lib/metanorma/standoc/biblio.rng +5 -3
  5. data/lib/metanorma/standoc/blocks.rb +4 -4
  6. data/lib/metanorma/standoc/cleanup_amend.rb +33 -30
  7. data/lib/metanorma/standoc/cleanup_boilerplate.rb +29 -5
  8. data/lib/metanorma/standoc/cleanup_image.rb +117 -3
  9. data/lib/metanorma/standoc/cleanup_ref.rb +32 -3
  10. data/lib/metanorma/standoc/cleanup_ref_dl.rb +25 -16
  11. data/lib/metanorma/standoc/cleanup_section.rb +2 -2
  12. data/lib/metanorma/standoc/cleanup_terms_designations.rb +4 -2
  13. data/lib/metanorma/standoc/cleanup_text.rb +39 -17
  14. data/lib/metanorma/standoc/cleanup_xref.rb +82 -13
  15. data/lib/metanorma/standoc/converter.rb +2 -1
  16. data/lib/metanorma/standoc/inline.rb +21 -12
  17. data/lib/metanorma/standoc/isodoc.rng +73 -3
  18. data/lib/metanorma/standoc/macros.rb +14 -2
  19. data/lib/metanorma/standoc/macros_embed.rb +35 -14
  20. data/lib/metanorma/standoc/macros_note.rb +4 -3
  21. data/lib/metanorma/standoc/processor.rb +6 -1
  22. data/lib/metanorma/standoc/ref.rb +20 -16
  23. data/lib/metanorma/standoc/ref_utility.rb +8 -6
  24. data/lib/metanorma/standoc/render.rb +7 -3
  25. data/lib/metanorma/standoc/table.rb +8 -10
  26. data/lib/metanorma/standoc/term_lookup_cleanup.rb +16 -10
  27. data/lib/metanorma/standoc/terms.rb +10 -7
  28. data/lib/metanorma/standoc/utils.rb +3 -1
  29. data/lib/metanorma/standoc/validate.rb +81 -7
  30. data/lib/metanorma/standoc/version.rb +1 -1
  31. data/metanorma-standoc.gemspec +2 -2
  32. data/spec/assets/a2.adoc +4 -2
  33. data/spec/assets/a3.adoc +2 -2
  34. data/spec/assets/a3a.adoc +7 -0
  35. data/spec/metanorma/base_spec.rb +1 -1
  36. data/spec/metanorma/cleanup_blocks_spec.rb +136 -0
  37. data/spec/metanorma/cleanup_spec.rb +34 -23
  38. data/spec/metanorma/cleanup_terms_spec.rb +16 -4
  39. data/spec/metanorma/inline_spec.rb +31 -0
  40. data/spec/metanorma/isobib_cache_spec.rb +2 -2
  41. data/spec/metanorma/macros_plantuml_spec.rb +41 -42
  42. data/spec/metanorma/macros_spec.rb +267 -4
  43. data/spec/metanorma/processor_spec.rb +17 -13
  44. data/spec/metanorma/refs_spec.rb +632 -460
  45. data/spec/metanorma/section_spec.rb +1 -1
  46. data/spec/metanorma/validate_spec.rb +108 -0
  47. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +48 -48
  48. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +13 -13
  49. data/spec/vcr_cassettes/hide_refs.yml +100 -100
  50. data/spec/vcr_cassettes/isobib_get_123.yml +12 -12
  51. data/spec/vcr_cassettes/isobib_get_123_1.yml +25 -25
  52. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +35 -35
  53. data/spec/vcr_cassettes/isobib_get_123_2001.yml +11 -11
  54. data/spec/vcr_cassettes/isobib_get_124.yml +13 -13
  55. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +18 -18
  56. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +86 -66
  57. metadata +10 -9
@@ -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>
@@ -585,7 +596,7 @@ RSpec.describe Metanorma::Standoc do
585
596
  <title type='main' format='text/plain' language='en' script='Latn'>International Electrotechnical Vocabulary (IEV) — Part 102: Mathematics — General concepts and linear algebra</title>
586
597
  <uri type="src">https://webstore.iec.ch/publication/160</uri>
587
598
  <uri type="obp">/preview/info_iec60050-102%7Bed1.0%7Db.pdf</uri>
588
- <docidentifier type="IEC">IEC 60050-102:2007</docidentifier>
599
+ <docidentifier type="IEC" primary="true">IEC 60050-102:2007</docidentifier>
589
600
  <docidentifier type='URN'>urn:iec:std:iec:60050-102:2007:::en</docidentifier>
590
601
  <date type="published">
591
602
  <on>2007-08-27</on>
@@ -624,7 +635,7 @@ RSpec.describe Metanorma::Standoc do
624
635
  <title type="main" format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary (IEV) — Part 103: Mathematics — Functions</title>
625
636
  <uri type="src">https://webstore.iec.ch/publication/161</uri>
626
637
  <uri type="obp">/preview/info_iec60050-103%7Bed1.0%7Db.pdf</uri>
627
- <docidentifier type="IEC">IEC 60050-103:2009</docidentifier>
638
+ <docidentifier type="IEC" primary="true">IEC 60050-103:2009</docidentifier>
628
639
  <docidentifier type='URN'>urn:iec:std:iec:60050-103:2009:::en</docidentifier>
629
640
  <date type="published">
630
641
  <on>2009-12-14</on>
@@ -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>
@@ -1288,7 +1299,7 @@ RSpec.describe Metanorma::Standoc do
1288
1299
  <sourcecode id='L__xf6_we'>
1289
1300
  <name>
1290
1301
  See
1291
- <eref type='inline' bibitemid='L__xf6_wner2016' citeas='L&#246;wner et al. 2016'/>
1302
+ <eref type='inline' bibitemid='L__xf6_wner2016' citeas='L&amp;#xf6;wner et al. 2016'/>
1292
1303
  </name>
1293
1304
  ABC
1294
1305
  </sourcecode>
@@ -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}
@@ -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