metanorma-standoc 2.0.3 → 2.0.4

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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/lib/metanorma/standoc/base.rb +61 -22
  3. data/lib/metanorma/standoc/blocks.rb +3 -3
  4. data/lib/metanorma/standoc/cleanup_boilerplate.rb +3 -3
  5. data/lib/metanorma/standoc/cleanup_ref.rb +31 -2
  6. data/lib/metanorma/standoc/cleanup_ref_dl.rb +20 -16
  7. data/lib/metanorma/standoc/cleanup_section.rb +1 -1
  8. data/lib/metanorma/standoc/cleanup_terms_designations.rb +4 -2
  9. data/lib/metanorma/standoc/cleanup_xref.rb +70 -8
  10. data/lib/metanorma/standoc/converter.rb +1 -0
  11. data/lib/metanorma/standoc/inline.rb +21 -12
  12. data/lib/metanorma/standoc/isodoc.rng +63 -3
  13. data/lib/metanorma/standoc/macros.rb +13 -1
  14. data/lib/metanorma/standoc/macros_embed.rb +1 -1
  15. data/lib/metanorma/standoc/ref.rb +5 -6
  16. data/lib/metanorma/standoc/render.rb +7 -3
  17. data/lib/metanorma/standoc/table.rb +8 -10
  18. data/lib/metanorma/standoc/term_lookup_cleanup.rb +2 -1
  19. data/lib/metanorma/standoc/utils.rb +3 -1
  20. data/lib/metanorma/standoc/version.rb +1 -1
  21. data/spec/metanorma/base_spec.rb +1 -1
  22. data/spec/metanorma/cleanup_spec.rb +10 -10
  23. data/spec/metanorma/cleanup_terms_spec.rb +1 -1
  24. data/spec/metanorma/inline_spec.rb +31 -0
  25. data/spec/metanorma/macros_plantuml_spec.rb +41 -42
  26. data/spec/metanorma/macros_spec.rb +138 -2
  27. data/spec/metanorma/processor_spec.rb +17 -13
  28. data/spec/metanorma/refs_spec.rb +129 -2
  29. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +45 -45
  30. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +10 -10
  31. data/spec/vcr_cassettes/hide_refs.yml +39 -39
  32. data/spec/vcr_cassettes/isobib_get_123.yml +12 -12
  33. data/spec/vcr_cassettes/isobib_get_123_1.yml +23 -23
  34. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +28 -28
  35. data/spec/vcr_cassettes/isobib_get_123_2001.yml +11 -11
  36. data/spec/vcr_cassettes/isobib_get_124.yml +12 -12
  37. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +18 -18
  38. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +75 -65
  39. metadata +2 -2
@@ -19,9 +19,7 @@ module Metanorma
19
19
  xml.table **attr_code(table_attrs(node)) do |xml_table|
20
20
  colgroup(node, xml_table)
21
21
  table_name(node, xml_table)
22
- %i(head body foot).reject do |tblsec|
23
- node.rows[tblsec].empty?
24
- end
22
+ %i(head body foot).reject { |tblsec| node.rows[tblsec].empty? }
25
23
  table_head_body_and_foot node, xml_table
26
24
  end
27
25
  end
@@ -50,12 +48,12 @@ module Metanorma
50
48
  end
51
49
  end
52
50
 
53
- def table_cell1(cell, thd)
54
- thd << if cell.style == :asciidoc
55
- cell.content
56
- else
57
- cell.text
58
- end
51
+ def table_cell1(cell)
52
+ if cell.style == :asciidoc
53
+ cell.content
54
+ else
55
+ cell.text
56
+ end
59
57
  end
60
58
 
61
59
  def table_cell(node, xml_tr, tblsec)
@@ -65,7 +63,7 @@ module Metanorma
65
63
  cell_tag = "td"
66
64
  cell_tag = "th" if tblsec == :head || node.style == :header
67
65
  xml_tr.send cell_tag, **attr_code(cell_attributes) do |thd|
68
- table_cell1(node, thd)
66
+ thd << table_cell1(node)
69
67
  end
70
68
  end
71
69
 
@@ -162,7 +162,8 @@ module Metanorma
162
162
  def normalize_ref_id(term)
163
163
  t = term.dup
164
164
  t.xpath(".//index").map(&:remove)
165
- Metanorma::Utils::to_ncname(t.text.downcase.gsub(/[[:space:]]/, "-"))
165
+ Metanorma::Utils::to_ncname(t.text.strip.downcase
166
+ .gsub(/[[:space:]]+/, "-"))
166
167
  end
167
168
 
168
169
  def unique_text_id(text, prefix)
@@ -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")
@@ -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.4".freeze
23
23
  end
24
24
  end
@@ -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
 
@@ -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>
@@ -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>
@@ -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}
@@ -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
 
@@ -748,7 +748,7 @@ RSpec.describe Metanorma::Standoc do
748
748
  <definitions id='clause1' obligation='normative'>
749
749
  <title>Symbols and abbreviated terms</title>
750
750
  <dl id='_'>
