isodoc 3.1.7 → 3.1.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a295da0c0143ef7732aca192d4ebc1e9eb7c0b4ec6b515bb00609cd7b9dce1e2
4
- data.tar.gz: 33b46c1df1e837cdd1df7034f434bb7740bdb720d4309a663e51368df5898998
3
+ metadata.gz: 6a8388650d37a65faf83e9279b1d749045fb6a0ad26367a2530eb0ccae120ad8
4
+ data.tar.gz: 518346e1d25294060e5e32d2b6188a7817dd8dc3a54834c1406a5d2285deab97
5
5
  SHA512:
6
- metadata.gz: 12e4328d0d97cec33a1fe8a3afb339f6488e91d410c5cd40ff85ae46e571e8575ef50929d5756bfaa24604cdf1545ffef061c1429a80d1cb7c5af7527ce3be23
7
- data.tar.gz: e55fc19631f6075ca61f459bb5026a435ff6eadc2f604fdd269abebf1fe4153a975fb095061b289371c08ba76d271e868b7fe2a1f3fc0b9a53bd50c5671b2a7f
6
+ metadata.gz: c8db9974c553f9385126d0a67d1b50dcca7b84a9d9df5e2ef8f0923fa2f617efc2300e8e500bf0b29d9dd2a3a73307b5ff20e483e1cffd820b80a718f200716a
7
+ data.tar.gz: 6d9b8daf2cd962bd1fa6ec201aa54fd67f342293e91ea513be06ed2335e2fb20df5ebf8f8d9d86536cb93923418e18d5e9eb67f099b2bc13022ce018ffe88e7b
@@ -3,7 +3,7 @@ module IsoDoc
3
3
  module Footnotes
4
4
  def make_table_footnote_link(out, fnid, node)
5
5
  attrs = { href: "##{fnid}", class: "TableFootnoteRef" }
6
- sup = node.at(ns("./sup")) and sup.replace(sup.children)
6
+ sup = node.at(ns(".//sup")) and sup.replace(sup.children)
7
7
  out.a **attrs do |a|
8
8
  children_parse(node, a)
9
9
  end
@@ -34,7 +34,7 @@ module IsoDoc
34
34
  return
35
35
  fnbody["reference"] = reference
36
36
  fnbody["is_table"] = true
37
- sup = fnbody.at(ns(".//fmt-fn-label/sup")) and sup.replace(sup.children)
37
+ sup = fnbody.at(ns(".//fmt-fn-label//sup")) and sup.replace(sup.children)
38
38
  fnbody.xpath(ns(".//fmt-fn-label")).each do |s|
39
39
  s["class"] = "TableFootnoteRef"
40
40
  s.name = "span"
@@ -220,6 +220,7 @@ module IsoDoc
220
220
  def amend_parse(node, out); end
221
221
  def semx_sourcecode_parse(node, out); end
222
222
  def review_note_parse(node, out); end
223
+ def semx_source_parse(node, out); end
223
224
 
224
225
  def fmt_name_parse(node, out)
225
226
  children_parse(node, out)
@@ -34,21 +34,6 @@ module IsoDoc
34
34
  OL_STYLE[type.to_sym]
35
35
  end
36
36
 
37
- # We don't really want users to specify type of ordered list;
38
- # we will use a fixed hierarchy as practiced by ISO (though not
39
- # fully spelled out): a) 1) i) A) I)
40
- # Fallback, this is now being done in Presentation XML
41
- # KILL
42
- def ol_depthx(node)
43
- depth = node.ancestors("ul, ol").size + 1
44
- type = :alphabet
45
- type = :arabic if [2, 7].include? depth
46
- type = :roman if [3, 8].include? depth
47
- type = :alphabet_upper if [4, 9].include? depth
48
- type = :roman_upper if [5, 10].include? depth
49
- ol_style(type)
50
- end
51
-
52
37
  def ol_attrs(node)
