isodoc 1.7.4 → 1.7.5

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: 9ddab8465c1411d1596aa170ddda0affb869a0989e4fb0351d2b68c4a02e4a07
4
- data.tar.gz: 0aaecaa60940f2177781ca3b51610c2be9f0ac0fef3e8f01227b9afba9330571
3
+ metadata.gz: b42d786cf8fa0f78ac01afba8de3e886b35eddd191551b6ce20ec680d7441d39
4
+ data.tar.gz: 5db56071fb06162e738b7eff5c5726bf0eae2acc80dbcbfaf1c589ba04729a55
5
5
  SHA512:
6
- metadata.gz: ab482ce07d9ff45b532e3ffa83f98334171e75d5c91eded8c81070b2065690ee2cd1b246fe63ce55a61e04a3fe11fd259cdf1e800885a1151003add5fca1e41b
7
- data.tar.gz: 77df20df67c7adb582dbbfb4a69ec8198d5d811ebe490d08bd023a4e3261083f64da759ca2d1fa231cb3dba3e7b254d7a1331a3e6b3a085ed9586fc1a81b0778
6
+ metadata.gz: 546f673176c4c6757567e43c3221c9e019d7f88f515636e9287e3e8016625a0741277b02d4b3de02cb09e301a76ac39dd8a7b7a62aa90a272c94b9f93529e84f
7
+ data.tar.gz: 6f1db97d1acb6c413bc84265e6e9182b46a645509780457074584d4d37bf1f958e2220eac71958f0167438ed99da7ff12029a1beeda010f23229c47ec5976b50
data/isodoc.gemspec CHANGED
@@ -40,6 +40,7 @@ Gem::Specification.new do |spec|
40
40
  spec.add_dependency "twitter_cldr", ">= 6.6.0"
41
41
  spec.add_dependency "uuidtools"
42
42
  spec.add_dependency "mathml2asciimath"
43
+ spec.add_dependency "metanorma-utils"
43
44
 
44
45
  spec.add_development_dependency "byebug", "~> 9.1"
45
46
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
@@ -2,10 +2,10 @@ require "base64"
2
2
 
3
3
  module IsoDoc
4
4
  class PresentationXMLConvert < ::IsoDoc::Convert
5
- def lower2cap(s)
6
- return s if /^[[:upper:]][[:upper:]]/.match?(s)
5
+ def lower2cap(text)
6
+ return text if /^[[:upper:]][[:upper:]]/.match?(text)
7
7
 
8
- s.capitalize
8
+ text.capitalize
9
9
  end
10
10
 
11
11
  def figure(docxml)
@@ -13,8 +13,7 @@ module IsoDoc
13
13
  docxml.xpath(ns("//figure")).each { |f| figure1(f) }
14
14
  docxml.xpath(ns("//svgmap")).each do |s|
15
15
  if f = s.at(ns("./figure")) then s.replace(f)
16
- else
17
- s.remove
16
+ else s.remove
18
17
  end
19
18
  end
20
19
  end
@@ -30,26 +29,28 @@ module IsoDoc
30
29
  elem.replace(x)
31
30
  end
32
31
 
33
- def figure1(f)
34
- return sourcecode1(f) if f["class"] == "pseudocode" || f["type"] == "pseudocode"
35
- return if labelled_ancestor(f) && f.ancestors("figure").empty?
36
- return if f.at(ns("./figure")) and !f.at(ns("./name"))
32
+ def figure1(elem)
33
+ return sourcecode1(elem) if elem["class"] == "pseudocode" ||
34
+ elem["type"] == "pseudocode"
35
+ return if labelled_ancestor(elem) && elem.ancestors("figure").empty? ||
36
+ elem.at(ns("./figure")) && !elem.at(ns("./name"))
37
37
 
