isodoc 2.0.7 → 2.0.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e038a4b4f203a16e86b716deffc9602d005c305312aebedbaf88231cfe263a60
4
- data.tar.gz: 0f873f9ce5847c0a33296714a60917d3112a95ef04f3b2ea7052b18f0fcdab8c
3
+ metadata.gz: 391849b43509b58e8e08eb2ab4e2922cdb3c6ac21ac287110518078b73601465
4
+ data.tar.gz: 8b15f3e7f8c608c0521c3347616a6ea2df7d09092d3830c2bd71f58ea23a95fc
5
5
  SHA512:
6
- metadata.gz: 8c146a97d03c932fe72755edf96a9ad26806daf7c7de07814f8afd93714e1a88193b476e972bed1c17820eeca3f9216c6e07931d8fe56e6d036f857d9537339d
7
- data.tar.gz: c081e93e7e29fd600f5968550a51a81c29f5663c6d5fb45c6f0a853978a3fdc1bc07d06a4b4e3161a4c67c78c3de7cd3ecc2e5b18999e25fec2d88ce010d9998
6
+ metadata.gz: 7f7b97e099260821ec96ec660c2bfa180dff43f2c3b186a2fa42ddebeb5052fe19904afbd62b28215caedeab4f5184c3fbee89171b3fd3a9759e91329bbbfc16
7
+ data.tar.gz: 53584cc076ed6b5537c592e4c750f069ba5ef69159c8ecabfe787968b5af4024b61868e1e98b7fbf1d03975980087b89557e2fe252e3a74cb42844bcd684ab6c
data/isodoc.gemspec CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
34
34
  spec.add_dependency "isodoc-i18n", "~> 1.0.0"
35
35
  spec.add_dependency "liquid", "~> 4"
36
36
  # spec.add_dependency "metanorma", ">= 1.2.0"
37
- spec.add_dependency "emf2svg", "~> 1"
37
+ spec.add_dependency "emf2svg", "<= 1.3"
38
38
  spec.add_dependency "mathml2asciimath"
39
39
  spec.add_dependency "metanorma-utils"
40
40
  spec.add_dependency "nokogiri", "~> 1.12.0"
@@ -43,6 +43,8 @@ module IsoDoc
43
43
  # tocfigures: add ToC for figures
44
44
  # toctables: add ToC for tables
45
45
  # tocrecommendations: add ToC for rcommendations
46
+ # fonts: fontist fonts to install
47
+ # fontlicenseagreement: fontist font license agreement
46
48
  def initialize(options)
47
49
  @libdir ||= File.dirname(__FILE__) # rubocop:disable Lint/DisjunctiveAssignmentInConstructor
48
50
  options.merge!(default_fonts(options)) do |_, old, new|
@@ -57,10 +59,7 @@ module IsoDoc
57
59
  init_stylesheets(options)
58
60
  init_covers(options)
59
61
  init_toc(options)
60
- @normalfontsize = options[:normalfontsize]
61
- @smallerfontsize = options[:smallerfontsize]
62
- @monospacefontsize = options[:monospacefontsize]
63
- @footnotefontsize = options[:footnotefontsize]
62
+ init_fonts(options)
64
63
  @i18nyaml = options[:i18nyaml]
65
64
  @ulstyle = options[:ulstyle]
66
65
  @olstyle = options[:olstyle]
@@ -96,6 +95,15 @@ module IsoDoc
96
95
  @tmpfilesdir_suffix = tmpfilesdir_suffix
97
96
  end
98
97
 
98
+ def init_fonts(options)
99
+ @normalfontsize = options[:normalfontsize]
100
+ @smallerfontsize = options[:smallerfontsize]
101
+ @monospacefontsize = options[:monospacefontsize]
102
+ @footnotefontsize = options[:footnotefontsize]
103
+ @fontist_fonts = options[:fonts]
104
+ @fontlicenseagreement = options[:fontlicenseagreement]
105
+ end
106
+
99
107
  def init_covers(options)
100
108
  @header = options[:header]
101
109
  @htmlcoverpage = options[:htmlcoverpage]
data/lib/isodoc/css.rb CHANGED
@@ -29,10 +29,10 @@ module IsoDoc
29
29
  @wordstylesheet = generate_css(localpath(@wordstylesheet_name), false)
30
30
  @standardstylesheet =
31
31
  generate_css(localpath(@standardstylesheet_name), false)
32
- @htmlstylesheet_override_name and @htmlstylesheet_override =
33
- File.open(localpath(@htmlstylesheet_override_name))
34
- @wordstylesheet_override_name and @wordstylesheet_override =
35
- File.open(localpath(@wordstylesheet_override_name))
32
+ @htmlstylesheet_override_name and
33
+ @htmlstylesheet_override = File.open(localpath(@htmlstylesheet_override_name))
34
+ @wordstylesheet_override_name and
35
+ @wordstylesheet_override = File.open(localpath(@wordstylesheet_override_name))
36
36
  end
37
37
 
38
38
  def default_fonts(_options)
@@ -80,12 +80,12 @@ module IsoDoc
80
80
 