53
38
  { # type: node["type"] ? ol_style(node["type"].to_sym) : ol_depth(node),
54
39
  type: ol_style(node["type"]&.to_sym),
@@ -84,7 +84,7 @@ module IsoDoc
84
84
 
85
85
  def table_parse_tail(node, out)
86
86
  (dl = node.at(ns("./dl"))) && parse(dl, out)
87
- node.xpath(ns("./source")).each { |n| parse(n, out) }
87
+ node.xpath(ns("./fmt-source")).each { |n| parse(n, out) }
88
88
  node.xpath(ns("./note")).each { |n| parse(n, out) }
89
89
  node.xpath(ns("./fmt-footnote-container/fmt-fn-body"))
90
90
  .each { |n| parse(n, out) }
@@ -153,7 +153,8 @@ module IsoDoc
153
153
  when "fn" then footnote_parse(node, out)
154
154
  when "p" then para_parse(node, out)
155
155
  when "quote" then quote_parse(node, out)
156
- when "source" then source_parse(node, out)
156
+ when "source" then semx_source_parse(node, out)
157
+ when "fmt-source" then source_parse(node, out)
157
158
  when "tr" then tr_parse(node, out)
158
159
  when "note" then note_parse(node, out)
159
160
  when "review" then review_note_parse(node, out)
@@ -142,38 +142,65 @@ module IsoDoc
142
142
  def amend1(elem)
143
143
  ret = semx_fmt_dup(elem)
144
144
  ret.xpath(ns("./locality | ./localityStack | ./autonumber | " \
145
- "./classification | ./contributor")).each(&:remove)
145
+ "./classification | ./contributor")).each(&:remove)
146
146
  ret.xpath(ns("./newcontent")).each { |a| a.name = "quote" }
147
147
  ret.xpath(ns("./description")).each { |a| a.replace(a.children) }
148
148
  elem.xpath(ns(".//fmt-name | .//fmt-xref-label")).each(&:remove)
149
149
  elem.next = ret
150
150
  end
151
151
 
152
+ # TODO will go back to just one source/modification, preserving it
152
153
  def source(docxml)
153
- docxml.xpath(ns("//source/modification")).each do |f|
154
+ fmt_source(docxml)
155
+ docxml.xpath(ns("//fmt-source/source/modification")).each do |f|
154
156
  source_modification(f)
155
157
  end
156
- docxml.xpath(ns("//table/source")).each { |f| tablesource(f) }
157
- docxml.xpath(ns("//figure/source")).each { |f| figuresource(f) }
158
+ source_types(docxml)
159
+ docxml.xpath(ns("//fmt-source/source")).each do |f|
160
+ f.replace(semx_fmt_dup(f))
161
+ end
162
+ end
163
+
164
+ def source_types(docxml)
165
+ docxml.xpath(ns("//table/fmt-source")).each { |f| tablesource(f) }
166
+ docxml.xpath(ns("//figure/fmt-source")).each { |f| figuresource(f) }
167
+ end
168
+
169
+ def fmt_source(docxml)
170
+ n = docxml.xpath(ns("//source")) - docxml.xpath(ns("//term//source")) -
171
+ docxml.xpath(ns("//quote/source"))
172
+ n.each do |s|
173
+ dup = s.clone
174
+ modification_dup_align(s, dup)
175
+ s.next = "<fmt-source>#{to_xml(dup)}</fmt-source>"
176
+ end
158
177
  end
159
178
 
160
179
  def tablesource(elem)
161
- source1(elem)
180
+ source1(elem, :table)
162
181
  end
163
182
 
164
183
  def figuresource(elem)
165
- source1(elem)
184
+ source1(elem, :figure)
166
185
  end
167
186
 
168
- def source1(elem)
169
- while elem&.next_element&.name == "source"
170
- elem << "; #{to_xml(elem.next_element.remove.children)}"
187
+ def source1(elem, ancestor)
188
+ n = elem
189
+ while n = n&.next_element
190
+ case n.name
191
+ when "source"
192
+ when "fmt-source"
193
+ elem << "; #{to_xml(n.remove.children)}"
194
+ else break
195
+ end
171
196
  end
172
- elem.children = l10n("[#{@i18n.source}: #{to_xml(elem.children).strip}]")
197
+ source1_label(elem, to_xml(elem.children).strip, ancestor)
198
+ end
199
+
200
+ def source1_label(elem, sources, _ancestor)
201
+ elem.children = l10n("[#{@i18n.source}: #{sources}]")
173
202
  end
174
203
 
175
- # TODO just as termsource is duplicated in fmt-termsource to allow for changes,
176
- # should double up source with fmt-source
177
204
  def source_modification(mod)
178
205
  termsource_modification(mod.parent)
179
206
  end
@@ -7,7 +7,7 @@ module IsoDoc
7
7
  end
