isodoc 3.4.1 → 3.4.3

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 (54) hide show
  1. checksums.yaml +4 -4
  2. data/lib/isodoc/base_style/typography.scss +5 -0
  3. data/lib/isodoc/convert.rb +3 -2
  4. data/lib/isodoc/function/blocks.rb +33 -5
  5. data/lib/isodoc/function/blocks_example_note.rb +5 -3
  6. data/lib/isodoc/function/cleanup.rb +5 -4
  7. data/lib/isodoc/function/inline.rb +9 -27
  8. data/lib/isodoc/function/inline_simple.rb +25 -0
  9. data/lib/isodoc/function/references.rb +11 -4
  10. data/lib/isodoc/function/setup.rb +2 -1
  11. data/lib/isodoc/function/table.rb +2 -2
  12. data/lib/isodoc/function/to_word_html.rb +1 -0
  13. data/lib/isodoc/function/utils.rb +1 -1
  14. data/lib/isodoc/init.rb +17 -7
  15. data/lib/isodoc/metadata.rb +10 -6
  16. data/lib/isodoc/metadata_contributor.rb +15 -2
  17. data/lib/isodoc/presentation_function/autonum.rb +65 -4
  18. data/lib/isodoc/presentation_function/bibdata.rb +15 -4
  19. data/lib/isodoc/presentation_function/block.rb +36 -78
  20. data/lib/isodoc/presentation_function/docid.rb +18 -10
  21. data/lib/isodoc/presentation_function/erefs.rb +55 -28
  22. data/lib/isodoc/presentation_function/erefs_locality.rb +18 -10
  23. data/lib/isodoc/presentation_function/footnotes.rb +2 -1
  24. data/lib/isodoc/presentation_function/image.rb +15 -5
  25. data/lib/isodoc/presentation_function/index.rb +1 -5
  26. data/lib/isodoc/presentation_function/inline.rb +2 -20
  27. data/lib/isodoc/presentation_function/list.rb +3 -3
  28. data/lib/isodoc/presentation_function/metadata.rb +50 -32
  29. data/lib/isodoc/presentation_function/refs.rb +70 -86
  30. data/lib/isodoc/presentation_function/section.rb +0 -3
  31. data/lib/isodoc/presentation_function/section_refs.rb +55 -0
  32. data/lib/isodoc/presentation_function/source.rb +73 -0
  33. data/lib/isodoc/presentation_function/terms.rb +7 -5
  34. data/lib/isodoc/presentation_function/xrefs.rb +17 -6
  35. data/lib/isodoc/presentation_xml_convert.rb +10 -4
  36. data/lib/isodoc/version.rb +1 -1
  37. data/lib/isodoc/word_function/lists.rb +4 -2
  38. data/lib/isodoc/word_function/postprocess_table.rb +3 -1
  39. data/lib/isodoc/xref/xref_gen.rb +72 -119
  40. data/lib/isodoc/xref/xref_gen_seq.rb +18 -14
  41. data/lib/isodoc/xref/xref_list_gen.rb +107 -0
  42. data/lib/isodoc/xref/xref_sect_asset.rb +0 -1
  43. data/lib/isodoc/xref/xref_sect_gen.rb +0 -2
  44. data/lib/isodoc/xref.rb +1 -0
  45. data/lib/isodoc/xslfo_convert.rb +5 -1
  46. data/lib/isodoc-yaml/i18n-ar.yaml +9 -0
  47. data/lib/isodoc-yaml/i18n-de.yaml +9 -0
  48. data/lib/isodoc-yaml/i18n-en.yaml +9 -0
  49. data/lib/isodoc-yaml/i18n-es.yaml +9 -0
  50. data/lib/isodoc-yaml/i18n-fr.yaml +9 -0
  51. data/lib/isodoc-yaml/i18n-ja.yaml +9 -0
  52. data/lib/isodoc-yaml/i18n-ru.yaml +9 -0
  53. data/lib/isodoc-yaml/i18n-zh-Hans.yaml +9 -0
  54. metadata +5 -2