81
81
  [File.join(Gem.loaded_specs["isodoc"].full_gem_path,
82
82
  "lib", "isodoc"),
83
- File.dirname(filename)].each do |name|
84
- SassC.load_paths << name
85
- end
86
- SassC::Engine.new(scss_fontheader(stripwordcss) + stylesheet,
87
- syntax: :scss, importer: SasscImporter)
88
- .render
83
+ File.dirname(filename)].each do |name|
84
+ SassC.load_paths << name
85
+ end
86
+ SassC::Engine.new(scss_fontheader(stripwordcss) + stylesheet,
87
+ syntax: :scss, importer: SasscImporter)
88
+ .render
89
89
  end
90
90
 
91
91
  # stripwordcss if HTML stylesheet, !stripwordcss if DOC stylesheet
@@ -96,6 +96,7 @@ module IsoDoc
96
96
  stylesheet = File.read(filename, encoding: "UTF-8")
97
97
  stylesheet = populate_template(stylesheet, :word)
98
98
  stylesheet.gsub!(/(\s|\{)mso-[^:]+:[^;]+;/m, "\\1") if stripwordcss
99
+ stylesheet.gsub!(/--/, "-DOUBLE_HYPHEN_ESCAPE-") unless stripwordcss
99
100
  if File.extname(filename) == ".scss"
100
101
  stylesheet = convert_scss(filename, stylesheet, stripwordcss)
101
102
  end
@@ -171,7 +171,7 @@ module IsoDoc
171
171
  if b.name == "bibitem"
172
172
  next if implicit_reference(b)
173
173
 
174
- i += 1
174
+ i += 1 unless b["hidden"]
175
175
  if standard?(b) then std_bibitem_entry(div, b, i, biblio)
176
176
  else nonstd_bibitem(div, b, i, biblio)
177
177
  end
@@ -190,7 +190,7 @@ module IsoDoc
190
190
  (f = isoxml.at(ns(norm_ref_xpath)) and f["hidden"] != "true") or
191
191
  return num
192
192
  out.div do |div|
193
- num = num + 1
193
+ num += 1
194
194
  clause_name(num, f.at(ns("./title")), div, nil)
195
195
  if f.name == "clause"
196
196
  f.elements.each { |e| parse(e, div) unless e.name == "title" }
@@ -1,7 +1,10 @@
1
+ require "csv"
2
+
1
3
  module IsoDoc
2
4
  class PresentationXMLConvert < ::IsoDoc::Convert
3
5
  def bibdata(docxml)
4
6
  toc_metadata(docxml)
7
+ fonts_metadata(docxml)
5
8
  docid_prefixes(docxml)
6
9
  a = bibdata_current(docxml) or return
7
10
  address_precompose(a)
@@ -34,6 +37,23 @@ module IsoDoc
34
37
  end
35
38
  end
36
39
 
40
+ def fonts_metadata(xmldoc)
41
+ return unless @fontist_fonts
42
+
43
+ ins = xmldoc.at(ns("//presentation-metadata")) ||
44
+ xmldoc.at(ns("//misc-container")) || xmldoc.at(ns("//bibdata"))
45
+ CSV.parse_line(@fontist_fonts, col_sep: ";").map(&:strip).each do |f|
46
+ ins.next = presmeta("fonts", f)
47
+ end
48
+ @fontlicenseagreement and
49
+ ins.next = presmeta("font-license-agreement", @fontlicenseagreement)
50
+ end
51
+
52
+ def presmeta(name, value)
53
+ "<presentation-metadata><name>#{name}</name><value>#{value}</value>"\
54
+ "</presentation-metadata>"
55
+ end
56
+
37
57
  def address_precompose1(addr)
38
58
  ret = []
39
59
  addr.xpath(ns("./street")).each { |s| ret << s.children.to_xml }
@@ -29,8 +29,7 @@ module IsoDoc
29
29
  def figure1(elem)
30
30
  return sourcecode1(elem) if elem["class"] == "pseudocode" ||
31
31
  elem["type"] == "pseudocode"
32
- return if (labelled_ancestor(elem) && elem.ancestors("figure").empty?) ||
33
- (elem.at(ns("./figure")) && !elem.at(ns("./name")))
32
+ return if elem.at(ns("./figure")) && !elem.at(ns("./name"))
34
33
 
35
34
  lbl = @xrefs.anchor(elem["id"], :label, false) or return
36
35
  prefix_name(elem, "&nbsp;&mdash; ",
@@ -69,8 +69,8 @@ module IsoDoc
69
69
  def bibliography_bibitem_number_skip(bibitem)
70
70
  @xrefs.klass.implicit_reference(bibitem) ||
71
71
  bibitem.at(ns(".//docidentifier[@type = 'metanorma']")) ||
72
- bibitem.at(ns(".//docidentifier[@type = 'metanorma-ordinal']"))
73
- # || @xrefs.klass.standard?(bibitem)
72
+ bibitem.at(ns(".//docidentifier[@type = 'metanorma-ordinal']")) ||
73
+ bibitem["hidden"] == "true" || bibitem.parent["hidden"] == "true"
74
74
  end
75
75
 
76
76
  def bibliography_bibitem_number(docxml)
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "2.0.7".freeze
2
+ VERSION = "2.0.8.2".freeze
3
3
  end
@@ -39,6 +39,7 @@ module IsoDoc
39
39
 
40
40
  def toWord(result, filename, dir, header)
41
41
  result = from_xhtml(word_cleanup(to_xhtml(result)))
42
+ .gsub(/-DOUBLE_HYPHEN_ESCAPE-/, "--")
42
43
  @wordstylesheet = wordstylesheet_update
43
44
  Html2Doc.process(
44
45
  result,
@@ -112,7 +112,7 @@ module IsoDoc
112
112
  end
113
113
 
114
114
  def increment(node)
115
- return self if node["unnumbered"]
115
+ return self if node["unnumbered"] || node["hidden"]
116
116
 
117
117
  @letter_override = nil
118
118
  @number_override = nil
@@ -25,7 +25,7 @@ module IsoDoc
25
25
  j = 0
26
26
  clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]"))
27
27
  .each do |t|
28
- next if labelled_ancestor(t) && t.ancestors("figure").empty?
28
+ # next if labelled_ancestor(t) && t.ancestors("figure").empty?
29
29
 
30
30
  j = subfigure_increment(j, c, t)
31
31
  label = c.print + (j.zero? ? "" : "-#{j}")
@@ -111,7 +111,7 @@ module IsoDoc
111
111
  j = 0
112
112
  clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]"))
113
113
  .each do |t|
114
- next if labelled_ancestor(t) && t.ancestors("figure").empty?
114
+ # next if labelled_ancestor(t) && t.ancestors("figure").empty?
115
115
 
116
116
  j = subfigure_increment(j, c, t)
117
117
  label = "#{num}#{hiersep}#{c.print}" +
@@ -34,9 +34,9 @@ internal_external_terms_boilerplate: |
34
34
  <p>% 界定的以及下列术语和定义适用于本文件。</p>
35
35
  term_defined_in: "〖术语于%中定义〗"
36
36
  binary_and: "%1和%2"
37
- multiple_and: "%1和%2"
37
+ multiple_and: "%1、和%2"
38
38
  binary_or: "%1或%2"
39
- multiple_or: "%1或%2"
39
+ multiple_or: "%1、或%2"
40
40
  chain_and: "%1和%2"
41
41
  chain_or: "%1或%2"
42
42
  chain_from: "%1从%2"
@@ -2497,7 +2497,6 @@ RSpec.describe IsoDoc do
2497
2497
  <bibliography>
2498
2498
  <references hidden='true' normative='false' displayorder="1">
2499
2499
  <bibitem id='express_action_schema' type='internal'>
2500
- <docidentifier type='metanorma-ordinal'>[1]</docidentifier>
2501
2500
  <docidentifier type='repository'>express/action_schema</docidentifier>
2502
2501
  </bibitem>
2503
2502
  </references>
@@ -644,7 +644,7 @@ RSpec.describe IsoDoc do
644
644
  </introduction></preface><sections>
645
645
  <clause id="D" obligation="normative" type="scope" displayorder="3">
646
646
  <title depth="1">1.<tab/>Scope</title>
647
- <p id="E"><eref type="inline" bibitemid="ISO712"><locality type="table"><referenceFrom>1</referenceFrom><referenceTo>1</referenceTo></locality>ISO 712&#x3001;&#x7B2C;1&#x2013;1&#x8868;</eref></p>
647
+ <p id="E"><eref type="inline" bibitemid="ISO712"><locality type="table"><referenceFrom>1</referenceFrom><referenceTo>1</referenceTo></locality>ISO 712, &#x7B2C;1&#x2013;1 &#x8868;</eref></p>
648
648
  </clause>
649
649
  <clause id="H" obligation="normative" displayorder="5"><title depth="1">3.<tab/>Terms, definitions, symbols and abbreviated terms</title><terms id="I" obligation="normative">
650
650
  <title depth="2">3.1.<tab/>Normal Terms</title>
@@ -722,7 +722,7 @@ RSpec.describe IsoDoc do
722
722
  <div id="D">
723
723
  <h1>1.&#12288;Scope</h1>
724
724
  <p id="E">
725
- <a href='#ISO712'>ISO 712&#12289;&#31532;1&#8211;1&#34920;</a>
725
+ <a href='#ISO712'>ISO 712, &#31532;1&#8211;1 &#34920;</a>
726
726
  </p>
727
727
  </div>
728
728
  <div>
@@ -1603,7 +1603,7 @@ RSpec.describe IsoDoc do
1603
1603
  <bibliography>
1604
1604
  <references id='_normative_references' obligation='informative' normative='true' displayorder='2' hidden="true">
1605
1605
  <title depth='1'>
1606
- 1.
1606
+ 0.
1607
1607
  <tab/>
1608
1608
  Normative References
1609
1609
  </title>
@@ -1709,7 +1709,7 @@ RSpec.describe IsoDoc do
1709
1709
  OUTPUT
1710
1710
 
1711
1711
  expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
1712
- .convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
1712
+ .convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
1713
1713
  expect(xmlpp(IsoDoc::HtmlConvert.new({})
1714
1714
  .convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
1715
1715
  expect(xmlpp(IsoDoc::WordConvert.new({})
@@ -1158,7 +1158,6 @@ RSpec.describe IsoDoc do
1158
1158
  .to be_equivalent_to xmlpp(presxml)
1159
1159
  end
1160
1160
 
1161
-
1162
1161
  it "inserts toc metadata" do
1163
1162
  input = <<~INPUT
1164
1163
  <iso-standard xmlns="http://riboseinc.com/isoxml">
@@ -1194,7 +1193,7 @@ RSpec.describe IsoDoc do
1194
1193
  end
1195
1194
 
1196
1195
  it "processes multiple-target xrefs" do
1197
- input = <<~INPUT
1196
+ input = <<~INPUT
1198
1197
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1199
1198
  <bibdata/>
1200
1199
  <sections>
@@ -1295,6 +1294,179 @@ RSpec.describe IsoDoc do
1295
1294
  .to be_equivalent_to xmlpp(presxml)
1296
1295
  end
1297
1296
 
1297
+ it "captions embedded figures" do
1298
+ input = <<~INPUT
1299
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
1300
+ <bibdata/>
1301
+ <sections>
1302
+ <clause id="A" inline-header="false" obligation="normative">
1303
+ <title>Section</title>
1304
+ <figure id="B1">
1305
+ <name>First</name>
1306
+ </figure>
1307
+ <example id="C1">
1308
+ <figure id="B2">
1309
+ <name>Second</name>
1310
+ </figure>
1311
+ </example>
1312
+ <example id="C2">
1313
+ <figure id="B4" unnumbered="true">
1314
+ <name>Unnamed</name>
1315
+ </figure>
1316
+ </example>
1317
+ <figure id="B3">
1318
+ <name>Third</name>
1319
+ </figure>
1320
+ </clause>
1321
+ </sections>
1322
+ </iso-standard>
1323
+ INPUT
1324
+ presxml = <<~OUTPUT
1325
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
1326
+ <bibdata/>
1327
+
1328
+ <sections>
1329
+ <clause id='A' inline-header='false' obligation='normative' displayorder='1'>
1330
+ <title depth='1'>
1331
+ 1.
1332
+ <tab/>
1333
+ Section
1334
+ </title>
1335
+ <figure id='B1'>
1336
+ <name>Figure 1&#xA0;&#x2014; First</name>
1337
+ </figure>
1338
+ <example id='C1'>
1339
+ <name>EXAMPLE 1</name>
1340
+ <figure id='B2'>
1341
+ <name>Figure 2&#xA0;&#x2014; Second</name>
1342
+ </figure>
1343
+ </example>
1344
+ <example id='C2'>
1345
+ <name>EXAMPLE 2</name>
1346
+ <figure id='B4' unnumbered='true'>
1347
+ <name>Unnamed</name>
1348
+ </figure>
1349
+ </example>
1350
+ <figure id='B3'>
1351
+ <name>Figure 3&#xA0;&#x2014; Third</name>
1352
+ </figure>
1353
+ </clause>
1354
+ </sections>
1355
+ </iso-standard>
1356
+ OUTPUT
1357
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
1358
+ .convert("test", input, true))
1359
+ .sub(%r{<localized-strings>.*</localized-strings>}m, ""))
1360
+ .to be_equivalent_to xmlpp(presxml)
1361
+ end
1362
+
1363
+ it "passes font names to Presentation XML" do
1364
+ input = <<~INPUT
1365
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
1366
+ <bibdata/>
1367
+ <sections>
1368
+ <clause id="A" inline-header="false" obligation="normative">
1369
+ <title>Section</title>
1370
+ <figure id="B1">
1371
+ <name>First</name>
1372
+ </figure>
1373
+ </clause>
1374
+ </sections>
1375
+ </iso-standard>
1376
+ INPUT
1377
+ presxml = <<~OUTPUT
1378
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
1379
+ <bibdata/>
1380
+ <presentation-metadata>
1381
+ <name>font-license-agreement</name>
1382
+ <value>no-install-fonts</value>
1383
+ </presentation-metadata>
1384
+ <presentation-metadata>
1385
+ <name>fonts</name>
1386
+ <value>font2</value>
1387
+ </presentation-metadata>
1388
+ <presentation-metadata>
1389
+ <name>fonts</name>
1390
+ <value>font1</value>
1391
+ </presentation-metadata>
1392
+ <sections>
1393
+ <clause id='A' inline-header='false' obligation='normative' displayorder='1'>
1394
+ <title depth='1'>
1395
+ 1.
1396
+ <tab/>
1397
+ Section
1398
+ </title>
1399
+ <figure id='B1'>
1400
+ <name>Figure 1&#xA0;&#x2014; First</name>
1401
+ </figure>
1402
+ </clause>
1403
+ </sections>
1404
+ </iso-standard>
1405
+ OUTPUT
1406
+ expect(xmlpp(IsoDoc::PresentationXMLConvert
1407
+ .new({ fonts: "font1; font2", fontlicenseagreement: "no-install-fonts" })
1408
+ .convert("test", input, true))
1409
+ .sub(%r{<localized-strings>.*</localized-strings>}m, ""))
1410
+ .to be_equivalent_to xmlpp(presxml)
1411
+ end
1412
+
1413
+ it "skips numbering of hidden sections" do
1414
+ input = <<~INPUT
1415
+ <standard-document xmlns="https://www.metanorma.org/ns/standoc" type="semantic">
1416
+ <bibdata/>
1417
+ <sections><clause id="_scope" type="scope" inline-header="false" obligation="normative">
1418
+ <title>Scope</title>
1419
+ <p id="_8d98c053-85d7-e8cc-75bb-183a14209d61">A</p>
1420
+
1421
+ <p id="_2141c040-93a4-785a-73f0-ffad4fa1779f"><eref type="inline" bibitemid="_607373b1-0cc4-fcdb-c482-fd86ae572bd1" citeas="ISO 639-2"/></p>
1422
+ </clause>
1423
+
1424
+ <terms id="_terms_and_definitions" obligation="normative">
1425
+ <title>Terms and definitions</title><p id="_36938d4b-05e5-bd0f-a082-0415db50e8f7">No terms and definitions are listed in this document.</p>
1426
+
1427
+ </terms>
1428
+ </sections><bibliography><references hidden="true" normative="true">
1429
+ <title>Normative references</title>
1430
+ </references>
1431
+ </bibliography></standard-document>
1432
+ INPUT
1433
+ presxml = <<~OUTPUT
1434
+ <standard-document xmlns="https://www.metanorma.org/ns/standoc" type="presentation">
1435
+ <bibdata/>
1436
+ <sections>
1437
+ <clause id='_scope' type='scope' inline-header='false' obligation='normative' displayorder='1'>
1438
+ <title depth='1'>
1439
+ 1.
1440
+ <tab/>
1441
+ Scope
1442
+ </title>
1443
+ <p id='_8d98c053-85d7-e8cc-75bb-183a14209d61'>A</p>
1444
+ <p id='_2141c040-93a4-785a-73f0-ffad4fa1779f'>
1445
+ <eref type='inline' bibitemid='_607373b1-0cc4-fcdb-c482-fd86ae572bd1' citeas='ISO 639-2'>ISO 639-2</eref>
1446
+ </p>
1447
+ </clause>
1448
+ <terms id='_terms_and_definitions' obligation='normative' displayorder='3'>
1449
+ <title depth='1'>
1450
+ 2.
1451
+ <tab/>
1452
+ Terms and definitions
1453
+ </title>
1454
+ <p id='_36938d4b-05e5-bd0f-a082-0415db50e8f7'>No terms and definitions are listed in this document.</p>
1455
+ </terms>
1456
+ </sections>
1457
+ <bibliography>
1458
+ <references hidden='true' normative='true' displayorder='2'>
1459
+ <title depth='1'>Normative references</title>
1460
+ </references>
1461
+ </bibliography>
1462
+ </standard-document>
1463
+ OUTPUT
1464
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
1465
+ .convert("test", input, true))
1466
+ .sub(%r{<localized-strings>.*</localized-strings>}m, ""))
1467
+ .to be_equivalent_to xmlpp(presxml)
1468
+ end
1469
+
1298
1470
  private
1299
1471
 
1300
1472
  def mock_symbols
@@ -902,4 +902,100 @@ RSpec.describe IsoDoc do
902
902
  ).at("//xmlns:bibliography").to_xml))