8
8
 
9
9
  def concept1(node)
10
- node.ancestors("definition, termsource, related").empty? or return
10
+ node.ancestors("definition, source, related").empty? or return
11
11
  xref = node&.at(ns("./semx/fmt-xref/@target"))&.text or
12
12
  return concept_render(node, ital: "true", ref: "true", bold: "false",
13
13
  linkref: "true", linkmention: "false")
@@ -192,8 +192,8 @@ module IsoDoc
192
192
  desgn.parent.name == "related" and return
193
193
  out = desgn.parent.at(ns("./fmt-#{desgn.name}"))
194
194
  d1 = semx_fmt_dup(desgn)
195
- s = d1.at(ns("./termsource"))
196
- s0 = desgn.at(ns("./termsource"))
195
+ s = d1.at(ns("./source"))
196
+ s0 = desgn.at(ns("./source"))
197
197
  modification_dup_align(s0, s)
198
198
  name = d1.at(ns("./expression/name | ./letter-symbol/name | " \
199
199
  "./graphical-symbol")) or return
@@ -33,7 +33,6 @@ module IsoDoc
33
33
  [e["connective"], to_xml(e.parent.remove)]
34
34
  end.flatten
35
35
  ret = resolve_eref_connectives(locs)
36
- elem["id"] ||= "_#{UUIDTools::UUID.random_create}"
37
36
  elem.next = "<semx element='erefstack' source='#{elem['id']}'>#{ret[1]}</semx>"
38
37
  end
39
38
 
@@ -3,11 +3,12 @@ module IsoDoc
3
3
  def footnote_collect(fnotes)
4
4
  seen = {}
5
5
  fnotes.each_with_object([]) do |x, m|
6
- x["id"] ||= "_#{UUIDTools::UUID.random_create}"
7
6
  seen[x["reference"]] or m << fnbody(x, seen)
8
7
  x["target"] = seen[x["reference"]]
9
8
  ref = x["hiddenref"] == "true" ? "" : fn_ref_label(x)
10
- x << "<fmt-fn-label>#{ref}</fmt-fn-label>"
9
+ x << <<~FNOTE.strip
10
+ <fmt-fn-label><span class='fmt-caption-label'>#{ref}</span</fmt-fn-label>
11
+ FNOTE
11
12
  end
12
13
  end
13
14
 
@@ -35,7 +36,7 @@ module IsoDoc
35
36
  body.at(ns("./semx")).children.first.before("<p> </p>").previous
36
37
  lbl = fn_body_label(fnote)
37
38
  ins.children.first.previous = <<~FNOTE.strip
38
- <fmt-fn-label>#{lbl}<span class="fmt-caption-delim"><tab/></fmt-fn-label>
39
+ <fmt-fn-label><span class='fmt-caption-label'>#{lbl}</span><span class="fmt-caption-delim"><tab/></fmt-fn-label>
39
40
  FNOTE
40
41
  end
41
42
 
@@ -145,7 +146,6 @@ module IsoDoc
145
146
  end
146
147
 
147
148
  def comment_body(elem)
148
- elem["id"] ||= "_#{UUIDTools::UUID.random_create}"
149
149
  c1 = elem.after("<fmt-review-body/>").next
150
150
  elem.attributes.each_key { |k| c1[k] = elem[k] }
151
151
  c1["id"] = "_#{UUIDTools::UUID.random_create}"