751
- <dt id='symbol-_-__x230a_x__x230b_-'>
751
+ <dt id='symbol-__x230a_-x-__x230b_'>
752
752
  <stem type='MathML'>
753
753
  <math xmlns='http://www.w3.org/1998/Math/MathML'>
754
754
  <mo>&#8970;</mo>
@@ -770,7 +770,7 @@ RSpec.describe Metanorma::Standoc do
770
770
  function.
771
771
  </p>
772
772
  </dd>
773
- <dt id='symbol-_-__x2308_x__x2309_-'>
773
+ <dt id='symbol-__x2308_-x-__x2309_'>
774
774
  <stem type='MathML'>
775
775
  <math xmlns='http://www.w3.org/1998/Math/MathML'>
776
776
  <mo>&#8968;</mo>
@@ -1392,6 +1392,142 @@ RSpec.describe Metanorma::Standoc do
1392
1392
  .to be_equivalent_to xmlpp(output)
1393
1393
  end
1394
1394
 
1395
+ it "processes std-link macro" do
1396
+ VCR.use_cassette "std-link" do
1397
+ input = <<~INPUT
1398
+ #{ISOBIB_BLANK_HDR}
1399
+
1400
+ [[clause1]]
1401
+ == Clause
1402
+
1403
+ std-link:[ISO 131]
1404
+ std-link:[iso:std:iso:13485:en,droploc%clause=4,text]
1405
+ INPUT
1406
+ output = <<~OUTPUT
1407
+ #{BLANK_HDR}
1408
+ <sections>
1409
+ <clause id='clause1' inline-header='false' obligation='normative'>
1410
+ <title>Clause</title>
1411
+ <p id='_'>
1412
+ <eref type='inline' bibitemid='_' citeas='ISO 131'/>
1413
+ <eref type='inline' droploc='true' bibitemid='_' citeas='iso:std:iso:13485:en'>
1414
+ <localityStack>
1415
+ <locality type='clause'>
1416
+ <referenceFrom>4</referenceFrom>
1417
+ </locality>
1418
+ </localityStack>
1419
+ text
1420
+ </eref>
1421
+ </p>
1422
+ </clause>
1423
+ </sections>
1424
+ <bibliography>
1425
+ <references hidden='true' normative='true'>
1426
+ <bibitem id='_' type='standard' hidden="true">
1427
+ <fetched/>
1428
+ <title type='title-intro' format='text/plain' language='en' script='Latn'>Acoustics</title>
1429
+ <title type='title-main' format='text/plain' language='en' script='Latn'>Expression of physical and subjective magnitudes of sound or noise in air</title>
1430
+ <title type='main' format='text/plain' language='en' script='Latn'>
1431
+ Acoustics — Expression of physical and subjective magnitudes of sound
1432
+ or noise in air
1433
+ </title>
1434
+ <uri type='src'>https://www.iso.org/standard/3944.html</uri>
1435
+ <uri type='rss'>https://www.iso.org/contents/data/standard/00/39/3944.detail.rss</uri>
1436
+ <docidentifier type='ISO' primary='true'>ISO 131</docidentifier>
1437
+ <docidentifier type='URN'>urn:iso:std:iso:131:stage-95.99:ed-1:en</docidentifier>
1438
+ <docnumber>131</docnumber>
1439
+ <contributor>
1440
+ <role type='publisher'/>
1441
+ <organization>
1442
+ <name>International Organization for Standardization</name>
1443
+ <abbreviation>ISO</abbreviation>
1444
+ <uri>www.iso.org</uri>
1445
+ </organization>
1446
+ </contributor>
1447
+ <edition>1</edition>
1448
+ <language>en</language>
1449
+ <script>Latn</script>
1450
+ <status>
1451
+ <stage>95</stage>
1452
+ <substage>99</substage>
1453
+ </status>
1454
+ <copyright>
1455
+ <from>1979</from>
1456
+ <owner>
1457
+ <organization>
1458
+ <name>ISO</name>
1459
+ </organization>
1460
+ </owner>
1461
+ </copyright>
1462
+ <relation type='obsoletes'>
1463
+ <bibitem type='standard'>
1464
+ <formattedref format='text/plain'>ISO/R 357:1963</formattedref>
1465
+ </bibitem>
1466
+ </relation>
1467
+ <relation type='instance'>
1468
+ <bibitem type='standard'>
1469
+ <fetched/>
1470
+ <title type='title-intro' format='text/plain' language='en' script='Latn'>Acoustics</title>
1471
+ <title type='title-main' format='text/plain' language='en' script='Latn'>Expression of physical and subjective magnitudes of sound or noise in air</title>
1472
+ <title type='main' format='text/plain' language='en' script='Latn'>
1473
+ Acoustics — Expression of physical and subjective magnitudes of
1474
+ sound or noise in air
1475
+ </title>
1476
+ <uri type='src'>https://www.iso.org/standard/3944.html</uri>
1477
+ <uri type='rss'>https://www.iso.org/contents/data/standard/00/39/3944.detail.rss</uri>
1478
+ <docidentifier type='ISO' primary='true'>ISO 131:1979</docidentifier>
1479
+ <docidentifier type='URN'>urn:iso:std:iso:131:stage-95.99:ed-1:en</docidentifier>
1480
+ <docnumber>131</docnumber>
1481
+ <date type='published'>
1482
+ <on>1979-11</on>
1483
+ </date>
1484
+ <contributor>
1485
+ <role type='publisher'/>
1486
+ <organization>
1487
+ <name>International Organization for Standardization</name>
1488
+ <abbreviation>ISO</abbreviation>
1489
+ <uri>www.iso.org</uri>
1490
+ </organization>
1491
+ </contributor>
1492
+ <edition>1</edition>
1493
+ <language>en</language>
1494
+ <script>Latn</script>
1495
+ <status>
1496
+ <stage>95</stage>
1497
+ <substage>99</substage>
1498
+ </status>
1499
+ <copyright>
1500
+ <from>1979</from>
1501
+ <owner>
1502
+ <organization>
1503
+ <name>ISO</name>
1504
+ </organization>
1505
+ </owner>
1506
+ </copyright>
1507
+ <relation type='obsoletes'>
1508
+ <bibitem type='standard'>
1509
+ <formattedref format='text/plain'>ISO/R 357:1963</formattedref>
1510
+ </bibitem>
1511
+ </relation>
1512
+ <place>Geneva</place>
1513
+ </bibitem>
1514
+ </relation>
1515
+ <place>Geneva</place>
1516
+ </bibitem>
1517
+ <bibitem id='_' hidden="true">
1518
+ <formattedref format='application/x-isodoc+xml'/>
1519
+ <docidentifier type='ISO'>iso:std:iso:13485:en</docidentifier>
1520
+ <docnumber>13485:en</docnumber>
1521
+ </bibitem>
1522
+ </references>
1523
+ </bibliography>
1524
+ </standard-document>
1525
+ OUTPUT
1526
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))
1527
+ .gsub(%r{ bibitemid="_[^"]+"}, ' bibitemid="_"')))
1528
+ .to be_equivalent_to xmlpp(output)
1529
+ end
1530
+ end
1395
1531
 
1396
1532
  describe "term inline macros" do
1397
1533
  subject(:convert) do
@@ -23,13 +23,16 @@ RSpec.describe Metanorma::Standoc::Processor do
23
23
  end
24
24
 
25
25
  it "generates IsoDoc XML from a blank document" do
26
- expect(processor.input_to_isodoc(<<~"INPUT", "test")).to be_equivalent_to <<~"OUTPUT"
26
+ input = <<~INPUT
27
27
  #{ASCIIDOC_BLANK_HDR}
28
28
  INPUT
29
+ output = <<~"OUTPUT"
29
30
  #{BLANK_HDR}
30
31
  <sections/>
31
32
  </iso-standard>
32
33
  OUTPUT
34
+ expect(processor.input_to_isodoc(input, "test"))
35
+ .to be_equivalent_to output
33
36
  end
34
37
 
35
38
  it "generates HTML from IsoDoc XML" do
@@ -45,16 +48,17 @@ RSpec.describe Metanorma::Standoc::Processor do
45
48
  </sections>
46
49
  </iso-standard>
47
50
  INPUT
48
- expect(File.read("test.html", encoding: "utf-8").gsub(%r{^.*<main}m, "<main").gsub(
49
- %r{</main>.*}m, "</main>"
50
- )).to be_equivalent_to <<~"OUTPUT"
51
- <main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
52
- <p class="zzSTDTitle1"></p>
53
- <div id="H"><h1>Terms, Definitions, Symbols and Abbreviated Terms</h1><h2 class="TermNum" id="J"></h2>
54
- <p class="Terms" style="text-align:left;">Term2</p>
55
- </div>
56
- </main>
57
- OUTPUT
51
+ expect(File.read("test.html", encoding: "utf-8")
52
+ .gsub(%r{^.*<main}m, "<main")
53
+ .gsub(%r{</main>.*}m, "</main>"))
54
+ .to be_equivalent_to <<~"OUTPUT"
55
+ <main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
56
+ <p class="zzSTDTitle1"></p>
57
+ <div id="H"><h1>Terms, Definitions, Symbols and Abbreviated Terms</h1><h2 class="TermNum" id="J"></h2>
58
+ <p class="Terms" style="text-align:left;">Term2</p>
59
+ </div>
60
+ </main>
61
+ OUTPUT
58
62
  end
59
63
 
60
64
  it "generates HTML from IsoDoc XML" do
@@ -70,8 +74,8 @@ RSpec.describe Metanorma::Standoc::Processor do
70
74
  </sections>
71
75
  </iso-standard>
72
76
  INPUT
73
- expect(File.read("test.doc",
74
- encoding: "utf-8")).to match(/Terms, Definitions, Symbols and Abbreviated Terms/)
77
+ expect(File.read("test.doc", encoding: "utf-8"))
78
+ .to match(/Terms, Definitions, Symbols and Abbreviated Terms/)
75
79
  end
76
80
 
77
81
  it "generates XML from IsoDoc XML" do