903
903
  .to be_equivalent_to xmlpp(presxml)
904
904
  end
905
+
906
+ it "enforces consistent references numbering with hidden items: metanorma identifiers" do
907
+ input = <<~INPUT
908
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
909
+ <bibdata>
910
+ <language>en</language>
911
+ </bibdata>
912
+ <bibliography><references id="_normative_references" obligation="informative" normative="false"><title>Bibliography</title>
913
+ <bibitem id="ref1" type="standard">
914
+ <title format="text/plain">Cereals or cereal products</title>
915
+ <docidentifier type="metanorma">[1]</docidentifier>
916
+ </bibitem>
917
+ <bibitem id="ref2" type="standard" hidden="true">
918
+ <title format="text/plain">Cereals or cereal products</title>
919
+ <docidentifier type="metanorma">[2]</docidentifier>
920
+ </bibitem>
921
+ <bibitem id="ref3" type="standard">
922
+ <title format="text/plain">Cereals or cereal products</title>
923
+ <docidentifier type="metanorma">[3]</docidentifier>
924
+ </bibitem>
925
+ </references></bibliography></iso-standard>
926
+ INPUT
927
+ presxml = <<~PRESXML
928
+ <bibliography>
929
+ <references id='_normative_references' obligation='informative' normative='false' displayorder='1'>
930
+ <title depth='1'>Bibliography</title>
931
+ <bibitem id='ref1' type='standard'>
932
+ <title format='text/plain'>Cereals or cereal products</title>
933
+ <docidentifier type='metanorma'>[1]</docidentifier>
934
+ </bibitem>
935
+ <bibitem id='ref2' type='standard' hidden='true'>
936
+ <title format='text/plain'>Cereals or cereal products</title>
937
+ <docidentifier type='metanorma'>[2]</docidentifier>
938
+ </bibitem>
939
+ <bibitem id='ref3' type='standard'>
940
+ <title format='text/plain'>Cereals or cereal products</title>
941
+ <docidentifier type='metanorma'>[3]</docidentifier>
942
+ </bibitem>
943
+ </references>
944
+ </bibliography>
945
+ PRESXML
946
+ expect(xmlpp(Nokogiri::XML(
947
+ IsoDoc::PresentationXMLConvert.new({})
948
+ .convert("test", input, true),
949
+ ).at("//xmlns:bibliography").to_xml))
950
+ .to be_equivalent_to xmlpp(presxml)
951
+ end
952
+
953
+ it "enforces consistent references numbering with hidden items: metanorma-ordinal identifiers" do
954
+ input = <<~INPUT
955
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
956
+ <bibdata>
957
+ <language>en</language>
958
+ </bibdata>
959
+ <bibliography><references id="_normative_references" obligation="informative" normative="false"><title>Bibliography</title>
960
+ <bibitem id="ref1" type="standard">
961
+ <title format="text/plain">Cereals or cereal products</title>
962
+ <docidentifier>ABC</docidentifier>
963
+ </bibitem>
964
+ <bibitem id="ref2" type="standard" hidden="true">
965
+ <title format="text/plain">Cereals or cereal products</title>
966
+ <docidentifier>ABD</docidentifier>
967
+ </bibitem>
968
+ <bibitem id="ref3" type="standard">
969
+ <title format="text/plain">Cereals or cereal products</title>
970
+ <docidentifier>ABE</docidentifier>
971
+ </bibitem>
972
+ </references></bibliography></iso-standard>
973
+ INPUT
974
+ presxml = <<~PRESXML
975
+ <bibliography>
976
+ <references id='_normative_references' obligation='informative' normative='false' displayorder='1'>
977
+ <title depth='1'>Bibliography</title>
978
+ <bibitem id='ref1' type='standard'>
979
+ <title format='text/plain'>Cereals or cereal products</title>
980
+ <docidentifier type='metanorma-ordinal'>[1]</docidentifier>
981
+ <docidentifier>ABC</docidentifier>
982
+ </bibitem>
983
+ <bibitem id='ref2' type='standard' hidden='true'>
984
+ <title format='text/plain'>Cereals or cereal products</title>
985
+ <docidentifier>ABD</docidentifier>
986
+ </bibitem>
987
+ <bibitem id='ref3' type='standard'>
988
+ <title format='text/plain'>Cereals or cereal products</title>
989
+ <docidentifier type='metanorma-ordinal'>[2]</docidentifier>
990
+ <docidentifier>ABE</docidentifier>
991
+ </bibitem>
992
+ </references>
993
+ </bibliography>
994
+ PRESXML
995
+ expect(xmlpp(Nokogiri::XML(
996
+ IsoDoc::PresentationXMLConvert.new({})
997
+ .convert("test", input, true),
998
+ ).at("//xmlns:bibliography").to_xml))
999
+ .to be_equivalent_to xmlpp(presxml)
1000
+ end
905
1001
  end