@@ -0,0 +1,79 @@
1
+ module IsoDoc
2
+ class PresentationXMLConvert < ::IsoDoc::Convert
3
+ def id_validate(docxml)
4
+ repeat_id_validate(docxml)
5
+ idref_validate(docxml)
6
+ end
7
+
8
+ def repeat_id_validate1(elem)
9
+ if @doc_ids[elem["id"]]
10
+ @log.add("Anchors", elem,
11
+ "Anchor #{elem['id']} has already been " \
12
+ "used at line #{@doc_ids[elem['id']]}", severity: 0)
13
+ end
14
+ @doc_ids[elem["id"]] = elem.line
15
+ end
16
+
17
+ def repeat_id_validate(doc)
18
+ @log or return
19
+ @doc_ids = {}
20
+ doc.xpath("//*[@id]").each do |x|
21
+ repeat_id_validate1(x)
22
+ end
23
+ end
24
+
25
+ def idref_validate(doc)
26
+ @log or return
27
+ doc.xpath("//*[@original-id]").each do |x|
28
+ @doc_ids[x["original-id"]] = x.line
29
+ end
30
+ Metanorma::Utils::anchor_attributes(presxml: true).each do |e|
31
+ doc.xpath("//xmlns:#{e[0]}[@#{e[1]}]").each do |x|
32
+ idref_validate1(x, e[1])
33
+ end
34
+ end
35
+ end
36
+
37
+ def idref_validate1(node, attr)
38
+ node[attr].strip.empty? and return
39
+ @doc_ids[node[attr]] and return
40
+ @log.add("Anchors", node,
41
+ "Anchor #{node[attr]} pointed to by #{node.name} " \
42
+ "is not defined in the document", severity: 1)
43
+ end
44
+
45
+ def provide_ids(docxml)
46
+ anchor_sanitise(docxml)
47
+ populate_id(docxml)
48
+ add_missing_id(docxml)
49
+ end
50
+
51
+ def anchor_sanitise(docxml)
52
+ Metanorma::Utils::anchor_attributes.each do |a|
53
+ docxml.xpath("//xmlns:#{a[0]}").each do |x|
54
+ x[a[1]] &&= to_ncname(x[a[1]])
55
+ end
56
+ end
57
+ end
58
+
59
+ def populate_id(docxml)
60
+ docxml.xpath("//*[@id]").each do |x|
61
+ x["semx-id"] = x["id"]
62
+ x["anchor"] and x["id"] = to_ncname(x["anchor"])
63
+ end
64
+ end
65
+
66
+ def add_missing_id(docxml)
67
+ docxml.xpath(ns("//source | //modification | //erefstack | //fn | " \
68
+ "//review | //floating-title")).each do |s|
69
+ s["id"] ||= "_#{UUIDTools::UUID.random_create}"
70
+ end
71
+ end
72
+
73
+ # do not sanitise "#"
74
+ def to_ncname(ident)
75
+ ret = ident.split("#", 2)
76
+ ret.map { |x| Metanorma::Utils::to_ncname(x) }.join("#")
77
+ end
78
+ end
79
+ end
@@ -71,7 +71,7 @@ module IsoDoc
71
71
  # do not change to Presentation XML rendering
72
72
  def sem_xml_descendant?(node)
73
73
  ancestor_names = node.ancestors.map(&:name)
74
- %w[preferred admitted deprecated related definition termsource]
74
+ %w[preferred admitted deprecated related definition source]
75
75
  .any? do |name|
76
76
  ancestor_names.include?(name)
77
77
  end and return true
@@ -211,7 +211,7 @@ module IsoDoc
211
211
  date_note = bib.at(ns("./note[@type = 'Unpublished-Status']"))
212
212
  date_note.nil? and return ret
213
213
  id = "_#{UUIDTools::UUID.random_create}"
214
- "#{ret}<fn reference='#{id}'><p>#{date_note.content}</p></fn>"
214
+ "#{ret}<fn id='#{id}' reference='#{id}'><p>#{date_note.content}</p></fn>"
215
215
  end
216
216
 
217
217
  def ident_fn(bib)
@@ -1,24 +1,29 @@
1
1
  module IsoDoc
2
2
  class PresentationXMLConvert < ::IsoDoc::Convert
3
3
  DESIGNATION_ELEMS =
4
- %w(preferred admitted deprecates related definition termsource).freeze
4
+ %w(preferred admitted deprecates related definition source).freeze
5
+
6
+ def target_desgn_elem(name)
7
+ target = "fmt-#{name}"
8
+ name == "source" and target = "fmt-termsource"
9
+ target
10
+ end
5
11
 
6
12
  def termcontainers(docxml)
7
13
  docxml.xpath(ns("//term")).each do |t|
8
14
  DESIGNATION_ELEMS.each do |w|
9
- d = t.at(ns("./#{w}[last()]")) and d.after("<fmt-#{w}/>")
15
+ target = target_desgn_elem(w)
16
+ d = t.at(ns("./#{w}[last()]")) and d.after("<#{target}/>")
10
17
  end
11
18
  end
12
- docxml.xpath(ns("//termsource")).each do |s|
13
- s["id"] ||= "_#{UUIDTools::UUID.random_create}"
14
- end
15
19
  end
16
20
 
17
21
  def termcleanup(docxml)