@@ -24,15 +24,17 @@ module IsoDoc
24
24
  end
25
25
 
26
26
  def formula1(elem)
27
- formula_where(elem.at(ns("./dl")))
28
- lbl = @xrefs.anchor(elem["id"], :label, false)
27
+ dl = elem.at(ns("./dl")) and dl.replace("<key>#{to_xml(dl)}</key>")
28
+ formula_where(elem.at(ns("./key")))
29
+ lbl = @xrefs.anchor(elem["id"], :label, false) ||
30
+ @xrefs.anchor(elem["original-id"], :label, false)
29
31
  lbl.nil? || lbl.empty? or prefix_name(elem, {}, lbl, "name")
30
32
  end
31
33
 
32
34
  def formula_where(dlist)
33
35
  dlist or return
34
36
  dlist["class"] = "formula_dl"
35
- where = dlist.xpath(ns("./dt")).size > 1 ? @i18n.where : @i18n.where_one
37
+ where = dlist.xpath(ns(".//dt")).size > 1 ? @i18n.where : @i18n.where_one
36
38
  dlist.previous = "<p keep-with-next='true'>#{where}</p>"
37
39
  end
38
40
 
@@ -41,8 +43,9 @@ module IsoDoc
41
43
  end
42
44
 
43
45
  def example1(elem)
44
- n = @xrefs.get[elem["id"]]
45
- lbl = labelled_autonum(@i18n.example, elem["id"], n&.dig(:label))
46
+ n = @xrefs.get[elem["id"]] || @xrefs.get[elem["original-id"]]
47
+ lbl = labelled_autonum(@i18n.example, elem["id"] || elem["original-id"],
48
+ n&.dig(:label))
46
49
  prefix_name(elem, { caption: block_delim }, lbl, "name")
47
50
  end
48
51
 
@@ -61,8 +64,9 @@ module IsoDoc
61
64
  end
62
65
 
63
66
  def note_label(elem)
64
- n = @xrefs.get[elem["id"]]
65
- labelled_autonum(@i18n.note, elem["id"], n&.dig(:label))
67
+ n = @xrefs.get[elem["id"]] || @xrefs.get[elem["original-id"]]
68
+ labelled_autonum(@i18n.note, elem["id"] || elem["original-id"],
69
+ n&.dig(:label))
66
70
  end
67
71
 
68
72
  def admonition(docxml)
@@ -81,7 +85,9 @@ module IsoDoc
81
85
  end
82
86
 
83
87
  def admonition_numbered1(elem)
84
- label = admonition_label(elem, @xrefs.anchor(elem["id"], :label, false))
88
+ label = admonition_label(elem,
89
+ @xrefs.anchor(elem["id"] || elem["original-id"],
90
+ :label, false))
85
91
  prefix_name(elem, { caption: block_delim }, label, "name")
86
92
  end
87
93
 
@@ -89,7 +95,7 @@ module IsoDoc
89
95
  lbl = if elem["type"] == "box" then @i18n.box
90
96
  else @i18n.admonition[elem["type"]]&.upcase
91
97
  end
92
- labelled_autonum(lbl, elem["id"], num)
98
+ labelled_autonum(lbl, elem["id"] || elem["original-id"], num)
93
99
  end
94
100
 
95
101
  def admonition_delim(_elem)
@@ -106,8 +112,9 @@ module IsoDoc
106
112
  table_css(elem)
107
113
  labelled_ancestor(elem) and return
108
114
  elem["unnumbered"] && !elem.at(ns("./name")) and return
109
- n = @xrefs.anchor(elem["id"], :label, false)
110
- lbl = labelled_autonum(lower2cap(@i18n.table), elem["id"], n)
115
+ n = @xrefs.anchor(elem["id"] || elem["original-id"], :label, false)
116
+ lbl = labelled_autonum(lower2cap(@i18n.table),
117
+ elem["id"] || elem["original-id"], n)
111
118
  prefix_name(elem, { caption: table_delim }, lbl, "name")