@@ -262,22 +262,22 @@ RSpec.describe IsoDoc do
262
262
  </iso-standard>
263
263
  INPUT
264
264
  output = <<~OUTPUT
265
- <foreword id='fwd' displayorder="1">
266
- <p>
267
- <xref target='N1'>Figure 1</xref>
268
- <xref target='N2'>Figure (??)</xref>
269
- <xref target='N'>Figure 2</xref>
270
- <xref target='note1'>Figure 3</xref>
271
- <xref target='note3'>Figure 4</xref>
272
- <xref target='note4'>Figure 5</xref>
273
- <xref target='note2'>Figure 6</xref>
274
- <xref target='note51'>[note51]</xref>
275
- <xref target='AN'>Figure A.1</xref>
276
- <xref target='Anote1'>Figure (??)</xref>
277
- <xref target='Anote2'>Figure A.2</xref>
278
- <xref target='Anote3'>Figure A.3</xref>
279
- </p>
280
- </foreword>
265
+ <foreword id='fwd' displayorder="1">
266
+ <p>
267
+ <xref target='N1'>Figure 1</xref>
268
+ <xref target='N2'>Figure (??)</xref>
269
+ <xref target='N'>Figure 2</xref>
270
+ <xref target='note1'>Figure 3</xref>
271
+ <xref target='note3'>Figure 4</xref>
272
+ <xref target='note4'>Figure 5</xref>
273
+ <xref target='note2'>Figure 6</xref>
274
+ <xref target='note51'>[note51]</xref>
275
+ <xref target='AN'>Figure A.1</xref>
276
+ <xref target='Anote1'>Figure (??)</xref>
277
+ <xref target='Anote2'>Figure A.2</xref>
278
+ <xref target='Anote3'>Figure A.3</xref>
279
+ </p>
280
+ </foreword>
281
281
  OUTPUT