38
- lbl = @xrefs.anchor(f['id'], :label, false) or return
39
- prefix_name(f, "&nbsp;&mdash; ",
38
+ lbl = @xrefs.anchor(elem["id"], :label, false) or return
39
+ prefix_name(elem, "&nbsp;&mdash; ",
40
40
  l10n("#{lower2cap @i18n.figure} #{lbl}"), "name")
41
41
  end
42
42
 
43
- def prefix_name(f, delim, number, elem)
43
+ def prefix_name(node, delim, number, elem)
44
44
  return if number.nil? || number.empty?
45
45
 
46
- unless name = f.at(ns("./#{elem}"))
47
- f.children.empty? and f.add_child("<#{elem}></#{elem}>") or
48
- f.children.first.previous = "<#{elem}></#{elem}>"
49
- name = f.children.first
46
+ unless name = node.at(ns("./#{elem}"))
47
+ node.children.empty? and node.add_child("<#{elem}></#{elem}>") or
48
+ node.children.first.previous = "<#{elem}></#{elem}>"
49
+ name = node.children.first
50
+ end
51
+ if name.children.empty? then name.add_child(number)
52
+ else (name.children.first.previous = "#{number}#{delim}")
50
53
  end
51
- name.children.empty? ? name.add_child(number) :
52
- ( name.children.first.previous = "#{number}#{delim}" )
53
54
  end
54
55
 
55
56
  def sourcecode(docxml)
@@ -58,12 +59,13 @@ module IsoDoc
58
59
  end
59
60
  end
60
61
 
61
- def sourcecode1(f)
62
- return if labelled_ancestor(f)
63
- return unless f.ancestors("example").empty?
62
+ def sourcecode1(elem)
63
+ return if labelled_ancestor(elem)
64
+ return unless elem.ancestors("example").empty?
64
65
 
65
- lbl = @xrefs.anchor(f['id'], :label, false) or return
66
- prefix_name(f, "&nbsp;&mdash; ", l10n("#{lower2cap @i18n.figure} #{lbl}"), "name")
66
+ lbl = @xrefs.anchor(elem["id"], :label, false) or return
67
+ prefix_name(elem, "&nbsp;&mdash; ",
68
+ l10n("#{lower2cap @i18n.figure} #{lbl}"), "name")
67
69
  end
68
70
 
69
71
  def formula(docxml)
@@ -73,9 +75,9 @@ module IsoDoc
73
75
  end
74
76
 
75
77
  # introduce name element
76
- def formula1(f)
77
- lbl = @xrefs.anchor(f['id'], :label, false)
78
- prefix_name(f, "", lbl, "name")
78
+ def formula1(elem)
79
+ lbl = @xrefs.anchor(elem["id"], :label, false)
80
+ prefix_name(elem, "", lbl, "name")
79
81
  end
80
82
 
81
83
  def example(docxml)
@@ -90,11 +92,14 @@ module IsoDoc
90
92
  end
91
93
  end
92
94
 
93
- def example1(f)
94
- n = @xrefs.get[f["id"]]
95
- lbl = (n.nil? || n[:label].nil? || n[:label].empty?) ? @i18n.example:
96
- l10n("#{@i18n.example} #{n[:label]}")
97
- prefix_name(f, "&nbsp;&mdash; ", lbl, "name")
95
+ def example1(elem)
96
+ n = @xrefs.get[elem["id"]]
97
+ lbl = if n.nil? || n[:label].nil? || n[:label].empty?
98
+ @i18n.example
99
+ else
100
+ l10n("#{@i18n.example} #{n[:label]}")
101
+ end
102
+ prefix_name(elem, "&nbsp;&mdash; ", lbl, "name")
98
103
  end
99
104
 
100
105
  def note(docxml)
@@ -104,13 +109,16 @@ module IsoDoc
104
109
  end
105
110
 
106
111
  # introduce name element
107
- def note1(f)
108
- return if f.parent.name == "bibitem"
112
+ def note1(elem)
113
+ return if elem.parent.name == "bibitem"
109
114
 
110
- n = @xrefs.get[f["id"]]
111
- lbl = (@i18n.note if n.nil? || n[:label].nil? || n[:label].empty?) ?
112
- @i18n.note: l10n("#{@i18n.note} #{n[:label]}")
113
- prefix_name(f, "", lbl, "name")
115
+ n = @xrefs.get[elem["id"]]
116
+ lbl = if n.nil? || n[:label].nil? || n[:label].empty?
117
+ @i18n.note
118
+ else
119
+ l10n("#{@i18n.note} #{n[:label]}")
120
+ end
121
+ prefix_name(elem, "", lbl, "name")
114
122
  end
115
123
 
116
124
  def termnote(docxml)
@@ -120,9 +128,27 @@ module IsoDoc
120
128
  end
121
129
 
122
130
  # introduce name element
123
- def termnote1(f)
124
- lbl = l10n(@xrefs.anchor(f["id"], :label) || "???")
125
- prefix_name(f, "", lower2cap(lbl), "name")
131
+ def termnote1(elem)
132
+ lbl = l10n(@xrefs.anchor(elem["id"], :label) || "???")
133
+ prefix_name(elem, "", lower2cap(lbl), "name")
134
+ end
135
+
136
+ def termdefinition(docxml)
137
+ docxml.xpath(ns("//term[definition]")).each do |f|
138
+ termdefinition1(f)
139
+ end
140
+ end
141
+
142
+ def termdefinition1(elem)
143
+ return unless elem.xpath(ns("./definition")).size > 1
144
+
145
+ d = elem.at(ns("./definition"))
146
+ d = d.replace("<ol><li>#{d.children.to_xml}</li></ol>").first
147
+ elem.xpath(ns("./definition")).each do |f|
148
+ f = f.replace("<li>#{f.children.to_xml}</li>").first
149
+ d << f
150
+ end
151
+ d.wrap("<definition></definition>")
126
152
  end
127
153
 
128
154
  def recommendation(docxml)
@@ -144,10 +170,10 @@ module IsoDoc
144
170
  end
145
171
 
146
172
  # introduce name element
147
- def recommendation1(f, type)
148
- n = @xrefs.anchor(f["id"], :label, false)
173
+ def recommendation1(elem, type)
174
+ n = @xrefs.anchor(elem["id"], :label, false)
149
175
  lbl = (n.nil? ? type : l10n("#{type} #{n}"))
150
- prefix_name(f, "", lbl, "name")
176
+ prefix_name(elem, "", lbl, "name")
151
177
  end
152
178
 
153
179
  def table(docxml)
@@ -156,12 +182,13 @@ module IsoDoc
156
182
  end
157
183
  end
158
184
 
159
- def table1(f)
160
- return if labelled_ancestor(f)
161
- return if f["unnumbered"] && !f.at(ns("./name"))
185
+ def table1(elem)
186
+ return if labelled_ancestor(elem)
187
+ return if elem["unnumbered"] && !elem.at(ns("./name"))
162
188
 
163
- n = @xrefs.anchor(f["id"], :label, false)
164
- prefix_name(f, "&nbsp;&mdash; ", l10n("#{lower2cap @i18n.table} #{n}"), "name")
189
+ n = @xrefs.anchor(elem["id"], :label, false)
190
+ prefix_name(elem, "&nbsp;&mdash; ", l10n("#{lower2cap @i18n.table} #{n}"),
191
+ "name")
165
192
  end
166
193
 
167
194
  # we use this to eliminate the semantic amend blocks from rendering
@@ -171,11 +198,11 @@ module IsoDoc
171
198
  end
172
199
  end
173
200
 
174
- def amend1(f)
175
- f.xpath(ns("./autonumber")).each(&:remove)
176
- f.xpath(ns("./newcontent")).each { |a| a.name = "quote" }
177
- f.xpath(ns("./description")).each { |a| a.replace(a.children) }
178
- f.replace(f.children)
201
+ def amend1(elem)
202
+ elem.xpath(ns("./autonumber")).each(&:remove)
203
+ elem.xpath(ns("./newcontent")).each { |a| a.name = "quote" }
204
+ elem.xpath(ns("./description")).each { |a| a.replace(a.children) }
205
+ elem.replace(elem.children)
179
206
  end
180
207
  end
181
208
  end
@@ -1,3 +1,5 @@
1
+ require "metanorma-utils"
2
+
1
3
  module IsoDoc
2
4
  class PresentationXMLConvert < ::IsoDoc::Convert
3
5
  def prefix_container(container, linkend, _target)
@@ -130,7 +132,7 @@ module IsoDoc
130
132
  loc = @i18n.locality[type] || type.sub(/^locality:/, "")
131
133
  loc = case node["case"]
132
134
  when "lowercase" then loc.downcase
133
- else loc.capitalize
135
+ else Metanorma::Utils.strict_capitalize_first(loc)
134
136
  end
135
137
  " #{loc}"
136
138
  end
@@ -161,32 +163,62 @@ module IsoDoc
161
163
 
162
164
  def concept1(node)
163
165
  xref = node&.at(ns("./xref/@target"))&.text or
164
- return concept_render(node, node["ital"] || "true",
165
- node["ref"] || "true")
166
+ return concept_render(node, ital: node["ital"] || "true",
167
+ ref: node["ref"] || "true",
168
+ linkref: node["linkref"] || "true",
169
+ linkmention: node["linkmention"] || "false")
166
170
  if node.at(ns("//definitions//dt[@id = '#{xref}']"))
167
- concept_render(node, node["ital"] || "false", node["ref"] || "false")
168
- else concept_render(node, node["ital"] || "true", node["ref"] || "true")
171
+ concept_render(node, ital: node["ital"] || "false",
172
+ ref: node["ref"] || "false",
173
+ linkref: node["linkref"] || "true",
174
+ linkmention: node["linkmention"] || "false")
175
+ else concept_render(node, ital: node["ital"] || "true",
176
+ ref: node["ref"] || "true",
177
+ linkref: node["linkref"] || "true",
178
+ linkmention: node["linkmention"] || "false")
169
179
  end
170
180
  end
171
181
 
172
- def concept_render(node, ital, ref)
182
+ def concept_render(node, opts)
173
183
  node&.at(ns("./refterm"))&.remove
174
184
  r = node.at(ns("./renderterm"))
175
- r&.next = " " if node.at(ns("./xref | ./eref | ./termref")) && ref != "false"
176
- if ital == "true" then r&.name = "em"
177
- else r&.replace(r&.children)
185
+ ref = node.at(ns("./xref | ./eref | ./termref"))
186
+ ref && opts[:ref] != "false" and r&.next = " "
187
+ opts[:ital] == "true" and r&.name = "em"
188
+ if opts[:linkmention] == "true" && !r.nil? && !ref.nil?
189
+ ref2 = ref.clone
190
+ r2 = r.clone
191
+ r.replace(ref2).children = r2
192
+ end
193
+ concept1_ref(node, ref, opts)
194
+ if opts[:ital] == "false"
195
+ r = node.at(ns(".//renderterm"))
196
+ r&.replace(r&.children)
178
197
  end
179
- concept1_ref(node, ref)
180
198
  node.replace(node.children)
181
199
  end
182
200
 
183
- def concept1_ref(node, ref)
184
- r = node.at(ns("./xref | ./eref | ./termref")) or return
185
- return r.remove if ref == "false"
201
+ def concept1_ref(_node, ref, opts)
202
+ ref.nil? and return
203
+ return ref.remove if opts[:ref] == "false"
204
+
205
+ r = concept1_ref_content(ref)
206
+ ref = r.at("./descendant-or-self::xmlns:xref | "\
207
+ "./descendant-or-self::xmlns:eref | "\
208
+ "./descendant-or-self::xmlns:termref")
209
+ %w(xref eref).include? ref&.name and get_linkend(ref)
210
+ if opts[:linkref] == "false" && %w(xref eref).include?(ref&.name)
211
+ ref.replace(ref.children)
212
+ end
213
+ end
186
214
 
187
- if non_locality_elems(r).select { |c| !c.text? || /\S/.match(c) }.empty?
188
- r.replace(@i18n.term_defined_in.sub(/%/, r.to_xml))
189
- else r.replace("[#{r.to_xml}]")
215
+ def concept1_ref_content(ref)
216
+ if non_locality_elems(ref).select do |c|
217
+ !c.text? || /\S/.match(c)
218
+ end.empty?
219
+ ref.replace(@i18n.term_defined_in.sub(/%/,
220
+ ref.to_xml))
221
+ else ref.replace("[#{ref.to_xml}]")
190
222
  end
191
223
  end
192
224
 
@@ -49,6 +49,7 @@ module IsoDoc
49
49
  termexample docxml
50
50
  note docxml
51
51
  termnote docxml
52
+ termdefinition docxml
52
53
  permission docxml
53
54
  requirement docxml
54
55
  recommendation docxml
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "1.7.4".freeze
2
+ VERSION = "1.7.5".freeze
3
3
  end
@@ -209,8 +209,7 @@ RSpec.describe IsoDoc do
209
209
  <renderterm>word</renderterm>
210
210
  <termref base='IEV' target='135-13-13'>The IEV database</termref>
211
211
  </concept></li>
212
- <li><concept><refterm>term</refterm>
213
- <renderterm>word</renderterm>
212
+ <li><concept>
214
213
  <strong>error!</strong>
215
214
  </concept>
216
215
  </li>
@@ -295,7 +294,7 @@ RSpec.describe IsoDoc do
295
294
  <li>
296
295
  <em>word</em> [<termref base="IEV" target="135-13-13">The IEV database</termref>]
297
296
  </li>
298
- <li> <em>word</em> <strong>error!</strong> </li>
297
+ <li> <strong>error!</strong> </li>
299
298
  </ul>
300
299
  </p>
301
300
  </foreword></preface>
@@ -380,7 +379,7 @@ RSpec.describe IsoDoc do
380
379
  <i>word</i>
381
380
  [The IEV database]
382
381
  </li>
383
- <li> <i>word</i> <b>error!</b> </li>
382
+ <li> <b>error!</b> </li>
384
383
  </ul>
385
384
  </p>
386
385
  </div>
@@ -418,13 +417,22 @@ RSpec.describe IsoDoc do
418
417
  <preface><foreword>
419
418
  <p>
420
419
  <ul>
421
- <li>
422
- <concept ital="true"><refterm>term</refterm><renderterm>term</renderterm><xref target='clause1'/></concept>,</li>
423
- <li><concept ref="true"><refterm>term</refterm><renderterm>term</renderterm><xref target='clause1'/></concept>,</li>
420
+ <li><concept ital="true"><refterm>term</refterm><renderterm>term</renderterm><xref target='clause1'/></concept>,</li>
421
+ <li><concept ref="true"><refterm>term</refterm><renderterm>term</renderterm><xref target='clause1'/></concept>,</li>
424
422
  <li><concept ital="true" ref="true"><refterm>term</refterm><renderterm>term</renderterm><xref target='clause1'/></concept>,</li>
425
- <li><concept ital="false"><refterm>term</refterm><renderterm>term</renderterm><xref target='clause1'/></concept>,</li>
426
- <li><concept ref="false"><refterm>term</refterm><renderterm>term</renderterm><xref target='clause1'/></concept>,</li>
423
+ <li><concept ital="false"><refterm>term</refterm><renderterm>term</renderterm><xref target='clause1'/></concept>,</li>
424
+ <li><concept ref="false"><refterm>term</refterm><renderterm>term</renderterm><xref target='clause1'/></concept>,</li>
427
425
  <li><concept ital="false" ref="false"><refterm>term</refterm><renderterm>term</renderterm><xref target='clause1'/></concept>,</li>
426
+ <li><concept ital="true" ref="true" linkmention="true" linkref="true"><refterm>term</refterm><renderterm>term</renderterm><xref target='clause1'/></concept>,</li>
427
+ <li><concept ital="true" ref="true" linkmention="true" linkref="false"><refterm>term</refterm><renderterm>term</renderterm><xref target='clause1'/></concept>,</li>
428
+ <li><concept ital="true" ref="true" linkmention="false" linkref="true"><refterm>term</refterm><renderterm>term</renderterm><xref target='clause1'/></concept>,</li>
429
+ <li><concept ital="true" ref="true" linkmention="false" linkref="false"><refterm>term</refterm><renderterm>term</renderterm><xref target='clause1'/></concept>,</li>
430
+ <li><concept ital="true" ref="true" linkmention="true" linkref="true"><strong>error!</strong></concept></li>
431
+ <li><concept ital="false" ref="false" linkmention="true">
432
+ <refterm>CV_DiscreteCoverage</refterm>
433
+ <renderterm>CV_DiscreteCoverage</renderterm>
434
+ <xref target="term-cv_discretecoverage"/>
435
+ </concept></li>
428
436
  </ul></p>
429
437
  </foreword></preface>
430
438
  <sections>
@@ -433,88 +441,101 @@ RSpec.describe IsoDoc do
433
441
  </iso-standard>
434
442
  INPUT
435
443
  presxml = <<~OUTPUT
436
- <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
437
- <preface><foreword displayorder="1">
438
- <p>
439
- <ul>
440
- <li>
441
-
442
- <em>term</em>
443
- [term defined in <xref target="clause1">Clause 1</xref>],
444
- </li>
445
- <li>
446
- <em>term</em>
447
- [term defined in <xref target="clause1">Clause 1</xref>],
448
- </li>
449
- <li>
450
- <em>term</em>
451
- [term defined in <xref target="clause1">Clause 1</xref>],
452
- </li>
453
- <li>
454
- term
455
- [term defined in <xref target="clause1">Clause 1</xref>],
456
- </li>
457
- <li>
458
- <em>term</em>,
459
-
460
- </li>
461
- <li>
462
- term,
463
-
464
- </li>
465
- </ul></p>
466
- </foreword></preface>
467
- <sections>
468
- <clause id="clause1" displayorder="2"><title depth="1">1.<tab/>Clause 1</title></clause>
469
- </sections>
444
+ <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
445
+ <preface><foreword displayorder="1">
446
+ <p>
447
+ <ul>
448
+ <li><em>term</em> [term defined in <xref target="clause1">Clause 1</xref>],</li>
449
+ <li><em>term</em> [term defined in <xref target="clause1">Clause 1</xref>],</li>
450
+ <li><em>term</em> [term defined in <xref target="clause1">Clause 1</xref>],</li>
451
+ <li>term [term defined in <xref target="clause1">Clause 1</xref>],</li>
452
+ <li><em>term</em>,</li>
453
+ <li>term,</li>
454
+ <li><xref target="clause1"><em>term</em></xref> [term defined in <xref target="clause1">Clause 1</xref>],</li>
455
+ <li><xref target="clause1"><em>term</em></xref> [term defined in Clause 1],</li>
456
+ <li><em>term</em> [term defined in <xref target="clause1">Clause 1</xref>],</li>
457
+ <li><em>term</em> [term defined in Clause 1],</li>
458
+ <li><strong>error!</strong></li>
459
+ <li><xref target='term-cv_discretecoverage'>CV_DiscreteCoverage</xref></li>
460
+ </ul></p>
461
+ </foreword></preface>
462
+ <sections>
463
+ <clause id="clause1" displayorder="2"><title depth="1">1.<tab/>Clause 1</title></clause>
464
+ </sections>
470
465
  </iso-standard>
471
466
  OUTPUT
472
467
  output = <<~OUTPUT
473
- #{HTML_HDR}
474
- <br/>
475
- <div>
476
- <h1 class='ForewordTitle'>Foreword</h1>
477
- <p>
478
- <ul>
479
- <li>
480
- <i>term</i>
481
- [term defined in
482
- <a href='#clause1'>Clause 1</a>
483
- ],
484
- </li>
485
- <li>
486
- <i>term</i>
487
- [term defined in
488
- <a href='#clause1'>Clause 1</a>
489
- ],
490
- </li>
491
- <li>
492
- <i>term</i>
493
- [term defined in
494
- <a href='#clause1'>Clause 1</a>
495
- ],
496
- </li>
497
- <li>
498
- term [term defined in
499
- <a href='#clause1'>Clause 1</a>
500
- ],
501
- </li>
502
- <li>
503
- <i>term</i>,
504
- </li>
505
- <li>term,</li>
506
- </ul>
507
- </p>
508
- </div>
509
- <p class='zzSTDTitle1'/>
510
- <div id='clause1'>
511
- <h1>1.&#160; Clause 1</h1>
512
- </div>
513
- </div>
514
- </body>
515
- </html>
468
+ #{HTML_HDR}
469
+ <br/>
470
+ <div>
471
+ <h1 class='ForewordTitle'>Foreword</h1>
472
+ <p>
473
+ <ul>
474
+ <li>
475
+ <i>term</i>
476
+ [term defined in
477
+ <a href='#clause1'>Clause 1</a>
478
+ ],
479
+ </li>
480
+ <li>
481
+ <i>term</i>
482
+ [term defined in
483
+ <a href='#clause1'>Clause 1</a>
484
+ ],
485
+ </li>
486
+ <li>
487
+ <i>term</i>
488
+ [term defined in
489
+ <a href='#clause1'>Clause 1</a>
490
+ ],
491
+ </li>
492
+ <li>
493
+ term [term defined in
494
+ <a href='#clause1'>Clause 1</a>
495
+ ],
496
+ </li>
497
+ <li>
498
+ <i>term</i>,
499
+ </li>
500
+ <li>term,</li>
501
+ <li>
502
+ <a href='#clause1'>
503
+ <i>term</i>
504
+ </a>
505
+ [term defined in
506
+ <a href='#clause1'>Clause 1</a>
507
+ ],
508
+ </li>
509
+ <li>
510
+ <a href='#clause1'>
511
+ <i>term</i>
512
+ </a>
513
+ [term defined in Clause 1],
514
+ </li>
515
+ <li>
516
+ <i>term</i>
517
+ [term defined in
518
+ <a href='#clause1'>Clause 1</a>
519
+ ],
520
+ </li>
521
+ <li>
522
+ <i>term</i>
523
+ [term defined in Clause 1],
524
+ </li>
525
+ <li> <b>error!</b> </li>
526
+ <li> <a href='#term-cv_discretecoverage'>CV_DiscreteCoverage</a> </li>
527
+ </ul>
528
+ </p>
529
+ </div>
530
+ <p class='zzSTDTitle1'/>
531
+ <div id='clause1'>
532
+ <h1>1.&#160; Clause 1</h1>
533
+ </div>
534
+ </div>
535
+ </body>
536
+ </html>
516
537
  OUTPUT
517
- expect((IsoDoc::PresentationXMLConvert.new({})
538
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
518
539
  .convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
519
540
  expect(xmlpp(IsoDoc::HtmlConvert.new({})
520
541
  .convert("test", presxml, true))).to be_equivalent_to xmlpp(output)
@@ -1002,6 +1023,7 @@ RSpec.describe IsoDoc do
1002
1023
  <eref type="inline" bibitemid="ISO712"><locality type="table"><referenceFrom>1</referenceFrom></locality>A</eref>
1003
1024
  <eref type="inline" bibitemid="ISO712"><locality type="whole"></locality></eref>
1004
1025
  <eref type="inline" bibitemid="ISO712"><locality type="locality:prelude"><referenceFrom>7</referenceFrom></locality></eref>
1026
+ <eref type="inline" bibitemid="ISO712"><locality type="locality:URI"><referenceFrom>7</referenceFrom></locality></eref>
1005
1027
  <eref type="inline" bibitemid="ISO712" citeas="ISO 712">A</eref>
1006
1028
  <eref type="inline" bibitemid="ISO712"><locality type="anchor"><referenceFrom>1</referenceFrom></locality></eref>
1007
1029
  <eref type="inline" bibitemid="ISO712"><locality type="anchor"><referenceFrom>1</referenceFrom></locality><locality type="clause"><referenceFrom>1</referenceFrom></locality></eref>
@@ -1040,6 +1062,7 @@ RSpec.describe IsoDoc do
1040
1062
  <eref type="inline" bibitemid="ISO712"><locality type="table"><referenceFrom>1</referenceFrom></locality>A</eref>
1041
1063
  <eref type="inline" bibitemid="ISO712"><locality type="whole"/>ISO 712, Whole of text</eref>
1042
1064
  <eref type="inline" bibitemid="ISO712"><locality type="locality:prelude"><referenceFrom>7</referenceFrom></locality>ISO 712, Prelude 7</eref>
1065
+ <eref type="inline" bibitemid="ISO712"><locality type="locality:URI"><referenceFrom>7</referenceFrom></locality>ISO 712, URI 7</eref>
1043
1066
  <eref type="inline" bibitemid="ISO712" citeas="ISO 712">A</eref>
1044
1067
  <eref type="inline" bibitemid="ISO712"><locality type="anchor"><referenceFrom>1</referenceFrom></locality>ISO 712</eref>
1045
1068
  <eref type="inline" bibitemid="ISO712"><locality type="anchor"><referenceFrom>1</referenceFrom></locality><locality type="clause"><referenceFrom>1</referenceFrom></locality>ISO 712, Clause 1</eref>
@@ -1082,6 +1105,7 @@ RSpec.describe IsoDoc do
1082
1105
  <a href="#ISO712">A</a>
1083
1106
  <a href="#ISO712">ISO 712, Whole of text</a>
1084
1107
  <a href="#ISO712">ISO 712, Prelude 7</a>
1108
+ <a href="#ISO712">ISO 712, URI 7</a>
1085
1109
  <a href="#ISO712">A</a>
1086
1110
  <a href='#ISO712'>ISO 712</a>
1087
1111
  <a href='#ISO712'>ISO 712, Clause 1</a>
@@ -1778,4 +1778,129 @@ RSpec.describe IsoDoc do
1778
1778
  expect(xmlpp(IsoDoc::HtmlConvert.new({})
1779
1779
  .convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
1780
1780
  end
1781
+
1782
+ it "processes annexes containing one, or more than one special sections" do
1783
+ input = <<~INPUT
1784
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
1785
+ <annex id='PP' obligation='normative'>
1786
+ <title>Glossary</title>
1787
+ <terms id='PP1' obligation='normative'>
1788
+ <term id='term-glossary'>
1789
+ <preferred>Glossary</preferred>
1790
+ </term>
1791
+ </terms>
1792
+ </annex>
1793
+ <annex id='QQ' obligation='normative'>
1794
+ <title>Glossary</title>
1795
+ <terms id='QQ1' obligation='normative'>
1796
+ <title>Term Collection</title>
1797
+ <term id='term-term-1'>
1798
+ <preferred>Term</preferred>
1799
+ </term>
1800
+ </terms>
1801
+ <terms id='QQ2' obligation='normative'>
1802
+ <title>Term Collection 2</title>
1803
+ <term id='term-term-2'>
1804
+ <preferred>Term</preferred>
1805
+ </term>
1806
+ </terms>
1807
+ </annex>
1808
+ <annex id='RR' obligation='normative'>
1809
+ <title>Glossary</title>
1810
+ <terms id='RR1' obligation='normative'>
1811
+ <title>Term Collection</title>
1812
+ <term id='term-term-3'>
1813
+ <preferred>Term</preferred>
1814
+ </term>
1815
+ </terms>
1816
+ <references id='RR2' obligation='normative'>
1817
+ <title>References</title>
1818
+ </terms>
1819
+ </annex>
1820
+ </iso-standard>
1821
+ INPUT
1822
+ presxml = <<~OUTPUT
1823
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
1824
+ <annex id='PP' obligation='normative' displayorder='1'>
1825
+ <title>
1826
+ <strong>Annex A</strong>
1827
+ <br/>
1828
+ (normative)
1829
+ <br/>
1830
+ <br/>
1831
+ <strong>Glossary</strong>
1832
+ </title>
1833
+ <terms id='PP1' obligation='normative'>
1834
+ <title>A.</title>
1835
+ <term id='term-glossary'>
1836
+ <name>A.1.</name>
1837
+ <preferred>Glossary</preferred>
1838
+ </term>
1839
+ </terms>
1840
+ </annex>
1841
+ <annex id='QQ' obligation='normative' displayorder='2'>
1842
+ <title>
1843
+ <strong>Annex B</strong>
1844
+ <br/>
1845
+ (normative)
1846
+ <br/>
1847
+ <br/>
1848
+ <strong>Glossary</strong>
1849
+ </title>
1850
+ <terms id='QQ1' obligation='normative'>
1851
+ <title depth='2'>
1852
+ B.1.
1853
+ <tab/>
1854
+ Term Collection
1855
+ </title>
1856
+ <term id='term-term-1'>
1857
+ <name>B.1.1.</name>
1858
+ <preferred>Term</preferred>
1859
+ </term>
1860
+ </terms>
1861
+ <terms id='QQ2' obligation='normative'>
1862
+ <title depth='2'>
1863
+ B.2.
1864
+ <tab/>
1865
+ Term Collection 2
1866
+ </title>
1867
+ <term id='term-term-2'>
1868
+ <name>B.2.1.</name>
1869
+ <preferred>Term</preferred>
1870
+ </term>
1871
+ </terms>
1872
+ </annex>
1873
+ <annex id='RR' obligation='normative' displayorder='3'>
1874
+ <title>
1875
+ <strong>Annex C</strong>
1876
+ <br/>
1877
+ (normative)
1878
+ <br/>
1879
+ <br/>
1880
+ <strong>Glossary</strong>
1881
+ </title>
1882
+ <terms id='RR1' obligation='normative'>
1883
+ <title depth='2'>
1884
+ C.1.
1885
+ <tab/>
1886
+ Term Collection
1887
+ </title>
1888
+ <term id='term-term-3'>
1889
+ <name>C.1.1.</name>
1890
+ <preferred>Term</preferred>
1891
+ </term>
1892
+ </terms>
1893
+ <references id='RR2' obligation='normative'>
1894
+ <title depth='2'>
1895
+ C.2.
1896
+ <tab/>
1897
+ References
1898
+ </title>
1899
+ </references>
1900
+ </annex>
1901
+ </iso-standard>
1902
+ OUTPUT
1903
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
1904
+ .convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
1905
+ end
1781
1906
  end
@@ -261,4 +261,120 @@ RSpec.describe IsoDoc do
261
261
  expect(xmlpp(IsoDoc::WordConvert.new({})
262
262
  .convert("test", presxml, true))).to be_equivalent_to xmlpp(word)
263
263
  end
264
+
265
+ it "processes IsoXML term with multiple definitions" do
266
+ input = <<~"INPUT"
267
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
268
+ <sections>
269
+ <terms id="_terms_and_definitions" obligation="normative"><title>Terms and Definitions</title>
270
+ <p>For the purposes of this document, the following terms and definitions apply.</p>
271
+ <term id="paddy1"><preferred>paddy</preferred>
272
+ <domain>rice</domain>
273
+ <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
274
+ <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747e">rice retaining its husk after threshing, mark 2</p>
275
+ <termsource status="modified">
276
+ <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality></origin>
277
+ <modification>
278
+ <p id="_e73a417d-ad39-417d-a4c8-20e4e2529489">The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here</p>
279
+ </modification>
280
+ </termsource>
281
+ </definition>
282
+ <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f892" keep-with-next="true" keep-lines-together="true">
283
+ <p id="_65c9a509-9a89-4b54-a890-274126aeb55c">Foreign seeds, husks, bran, sand, dust.</p>
284
+ <ul>
285
+ <li>A</li>
286
+ </ul>
287
+ </termexample>
288
+ <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f894">
289
+ <ul>
290
+ <li>A</li>
291
+ </ul>
292
+ </termexample>
293
+ <termsource status='identical'>
294
+ <origin citeas=''>
295
+ <termref base='IEV' target='xyz'>t1</termref>
296
+ </origin>
297
+ </termsource>
298
+ <termsource status='modified'>
299
+ <origin citeas=''>
300
+ <termref base='IEV' target='xyz'/>
301
+ </origin>
302
+ <modification>
303
+ <p id='_'>with adjustments</p>
304
+ </modification>
305
+ </termsource>
306
+ </term>
307
+ INPUT
308
+ presxml = <<~PRESXML
309
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
310
+ <sections>
311
+ <terms id='_terms_and_definitions' obligation='normative' displayorder='1'>
312
+ <title depth='1'>
313
+ 1.
314
+ <tab/>
315
+ Terms and Definitions
316
+ </title>
317
+ <p>For the purposes of this document, the following terms and definitions apply.</p>
318
+ <term id='paddy1'>
319
+ <name>1.1.</name>
320
+ <preferred>paddy</preferred>
321
+ <domain>rice</domain>
322
+ <definition>
323
+ <ol>
324
+ <li>
325
+ <p id='_eb29b35e-123e-4d1c-b50b-2714d41e747f'>rice retaining its husk after threshing</p>
326
+ </li>
327
+ <li>
328
+ <p id='_eb29b35e-123e-4d1c-b50b-2714d41e747e'>rice retaining its husk after threshing, mark 2</p>
329
+ <termsource status='modified'>
330
+ <origin bibitemid='ISO7301' type='inline' citeas='ISO 7301:2011'>
331
+ <locality type='clause'>
332
+ <referenceFrom>3.1</referenceFrom>
333
+ </locality>
334
+ ISO 7301:2011, Clause 3.1
335
+ </origin>
336
+ <modification>
337
+ <p id='_e73a417d-ad39-417d-a4c8-20e4e2529489'>
338
+ The term "cargo rice" is shown as deprecated, and Note 1 to
339
+ entry is not included here
340
+ </p>
341
+ </modification>
342
+ </termsource>
343
+ </li>
344
+ </ol>
345
+ </definition>
346
+ <termexample id='_bd57bbf1-f948-4bae-b0ce-73c00431f892' keep-with-next='true' keep-lines-together='true'>
347
+ <name>EXAMPLE 1</name>
348
+ <p id='_65c9a509-9a89-4b54-a890-274126aeb55c'>Foreign seeds, husks, bran, sand, dust.</p>
349
+ <ul>
350
+ <li>A</li>
351
+ </ul>
352
+ </termexample>
353
+ <termexample id='_bd57bbf1-f948-4bae-b0ce-73c00431f894'>
354
+ <name>EXAMPLE 2</name>
355
+ <ul>
356
+ <li>A</li>
357
+ </ul>
358
+ </termexample>
359
+ <termsource status='identical'>
360
+ <origin citeas=''>
361
+ <termref base='IEV' target='xyz'>t1</termref>
362
+ </origin>
363
+ </termsource>
364
+ <termsource status='modified'>
365
+ <origin citeas=''>
366
+ <termref base='IEV' target='xyz'/>
367
+ </origin>
368
+ <modification>
369
+ <p id='_'>with adjustments</p>
370
+ </modification>
371
+ </termsource>
372
+ </term>
373
+ </terms>
374
+ </sections>
375
+ </iso-standard>
376
+ PRESXML
377
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
378
+ .convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
379
+ end
264
380
  end
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: 1.7.4
4
+ version: 1.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-30 00:00:00.000000000 Z
11
+ date: 2021-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciimath
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: metanorma-utils
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: byebug
169
183
  requirement: !ruby/object:Gem::Requirement