112
119
  end
113
120
 
@@ -142,83 +149,34 @@ module IsoDoc
142
149
 
143
150
  def amend1(elem)
144
151
  ret = semx_fmt_dup(elem)
145
- ret.xpath(ns("./locality | ./localityStack | ./autonumber | " \
146
- "./classification | ./contributor")).each(&:remove)
152
+ ret.xpath(ns("./locality | ./localityStack | .//autonumber | " \
153
+ "./classification | ./contributor | ./fmt-name | " \
154
+ "./fmt-xref-label")).each(&:remove)
155
+ amend_newcontent(ret)
147
156
  ret.xpath(ns("./newcontent")).each { |a| a.name = "quote" }
148
157
  ret.xpath(ns("./description")).each { |a| a.replace(a.children) }
149
- elem.xpath(ns(".//fmt-name | .//fmt-xref-label")).each(&:remove)
150
158
  elem.next = ret
151
159
  end
152
160
 
153
- # TODO will go back to just one source/modification, preserving it
154
- def source(docxml)
155
- fmt_source(docxml)
156
- docxml.xpath(ns("//fmt-source/source/modification")).each do |f|
157
- source_modification(f)
158
- end
159
- source_types(docxml)
160
- docxml.xpath(ns("//fmt-source/source")).each do |f|
161
- f.replace(semx_fmt_dup(f))
162
- end
163
- end
164
-
165
- def source_types(docxml)
166
- docxml.xpath(ns("//table/fmt-source")).each { |f| tablesource(f) }
167
- docxml.xpath(ns("//figure/fmt-source")).each { |f| figuresource(f) }
168
- end
169
-
170
- def fmt_source(docxml)
171
- n = docxml.xpath(ns("//source")) - docxml.xpath(ns("//term//source")) -
172
- docxml.xpath(ns("//quote/source"))
173
- n.each do |s|
174
- dup = s.clone
175
- modification_dup_align(s, dup)
176
- s.next = "<fmt-source>#{to_xml(dup)}</fmt-source>"
177
- end
178
- end
179
-
180
- def tablesource(elem)
181
- source1(elem, :table)
182
- end
183
-
184
- def figuresource(elem)
185
- source1(elem, :figure)
186
- end
187
-
188
- def source_join_delim(_elem)
189
- "; "
190
- end
191
-
192
- def source1(elem, ancestor)
193
- source_elems = source1_gather(elem)
194
- source_elems.each do |e|
195
- e.xpath(ns(".//origin")).each do |origin|
196
- origin.wrap("<esc></esc>")
161
+ def amend_newcontent(elem)
162
+ elem.xpath(ns("./newcontent")).each do |a|
163
+ a.name = "quote"
164
+ a.xpath(ns("./clause")).each do |c|
165
+ amend_subclause(c, 1)
166
+ a.next = c
197
167
  end
198
- elem << "#{source_join_delim(elem)}#{to_xml(e.remove.children).strip}"
199
168
  end
200
- source1_label(elem, @i18n.l10n(to_xml(elem.children).strip), ancestor)
201
169
  end
202
170
 
203
- def source1_gather(elem)
204
- source_elems = []
205
- while elem = elem&.next_element
206
- case elem.name
207
- when "source"
208
- when "fmt-source"
209
- source_elems << elem
210
- else break
211
- end
171
+ def amend_subclause(clause, depth)
172
+ clause.xpath(ns("./title")).reverse_each do |t|
173
+ # t.name = "floating-title"
174
+ # t["depth"] ||= depth || "1"
175
+ t.name = "p"
176
+ t["type"] = "floating-title"
212
177
  end