282
282
  expect(xmlpp(Nokogiri.XML(IsoDoc::PresentationXMLConvert.new({})
283
283
  .convert("test", input, true))
@@ -824,20 +824,20 @@ RSpec.describe IsoDoc do
824
824
  </iso-standard>
825
825
  INPUT
826
826
  output = <<~OUTPUT
827
- <foreword displayorder='1'>
828
- <p>
829
- <xref target='N1'>Clause 1, Permission 1</xref>
830
- <xref target='N2'>Clause 1, Permission 1-1</xref>
831
- <xref target='N'>Clause 1, Permission 1-1-1</xref>
832
- <xref target='Q1'>Clause 1, Requirement 1-1</xref>
833
- <xref target='R1'>Clause 1, Recommendation 1-1</xref>
834
- <xref target='AN1'>Permission A.1</xref>
835
- <xref target='AN2'>Permission A.1-1</xref>
836
- <xref target='AN'>Permission A.1-1-1</xref>
837
- <xref target='AQ1'>Requirement A.1-1</xref>
838
- <xref target='AR1'>Recommendation A.1-1</xref>
839
- </p>
840
- </foreword>
827
+ <foreword displayorder='1'>
828
+ <p>
829
+ <xref target='N1'>Clause 1, Permission 1</xref>
830
+ <xref target='N2'>Clause 1, Permission 1-1</xref>
831
+ <xref target='N'>Clause 1, Permission 1-1-1</xref>
832
+ <xref target='Q1'>Clause 1, Requirement 1-1</xref>
833
+ <xref target='R1'>Clause 1, Recommendation 1-1</xref>
834
+ <xref target='AN1'>Permission A.1</xref>
835
+ <xref target='AN2'>Permission A.1-1</xref>
836
+ <xref target='AN'>Permission A.1-1-1</xref>
837
+ <xref target='AQ1'>Requirement A.1-1</xref>
838
+ <xref target='AR1'>Recommendation A.1-1</xref>
839
+ </p>
840
+ </foreword>
841
841
  OUTPUT
842
842
  expect(xmlpp(Nokogiri.XML(IsoDoc::PresentationXMLConvert.new({})
843
843
  .convert("test", input, true))
@@ -966,18 +966,18 @@ RSpec.describe IsoDoc do
966
966
  </iso-standard>
967
967
  INPUT
968
968
  output = <<~OUTPUT
969
- <foreword displayorder='1'>
970
- <p>
971
- <xref target='N1'>Table 1</xref>
972
- <xref target='N2'>Table (??)</xref>
973
- <xref target='N'>Table 2</xref>
974
- <xref target='note1'>Table 3</xref>
975
- <xref target='note2'>Table 4</xref>
976
- <xref target='AN'>Table A.1</xref>
977
- <xref target='Anote1'>Table (??)</xref>
978
- <xref target='Anote2'>Table A.2</xref>
979
- </p>
980
- </foreword>
969
+ <foreword displayorder='1'>
970
+ <p>
971
+ <xref target='N1'>Table 1</xref>
972
+ <xref target='N2'>Table (??)</xref>
973
+ <xref target='N'>Table 2</xref>
974
+ <xref target='note1'>Table 3</xref>
975
+ <xref target='note2'>Table 4</xref>
976
+ <xref target='AN'>Table A.1</xref>
977
+ <xref target='Anote1'>Table (??)</xref>
978
+ <xref target='Anote2'>Table A.2</xref>
979
+ </p>
980
+ </foreword>
981
981
  OUTPUT
982
982
  expect(xmlpp(Nokogiri.XML(IsoDoc::PresentationXMLConvert.new({})
983
983
  .convert("test", input, true))
@@ -1061,13 +1061,13 @@ RSpec.describe IsoDoc do
1061
1061
  </iso-standard>
1062
1062
  INPUT
1063
1063
  output = <<~OUTPUT
1064
- <foreword displayorder='1'>
1065
- <p>
1066
- <xref target='note1'>Clause 2.1, Note 1</xref>
1067
- <xref target='note2'>Clause 2.1.1, Note 1</xref>
1068
- <xref target='note3'>Clause 2.1.1, Note 2</xref>
1069
- </p>
1070
- </foreword>
1064
+ <foreword displayorder='1'>
1065
+ <p>
1066
+ <xref target='note1'>Clause 2.1, Note 1</xref>
1067
+ <xref target='note2'>Clause 2.1.1, Note 1</xref>
1068
+ <xref target='note3'>Clause 2.1.1, Note 2</xref>
1069
+ </p>
1070
+ </foreword>
1071
1071
  OUTPUT
1072
1072
  expect(xmlpp(Nokogiri.XML(IsoDoc::PresentationXMLConvert.new({})
1073
1073
  .convert("test", input, true))
@@ -1151,13 +1151,13 @@ RSpec.describe IsoDoc do
1151
1151
  </iso-standard>
1152
1152
  INPUT
1153
1153
  output = <<~OUTPUT
1154
- <foreword displayorder='1'>
1155
- <p>
1156
- <xref target='note1'>Clause 2.1, Example</xref>
1157
- <xref target='note2'>Clause 2.1.1, Example 1</xref>
1158
- <xref target='note3'>Clause 2.1.1, Example 2</xref>
1159
- </p>
1160
- </foreword>
1154
+ <foreword displayorder='1'>
1155
+ <p>
1156
+ <xref target='note1'>Clause 2.1, Example</xref>
1157
+ <xref target='note2'>Clause 2.1.1, Example 1</xref>
1158
+ <xref target='note3'>Clause 2.1.1, Example 2</xref>
1159
+ </p>
1160
+ </foreword>
1161
1161
  OUTPUT
1162
1162
  expect(xmlpp(Nokogiri.XML(IsoDoc::PresentationXMLConvert.new({})
1163
1163
  .convert("test", input, true))
@@ -1255,31 +1255,31 @@ RSpec.describe IsoDoc do
1255
1255
  </iso-standard>
1256
1256
  INPUT
1257
1257
  output = <<~OUTPUT
1258
- <foreword obligation='informative' displayorder='1'>
1259
- <title>Foreword</title>
1260
- <p id='A'>
1261
- This is a preamble
1262
- <xref target='C'>Introduction Subsection</xref>
1263
- <xref target='C1'>Introduction, 2</xref>
1264
- <xref target='D'>Clause 1</xref>
1265
- <xref target='H'>Clause 3</xref>
1266
- <xref target='I'>Clause 3.1</xref>
1267
- <xref target='J'>Clause 3.1.1</xref>
1268
- <xref target='K'>Clause 3.2</xref>
1269
- <xref target='L'>Clause 4</xref>
1270
- <xref target='M'>Clause 5</xref>
1271
- <xref target='N'>Clause 5.1</xref>
1272
- <xref target='O'>Clause 5.2</xref>
1273
- <xref target='P'>Annex A</xref>
1274
- <xref target='Q'>Annex A.1</xref>
1275
- <xref target='Q1'>Annex A.1.1</xref>
1276
- <xref target='QQ'>Annex B</xref>
1277
- <xref target='QQ1'>Annex B</xref>
1278
- <xref target='QQ2'>Annex B.1</xref>
1279
- <xref target='R'>Clause 2</xref>
1280
- <xref target='S'>Bibliography</xref>
1281
- </p>
1282
- </foreword>
1258
+ <foreword obligation='informative' displayorder='1'>
1259
+ <title>Foreword</title>
1260
+ <p id='A'>
1261
+ This is a preamble
1262
+ <xref target='C'>Introduction Subsection</xref>
1263
+ <xref target='C1'>Introduction, 2</xref>
1264
+ <xref target='D'>Clause 1</xref>
1265
+ <xref target='H'>Clause 3</xref>
1266
+ <xref target='I'>Clause 3.1</xref>
1267
+ <xref target='J'>Clause 3.1.1</xref>
1268
+ <xref target='K'>Clause 3.2</xref>
1269
+ <xref target='L'>Clause 4</xref>
1270
+ <xref target='M'>Clause 5</xref>
1271
+ <xref target='N'>Clause 5.1</xref>
1272
+ <xref target='O'>Clause 5.2</xref>
1273
+ <xref target='P'>Annex A</xref>
1274
+ <xref target='Q'>Annex A.1</xref>
1275
+ <xref target='Q1'>Annex A.1.1</xref>
1276
+ <xref target='QQ'>Annex B</xref>
1277
+ <xref target='QQ1'>Annex B</xref>
1278
+ <xref target='QQ2'>Annex B.1</xref>
1279
+ <xref target='R'>Clause 2</xref>
1280
+ <xref target='S'>Bibliography</xref>
1281
+ </p>
1282
+ </foreword>
1283
1283
  OUTPUT
1284
1284
  expect(xmlpp(Nokogiri.XML(IsoDoc::PresentationXMLConvert.new({})
1285
1285
  .convert("test", input, true))
@@ -1720,31 +1720,31 @@ RSpec.describe IsoDoc do
1720
1720
  </iso-standard>
1721
1721
  INPUT
1722
1722
  output = <<~OUTPUT
1723
- <foreword displayorder='1'>
1724
- <p>
1725
- <xref target='N1'>
1726
- Introduction, Definition List:
1727
- <stem type='MathML'>
1728
- <math xmlns='http://www.w3.org/1998/Math/MathML'>
1729
- <msub>
1730
- <mrow>
1731
- <mover accent='true'>
1732
- <mrow>
1733
- <mi>e</mi>
1734
- </mrow>
1735
- <mo>^</mo>
1736
- </mover>
1737
- </mrow>
1738
- <mrow>
1739
- <mi>r</mi>
1740
- </mrow>
1741
- </msub>
1742
- </math>
1743
- <!-- (hat e)_((r)) -->
1744
- </stem>
1745
- </xref>
1746
- </p>
1747
- </foreword>
1723
+ <foreword displayorder='1'>
1724
+ <p>
1725
+ <xref target='N1'>
1726
+ Introduction, Definition List:
1727
+ <stem type='MathML'>
1728
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
1729
+ <msub>
1730
+ <mrow>
1731
+ <mover accent='true'>
1732
+ <mrow>
1733
+ <mi>e</mi>
1734
+ </mrow>
1735
+ <mo>^</mo>
1736
+ </mover>
1737
+ </mrow>
1738
+ <mrow>
1739
+ <mi>r</mi>
1740
+ </mrow>
1741
+ </msub>
1742
+ </math>
1743
+ <!-- (hat e)_((r)) -->
1744
+ </stem>
1745
+ </xref>
1746
+ </p>
1747
+ </foreword>
1748
1748
  OUTPUT
1749
1749
  expect(xmlpp(Nokogiri::XML(IsoDoc::PresentationXMLConvert.new({})
1750
1750
  .convert("test", input, true))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isodoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.7
4
+ version: 2.0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-04 00:00:00.000000000 Z
11
+ date: 2022-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciimath
@@ -84,16 +84,16 @@ dependencies:
84
84
  name: emf2svg
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - "<="
88
88
  - !ruby/object:Gem::Version
89
- version: '1'
89
+ version: '1.3'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - "<="
95
95
  - !ruby/object:Gem::Version
96
- version: '1'
96
+ version: '1.3'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: mathml2asciimath
99
99
  requirement: !ruby/object:Gem::Requirement