18
22
  docxml.xpath(ns("//term")).each do |t|
19
23
  DESIGNATION_ELEMS.each do |w|
24
+ target = target_desgn_elem(w)
20
25
  t.xpath(ns("./#{w}//fmt-name | ./#{w}//fmt-xref-label")).each(&:remove)
21
- f = t.at(ns(".//fmt-#{w}"))
26
+ f = t.at(ns(".//#{target}"))
22
27
  f&.children&.empty? and f.remove
23
28
  end
24
29
  end
@@ -56,12 +61,12 @@ module IsoDoc
56
61
  else singledef(elem, d, d1)
57
62
  end
58
63
  unwrap_definition(elem, d1)
59
- s1 = d.xpath(ns(".//termsource"))
60
- s2 = d1.xpath(ns(".//termsource"))
61
- s1.each_with_index do |s, i|
62
- modification_dup_align(s, s2[i])
63
- end
64
- termdomain(elem, d1)
64
+ s1 = d.xpath(ns(".//source"))
65
+ s2 = d1.xpath(ns(".//source"))
66
+ s1.each_with_index do |s, i|
67
+ modification_dup_align(s, s2[i])
68
+ end
69
+ termdomain(elem, d1)
65
70
  end
66
71
 
67
72
  def multidef(_elem, defn, fmt_defn)
@@ -94,7 +99,8 @@ termdomain(elem, d1)
94
99
  def termsource(docxml)
95
100
  copy_baselevel_termsource(docxml)
96
101
  # TODO should I wrap fmt-definition//termsource in fmt-termsource, in order to preserve termsource attributes?
97
- docxml.xpath(ns("//fmt-termsource/termsource | //fmt-definition//termsource | //fmt-preferred//termsource | //fmt-admitted//termsource | //fmt-deprecates//termsource"))
102
+ # differentiating term and nonterm source under designations is not worth it
103
+ docxml.xpath(ns("//fmt-termsource/source | //fmt-definition//source | //fmt-preferred//source | //fmt-admitted//source | //fmt-deprecates//source"))
98
104
  .each do |f|
99
105
  termsource_modification(f)
100
106
  end
@@ -102,7 +108,7 @@ termdomain(elem, d1)
102
108
  .each do |f|
103
109
  termsource_designation(f)
104
110
  end
105
- docxml.xpath(ns("//fmt-termsource/termsource | //fmt-definition//termsource | //fmt-preferred//termsource | //fmt-admitted//termsource | //fmt-deprecates//termsource"))
111
+ docxml.xpath(ns("//fmt-termsource/source | //fmt-definition//source | //fmt-preferred//source | //fmt-admitted//source | //fmt-deprecates//source"))
106
112
  .each do |f|
107
113
  f.parent and termsource1(f)
108
114
  end
@@ -116,11 +122,8 @@ termdomain(elem, d1)
116
122
  end
117
123
 
118
124
  def copy_baselevel_termsource(docxml)
119
- docxml.xpath(ns("//term//modification")).each do |f|
120
- f["id"] ||= "_#{UUIDTools::UUID.random_create}"
121
- end
122
- docxml.xpath(ns("//term[termsource]")).each do |x|
123
- s = x.xpath(ns("./termsource"))
125
+ docxml.xpath(ns("//term[source]")).each do |x|
126
+ s = x.xpath(ns("./source"))
124
127
  s1 = x.at(ns("./fmt-termsource"))
125
128
  s.each do |ss|
126
129
  dup = ss.clone
@@ -135,13 +138,17 @@ termdomain(elem, d1)
135
138
  def modification_dup_align(sem, pres)
136
139
  m = sem&.at(ns("./modification")) or return
137
140
  m1 = pres.at(ns("./modification"))
141
+ if m["original-id"]
142
+ m["id"] = m["original-id"]
143
+ m.delete("original-id")
144
+ end
138
145
  new_m1 = semx_fmt_dup(m)
139
146
  m1.replace("<modification>#{to_xml(new_m1)}</modification>")
140
147
  end
141
148
 
142
149
  def termsource1(elem)
143
150
  ret = [semx_fmt_dup(elem)]
144
- while elem&.next_element&.name == "termsource"
151
+ while elem&.next_element&.name == "source"
145
152
  ret << semx_fmt_dup(elem.next_element.remove)
146
153
  end