213
- source_elems
214
- end
215
-
216
- def source1_label(elem, sources, _ancestor)
217
- elem.children = l10n("[#{@i18n.source}: #{esc sources}]")
218
- end
219
-
220
- def source_modification(mod)
221
- termsource_modification(mod.parent)
178
+ clause.name = depth == 1 ? "quote" : "quote" # "div"
179
+ clause.xpath(ns("./clause")).each { |c| amend_subclause(c, depth + 1) }
222
180
  end
223
181
 
224
182
  def quote(docxml)
@@ -28,20 +28,21 @@ module IsoDoc
28
28
 
29
29
  # returns [metanorma, non-metanorma, DOI/ISSN/ISBN] identifiers
30
30
  def bibitem_ref_code(bib)
31
- id, id1, id2, id3 = bibitem_ref_code_prep(bib)
32
- id || id1 || id2 || id3 and return [id, id1, id2, id3]
33
- bib["suppress_identifier"] == "true" and return [nil, nil, nil, nil]
31
+ ret = bibitem_ref_code_prep(bib)
32
+ ret.all?(&:nil?) or return ret
33
+ bib["suppress_identifier"] == "true" and return [nil, nil, nil, nil, nil]
34
34
  # [nil, no_identifier(bib), nil, nil]
35
- [nil, nil, nil, nil]
35
+ [nil, nil, nil, nil, nil]
36
36
  end
37
37
 
38
38
  def bibitem_ref_code_prep(bib)
39
- id = bib.at(ns("./docidentifier[@type = 'metanorma']")) ||
40
- bib.at(ns("./docidentifier[@type = 'title']"))
39
+ id = bib.at(ns("./docidentifier[@type = 'metanorma']"))
41
40
  id1 = pref_ref_code(bib)
42
- id2 = bib.at(ns("./docidentifier[#{SKIP_DOCID}]"))
41
+ id2 = bib.at(ns("./docidentifier[#{SERIAL_NUM_DOCID}]"))
43
42
  id3 = bib.at(ns("./docidentifier[@type = 'metanorma-ordinal']"))
44
- [id, id1, id2, id3]
43
+ id4 = bib.at(ns("./docidentifier[@type = 'title']")) ||
44
+ bib.at(ns("./docidentifier[@type = 'author-date']"))
45
+ [id, id1, id2, id3, id4]
45
46
  end
46
47
 
47
48
  def no_identifier(bib)
@@ -64,6 +65,12 @@ module IsoDoc
64
65
  num
65
66
  end
66
67
 
68
+ def bracket(num)
69
+ num.nil? and return nil
70
+ num = xml_to_string_skip_fn(num).sub(/^\[/, "").sub(/\]$/, "")
71
+ "[#{num}]"
72
+ end
73
+
67
74
  def unbracket1(ident)
68
75
  ident.nil? and return nil
69
76
  ident.is_a?(String) or ident = xml_to_string_skip_fn(ident)
@@ -78,10 +85,11 @@ module IsoDoc
78
85
  end
79
86
 
80
87
  def render_identifier(ident)
81
- { metanorma: bracket_if_num(ident[0]),
88
+ { metanorma: bracket(ident[0]),
82
89
  sdo: unbracket(ident[1]),
83
90
  doi: unbracket(ident[2]),
84
- ordinal: bracket_if_num(ident[3]) }
91
+ ordinal: bracket(ident[3]),
92
+ content: unbracket(ident[4]) }
85
93
  end
86
94
  end
87
95
  end
@@ -6,12 +6,12 @@ module IsoDoc
6
6
  def citeas(xmldoc)
7
7
  xmldoc.xpath(ns("//fmt-eref | //fmt-origin | //fmt-link"))
8
8
  .each do |e|
9
- sem_xml_descendant?(e) and next
10
- e["bibitemid"] && e["citeas"] or next
11
- a = @xrefs.anchor(e["bibitemid"], :xref, false) or next
12
- e["citeas"] = citeas_cleanup(a)
13
- # link generated in collection postprocessing from eref
14
- e.name == "fmt-link" && e.text.empty? and e.children = e["citeas"]
9
+ sem_xml_descendant?(e) and next
10
+ e["bibitemid"] && e["citeas"] or next
11
+ a = @xrefs.anchor(e["bibitemid"], :xref, false) or next
12
+ e["citeas"] = citeas_cleanup(a)
13
+ # link generated in collection postprocessing from eref
14
+ e.name == "fmt-link" && e.text.empty? and e.children = e["citeas"]
15
15
  end
16
16
  end
17
17
 
@@ -32,19 +32,32 @@ module IsoDoc
32
32
 
33
33
  def erefstack1(elem)
34
34
  locs = elem.xpath(ns("./semx/fmt-eref")).map do |e|
35
- [e["connective"], to_xml(e.parent.remove)]
35
+ [{ conn: e["connective"], custom: e["custom-connective"] },
36
+ { ref: to_xml(e.parent.remove) }]
36
37
  end.flatten
37
38
  ret = resolve_eref_connectives(locs)
38
- elem.next = "<semx element='erefstack' source='#{elem['id']}'>#{l10n ret[1]}</semx>"
39
+ elem.next = <<~XML
40
+ <semx element='erefstack' source='#{elem['id']}'>#{l10n ret[1]}</semx>
41
+ XML
39
42
  end
40
43
 
41
44
  def resolve_eref_connectives(locs)
42
45
  locs = escape_l10n(locs)
43
46
  locs = resolve_comma_connectives(locs)
44
47
  locs = resolve_to_connectives(locs)
45
- locs.size < 3 and return locs
48
+ locs.size < 3 and return locs.map { |x| x[:custom] || x[:conn] || x[:ref] }
49
+ locs = locs.each_with_object([]) do |x, m|
50
+ if m.empty? then m << x
51
+ elsif m[-1][:conn] && x[:conn]
52
+ m[-1][:conn] += x[:conn]
53
+ x[:custom] and m[-1][:custom] = x[:custom]
54
+ elsif m[-1][:conn] && x[:conn]
55
+ m[-1][:ref] += x[:ref]
56
+ else m << x
57
+ end
58
+ end
46
59
  locs = locs.each_slice(2).with_object([]) do |a, m|
47
- m << { conn: a[0], label: a[1] }
60
+ m << { custom: a[0][:custom], conn: a[0][:conn], label: a.dig(1, :ref) }
48
61
  end
49
62
  [", ", combine_conn(locs)]
50
63
  end
@@ -53,11 +66,7 @@ module IsoDoc
53
66
 
54
67
  def escape_l10n(locs)
55
68
  locs.map do |x|
56
- if XREF_CONNECTIVES.include?(x) || [", ", " ", ""].include?(x)
57
- x
58
- else
59
- esc x
60
- end
69
+ x[:conn] ? x : { ref: esc(x[:ref]) }
61
70
  end
62
71
  end
63
72
 
@@ -67,13 +76,13 @@ module IsoDoc
67
76
  until locs.empty?
68
77
  locs, locs1, add = resolve_comma_connectives1(locs, locs1, add)
69
78
  end
70
- locs1 << add unless add.empty?
79
+ locs1 << { ref: add } unless add.empty?
71
80
  locs1
72
81
  end
73
82
 
74
83
  def resolve_comma_connectives1(locs, locs1, add)
75
- if [", ", " ", ""].include?(locs[1])
76
- add += locs[0..2].join
84
+ if [", ", " ", ""].include?(locs.dig(1, :conn)) && locs.size > 2
85
+ add += [locs[0][:ref], locs[1][:custom] || locs[1][:conn], locs[2][:ref]].join
77
86
  locs.shift(3)
78
87
  else
79
88
  locs1 << add unless add.empty?
@@ -86,11 +95,20 @@ module IsoDoc
86
95
  def resolve_to_connectives(locs)
87
96
  locs1 = []
88
97
  until locs.empty?