147
154
  s = ret.map { |x| to_xml(x) }.map(&:strip).join("; ")
@@ -167,7 +174,7 @@ termdomain(elem, d1)
167
174
  return
168
175
  end
169
176
  mod.previous = " &#x2014; "
170
- c = mod.at(ns("./semx" )) || mod
177
+ c = mod.at(ns("./semx")) || mod
171
178
  c.elements.size == 1 and c.children = to_xml(c.elements[0].children)
172
179
  mod.replace(mod.children)
173
180
  end
@@ -25,7 +25,6 @@ module IsoDoc
25
25
 
26
26
  # TODO not currently doing anything with the @depth attribute of floating-title
27
27
  def floattitle1(elem)
28
- elem["id"] ||= "_#{UUIDTools::UUID.random_create}"
29
28
  p = elem.dup
30
29
  p.children = "<semx element='floating-title' source='#{elem['id']}'>" \
31
30
  "#{to_xml(p.children)}</semx>"
@@ -12,6 +12,7 @@ require_relative "presentation_function/index"
12
12
  require_relative "presentation_function/bibdata"
13
13
  require_relative "presentation_function/metadata"
14
14
  require_relative "presentation_function/footnotes"
15
+ require_relative "presentation_function/ids"
15
16
 
16
17
  module IsoDoc
17
18
  class PresentationXMLConvert < ::IsoDoc::Convert
@@ -25,8 +26,7 @@ module IsoDoc
25
26
  presxml_convert_init(docxml, filename, dir)
26
27
  conversions(docxml)
27
28
  docxml.root["type"] = "presentation"
28
- repeat_id_validate(docxml.root)
29
- idref_validate(docxml.root)
29
+ id_validate(docxml.root)
30
30
  docxml.to_xml.gsub("&lt;", "&#x3c;").gsub("&gt;", "&#x3e;")
31
31
  end
32
32
 
@@ -38,59 +38,13 @@ module IsoDoc
38
38
  @outputdir = dir
39
39
  @outputfile = Pathname.new(filename).basename.to_s
40
40
  docid_prefixes(docxml) # feeds @xrefs.parse citation processing
41
+ provide_ids docxml # feeds @xrefs.parse
41
42
  @xrefs.parse docxml
42
43
  @xrefs.klass.meta = @meta
43
44
  @xrefs.klass.info docxml, nil
44
45
  counter_init
45
46
  end
46
47
 
47
- def repeat_id_validate1(elem)
48
- if @doc_ids[elem["id"]]
49
- @log.add("Anchors", elem,
50
- "Anchor #{elem['id']} has already been " \
51
- "used at line #{@doc_ids[elem['id']]}", severity: 0)
52
- end
53
- @doc_ids[elem["id"]] = elem.line
54
- end
55
-
56
- def repeat_id_validate(doc)
57
- @log or return
58
- @doc_ids = {}
59
- doc.xpath("//*[@id]").each do |x|
60
- repeat_id_validate1(x)
61
- end
62
- end
63
-
64
- IDREF =
65
- [%w(review from), %w(review to), %w(index to), %w(xref target),
66
- %w(callout target), %w(eref bibitemid), %w(citation bibitemid),
67
- %w(admonition target), %w(label for), %w(semx source),
68
- %w(fmt-title source), %w(fmt-xref-label container), %w(fn target),
69
- %w(fmt-fn-body target), %w(fmt-review-start source),
70
- %w(fmt-review-start end), %w(fmt-review-start target),
71
- %w(fmt-review-end source), %w(fmt-review-end start),
72
- %w(fmt-review-end target)].freeze
73
-
74
- def idref_validate(doc)
75
- @log or return
76
- doc.xpath("//*[@original-id]").each do |x|
77
- @doc_ids[x["original-id"]] = x.line
78
- end
79
- IDREF.each do |e|
80
- doc.xpath("//xmlns:#{e[0]}[@#{e[1]}]").each do |x|
81
- idref_validate1(x, e[1])
82
- end
83
- end
84
- end
85
-
86
- def idref_validate1(node, attr)
87
- node[attr].strip.empty? and return
88
- @doc_ids[node[attr]] and return
89
- @log.add("Anchors", node,
90
- "Anchor #{node[attr]} pointed to by #{node.name} " \
91
- "is not defined in the document", severity: 1)
92
- end
93
-
94
48
  def bibitem_lookup(docxml)
95
49
  @bibitem_lookup ||= docxml.xpath(ns("//references/bibitem"))
96
50
  .each_with_object({}) do |b, m|
@@ -188,35 +142,6 @@ module IsoDoc
188
142
  .previous_element
189
143
  end
190
144
 
191
- def embedable_semantic_xml(xml)
192
- xml = embedable_semantic_xml_tags(xml)
193
- embedable_semantic_xml_attributes(xml)
194
- end
195
-
196
- def embedable_semantic_xml_tags(xml)
197
- ret = to_xml(xml)
198
- .sub(/ xmlns=['"][^"']+['"]/, "") # root XMLNS
199
- .split(/(?=[<> \t\r\n\f\v])/).map do |x|
200
- case x
201
- when /^<[^:]+:/ then x.sub(":", ":semantic__")
202
- when /^<[^:]+$/ then x.sub(%r{(</?)([[:alpha:]])},
203
- "\\1semantic__\\2")
204
- else x end
205
- end
206
- Nokogiri::XML(ret.join).root
207
- end
208
-
209
- def embedable_semantic_xml_attributes(xml)
210
- Metanorma::Utils::anchor_attributes.each do |(tag_name, attr_name)|
211
- tag_name == "*" or tag_name = "semantic__#{tag_name}"
212
- xml.xpath("//#{tag_name}[@#{attr_name}]").each do |elem|
213
- elem.attributes[attr_name].value =
214
- "semantic__#{elem.attributes[attr_name].value}"
215
- end
216
- end
217
- xml
218
- end
219
-
220
145
  def postprocess(result, filename, _dir)
221
146
  to_xml_file(result, filename)
222
147
  @files_to_delete.each { |f| FileUtils.rm_rf f }
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "3.1.7".freeze
2
+ VERSION = "3.1.8".freeze
3
3
  end
@@ -10,14 +10,6 @@ module IsoDoc
10
10
  sprintf "%09d", ret
11
11
  end
12
12
 
13
- def make_table_footnote_link(out, fnid, node)
14
- attrs = { href: "##{fnid}", class: "TableFootnoteRef" }
15
- sup = node.at(ns("./sup")) and sup.replace(sup.children)
16
- out.a **attrs do |a|
17
- children_parse(node, a)
18
- end
19
- end
20
-
21
13
  def fmt_fn_body_parse(node, out)
22
14
  node.at(ns(".//fmt-fn-label"))&.remove
23
15
  aside = node.parent.name == "fmt-footnote-container"
@@ -28,27 +20,6 @@ module IsoDoc
28
20
  end
29
21
  end
30
22
 
31
- # dupe to HTML
32
- def get_table_ancestor_id(node)
33
- table = node.ancestors("table")
34
- table.empty? and table = node.ancestors("figure")
35
- table.empty? and return [nil,
36
- UUIDTools::UUID.random_create.to_s]
37
- [table.last, table.last["id"]]
38
- end
39
-
40
- # dupe to HTML
41
- def table_footnote_parse(node, out)
42
- fn = node["reference"] || UUIDTools::UUID.random_create.to_s
43
- table, tid = get_table_ancestor_id(node)
44
- make_table_footnote_link(out, tid + fn, node.at(ns("./fmt-fn-label")))
45
- # do not output footnote text if we have already seen it for this table
46
- return if @seen_footnote.include?(tid + fn)
47
-
48
- update_table_fn_body_ref(node, table, tid + fn)
49
- @seen_footnote << (tid + fn)
50
- end
51
-
52
23
  def seen_footnote_parse(node, out, footnote)
53
24
  f = node.at(ns("./fmt-fn-label"))
54
25
  sup = f.at(ns(".//sup")) and sup.replace(sup.children)
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: 3.1.7
4
+ version: 3.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-04-28 00:00:00.000000000 Z
11
+ date: 2025-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -442,6 +442,7 @@ files:
442
442
  - lib/isodoc/presentation_function/docid.rb
443
443
  - lib/isodoc/presentation_function/erefs.rb
444
444
  - lib/isodoc/presentation_function/footnotes.rb
445
+ - lib/isodoc/presentation_function/ids.rb
445
446
  - lib/isodoc/presentation_function/image.rb
446
447
  - lib/isodoc/presentation_function/index.rb
447
448
  - lib/isodoc/presentation_function/inline.rb