89
- if locs[1] == "to"
90
- locs1 << connectives_spans(@i18n.chain_to.sub("%1", locs[0])
91
- .sub("%2", locs[2]))
98
+ if locs.dig(1, :conn) == "to"
99
+ x = @i18n.chain_to.sub("%1", locs[0][:ref])
100
+ .sub("%2", locs[2][:ref])
101
+ c = locs[1][:custom] and x = conn_sub(x, c)
102
+ locs1 << { ref: connectives_spans(x) }
92
103
  locs.shift(3)
93
- else locs1 << locs.shift
104
+ else
105
+ if locs[0][:conn] == "from" && locs[0][:custom] # strip "from" and English
106
+ # TODO languages with obligatory "from"
107
+ locs1 << { conn: locs[0][:custom] }
108
+ locs.shift
109
+ else
110
+ locs1 << locs.shift
111
+ end
94
112
  end
95
113
  end
96
114
  locs1
@@ -100,13 +118,14 @@ module IsoDoc
100
118
  docxml.xpath(ns("//display-text")).each { |f| f.replace(f.children) }
101
119
  docxml.xpath(ns("//fmt-eref | //fmt-origin[not(.//termref)]"))
102
120
  .each do |e|
103
- sem_xml_descendant?(e) and next
104
- href = eref_target(e) or next
105
- e.xpath(ns("./locality | ./localityStack")).each(&:remove)
106
- if href[:type] == :anchor || %w(full short).include?(e["style"])
121
+ sem_xml_descendant?(e) and next
122
+ href = eref_target(e) or next
123
+ e.xpath(ns("./locality | ./localityStack")).each(&:remove)
124
+ if %w(short).include?(e["style"]) then eref2linkshort(e, href)
125
+ elsif href[:type] == :anchor || %w(full).include?(e["style"])
107
126
  eref2xref(e)
108
- else eref2link1(e, href)
109
- end
127
+ else eref2link1(e, href)
128
+ end
110
129
  end
111
130
  end
112
131
 
@@ -126,6 +145,14 @@ module IsoDoc
126
145
  node.replace(repl)
127
146
  end
128
147
 
148
+ def eref2linkshort(node, _href)
149
+ node.at(ns("./span[@class = 'fmt-first-biblio-delim']")) or
150
+ return eref2xref(node)
151
+ node.children = <<~XML
152
+ <fmt-xref target='#{node['bibitemid']}'>#{to_xml(node.children).sub('<span class="fmt-first-biblio-delim"/>', '</fmt-xref>')}
153
+ XML
154
+ end
155
+
129
156
  def suffix_url(url)
130
157
  url.nil? || %r{^https?://|^#}.match?(url) and return url
131
158
  File.extname(url).empty? or return url
@@ -36,12 +36,14 @@ module IsoDoc
36
36
  i == refs.size - 1 and next
37
37
  m << eref_locality_delimiter(r)
38
38
  end
39
- ret.empty? ? ret : [", "] + ret
39
+ ret[-1] && ret[-1][:conn] == ", " and ret.pop
40
+ ret.empty? ? ret : [{ conn: ", " }] + ret
40
41
  end
41
42
 
42
43
  def eref_locality_delimiter(ref)
43
44
  if ref&.next_element&.name == "localityStack"
44
- ref.next_element["connective"]
45
+ { conn: ref.next_element["connective"],
46
+ custom: ref.next_element["custom-connective"] }
45
47
  else locality_delimiter(ref)
46
48
  end
47
49
  end
@@ -51,23 +53,27 @@ module IsoDoc
51
53
  if ref.name == "localityStack"
52
54
  ret = eref_locality_stack1(ref, target, node, ret)
53
55
  else
54
- l = eref_localities0(ref, idx, target, node) and ret << l
56
+ l = eref_localities0(ref, idx, target, node) and ret << { ref: l }
55
57
  end
56
- ret[-1] == ", " and ret.pop
58
+ ret[-1] && ret[-1][:conn] == ", " and ret.pop
57
59
  ret
58
60
  end
59
61
 
60
62
  def eref_locality_stack1(ref, target, node, ret)
63
+ if ref["connective"] == "from" && ref["custom-connective"]
64
+ # TODO deal better with languages with mandatory from connective
65
+ ret << { conn: "from", custom: ref["custom-connective"] }
66
+ end
61
67
  ref.elements.each_with_index do |rr, j|
62
68
  l = eref_localities0(rr, j, target, node) or next
63
- ret << l
69
+ ret << { ref: l }
64
70
  ret << locality_delimiter(rr) unless j == ref.elements.size - 1
65
71
  end
66
72
  ret
67
73
  end
68
74
 
69
75
  def locality_delimiter(_loc)
70
- ", "
76
+ { conn: ", " }
71
77
  end
72
78
 
73
79
  def eref_localities0(ref, _idx, target, node)
@@ -80,6 +86,8 @@ module IsoDoc
80
86
  end
81
87
  end
82
88
 
89
+ # Suspended, this is an ordinal that GB asked for, not applicable
90
+ # for non-integers, and not desired for JIS
83
91
  def eref_localities1_zh(opt)
84
92
  ret = "第#{esc opt[:from]}" if opt[:from]
85
93
  ret += "&#x2013;#{esc opt[:upto]}" if opt[:upto]
@@ -90,11 +98,11 @@ module IsoDoc
90
98
 
91
99
  def eref_localities1(opt)
92
100
  opt[:type] == "anchor" and return nil
93
- %(zh ja ko).include?(opt[:lang]) and
94
- return l10n(eref_localities1_zh(opt))
101
+ # %(zh ja ko).include?(opt[:lang]) and
102
+ # return l10n(eref_localities1_zh(opt))
95
103
  ret = eref_locality_populate(opt[:type], opt[:node], opt[:number])
96
- ret += " #{opt[:from]}" if opt[:from]
97
- ret += "&#x2013;#{opt[:upto]}" if opt[:upto]
104
+ ret += " <esc>#{opt[:from]}</esc>" if opt[:from]
105
+ ret += "&#x2013;<esc>#{opt[:upto]}</esc>" if opt[:upto]
98
106
  l10n(ret)
99
107
  end
100
108
 
@@ -156,7 +156,8 @@ module IsoDoc
156
156
  def figure_key_insert_pt(elem)
157
157
  elem.at(ns(".//dl/name"))&.next ||
158
158
  elem.at(ns(".//dl"))&.children&.first ||
159
- elem.add_child("<dl> </dl>").first.children.first
159
+ elem.add_child("<key><dl> </dl></key>")
160
+ .first.elements.first.children.first
160
161
  end
161
162
 
162
163
  def comments(docxml)
@@ -70,9 +70,9 @@ module IsoDoc
70
70
  elem["class"] == "pseudocode" || elem["type"] == "pseudocode" and
71
71
  return sourcecode1(elem)
72
72
  figure_fn(elem)
73
- figure_key(elem.at(ns("./dl")))
74
- lbl = @xrefs.anchor(elem["id"], :label, false)
75
- lbl and a = autonum(elem["id"], lbl)
73
+ figure_key(elem.at(ns("./key")))
74
+ lbl = @xrefs.anchor(elem["id"] || elem["original-id"], :label, false)
75
+ lbl and a = autonum(elem["id"] || elem["original-id"], lbl)
76
76
  figname = figure_name(elem)
77
77
  elem.at("./ancestor::xmlns:figure") && a and
78
78
  a += subfigure_delim
@@ -95,8 +95,7 @@ module IsoDoc
95
95
  dlist or return
96
96
  dlist["class"] = "formula_dl"
97
97
  dlist.at(ns("./name")) and return
98
- dlist.previous =
99
- "<p keep-with-next='true'><strong>#{@i18n.key}</strong></p>"
98
+ dlist.children.first.previous = "<name>#{@i18n.key}</name>"
100
99
  end
101
100
 
102
101
  def eps2svg(img)
@@ -184,5 +183,16 @@ module IsoDoc
184
183
  node["height"] = e["height"]
185
184
  node["width"] = e["width"]
186
185
  end
186
+
187
+ # used downstream to load svg images inline
188
+ def svg_load(directory, filename)
189
+ dir = File.join(@libdir, "html", directory)
190
+ filename = File.join(dir, filename)
191
+ File.exist?(filename) or return
192
+ file = File.read(filename) or return
193
+ file.sub(
194
+ '<?xml version="1.0" encoding="UTF-8"?>', ""
195
+ )
196
+ end
187
197
  end
188
198
  end
@@ -1,15 +1,11 @@
1
1
  module IsoDoc
2
2
  class PresentationXMLConvert < ::IsoDoc::Convert
3
- def enable_indexsect
4
- false
5
- end
6
-
7
3
  def strip_index(docxml)
8
4
  docxml.xpath(ns("//index | //index-xref | //indexsect")).each(&:remove)
9
5
  end
10
6
 
11
7
  def index(xml)
12
- if enable_indexsect && xml.at(ns("//index"))
8
+ if xml.at(ns("//index"))
13
9
  i = xml.at(ns("//indexsect")) ||
14
10
  xml.root.add_child(
15
11
  "<indexsect #{add_id_text}>" \
@@ -68,31 +68,13 @@ module IsoDoc
68
68
  docxml.xpath(ns("//fmt-origin[not(.//termref)]")).each { |f| xref1(f) }
69
69
  end
70
70
 
71
- # do not change to Presentation XML rendering
72
- def sem_xml_descendant?(node)
73
- ancestor_names = node.ancestors.map(&:name)
74
- %w[preferred admitted deprecated related definition source]
75
- .any? do |name|
76
- ancestor_names.include?(name)
77
- end and return true
78
- %w[xref eref origin link name title].any? do |name|
79
- ancestor_names.include?(name)
80
- end and return true
81
- ancestor_names.include?("bibitem") &&
82
- %w[formattedref biblio-tag].none? do |name|
83
- ancestor_names.include?(name)
84
- end and return true
85
- (ancestor_names & %w[requirement recommendation permission]).any? &&
86
- !ancestor_names.include?("fmt-provision") and return true
87
-
88
- false
89
- end
90
-
91
71
  def xref1(node)
92
72
  sem_xml_descendant?(node) and return
93
73
  get_linkend(node)
94
74
  end
95
75
 
76
+ def link(xml); end
77
+
96
78
  # there should be no //variant in bibdata now
97
79
  def variant(xml)
98
80
  b = xml.xpath(ns("//bibdata//variant"))
@@ -50,8 +50,8 @@ module IsoDoc
50
50
  end
51
51
 
52
52
  def ol_label(elem)
53
- val = @xrefs.anchor(elem["id"], :label, false)
54
- semx = "<semx element='autonum' source='#{elem['id']}'>#{val}</semx>"
53
+ val = @xrefs.anchor(elem["id"] || elem["original-id"], :label, false)
54
+ semx = "<semx element='autonum' source='#{elem['id'] || elem["original-id"]}'>#{val}</semx>"
55
55
  lbl = "<fmt-name>#{ol_label_format(semx, elem)}</fmt-name>"
56
56
  elem.add_first_child(lbl)
57
57
  end
@@ -83,7 +83,7 @@ module IsoDoc
83
83
 
84
84
  def ul_label(elem)
85
85
  val = ul_label_value(elem)
86
- semx = "<semx element='autonum' source='#{elem['id']}'>#{val}</semx>"
86
+ semx = "<semx element='autonum' source='#{elem['id'] || elem["original-id"]}'>#{val}</semx>"
87
87
  lbl = "<fmt-name>#{semx}</fmt-name>"
88
88
  elem.add_first_child(lbl)
89
89
  end