isodoc 2.12.0 → 2.12.2

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 (63) hide show
  1. checksums.yaml +4 -4
  2. data/isodoc.gemspec +2 -2
  3. data/lib/isodoc/convert.rb +0 -21
  4. data/lib/isodoc/function/blocks.rb +19 -48
  5. data/lib/isodoc/function/blocks_example_note.rb +75 -29
  6. data/lib/isodoc/function/cleanup.rb +3 -40
  7. data/lib/isodoc/function/inline.rb +39 -9
  8. data/lib/isodoc/function/lists.rb +5 -5
  9. data/lib/isodoc/function/references.rb +9 -133
  10. data/lib/isodoc/function/reqt.rb +2 -2
  11. data/lib/isodoc/function/section.rb +25 -28
  12. data/lib/isodoc/function/section_titles.rb +16 -13
  13. data/lib/isodoc/function/table.rb +3 -3
  14. data/lib/isodoc/function/terms.rb +21 -20
  15. data/lib/isodoc/function/to_word_html.rb +8 -5
  16. data/lib/isodoc/function/utils.rb +1 -1
  17. data/lib/isodoc/html_function/footnotes.rb +2 -1
  18. data/lib/isodoc/html_function/html.rb +1 -5
  19. data/lib/isodoc/init.rb +31 -0
  20. data/lib/isodoc/metadata.rb +9 -0
  21. data/lib/isodoc/metadata_contributor.rb +1 -1
  22. data/lib/isodoc/metadata_date.rb +1 -1
  23. data/lib/isodoc/presentation_function/autonum.rb +139 -0
  24. data/lib/isodoc/presentation_function/block.rb +95 -36
  25. data/lib/isodoc/presentation_function/docid.rb +78 -0
  26. data/lib/isodoc/presentation_function/erefs.rb +6 -4
  27. data/lib/isodoc/presentation_function/image.rb +52 -13
  28. data/lib/isodoc/presentation_function/inline.rb +6 -6
  29. data/lib/isodoc/presentation_function/math.rb +0 -14
  30. data/lib/isodoc/presentation_function/metadata.rb +0 -62
  31. data/lib/isodoc/presentation_function/refs.rb +44 -14
  32. data/lib/isodoc/presentation_function/reqt.rb +1 -1
  33. data/lib/isodoc/presentation_function/section.rb +46 -121
  34. data/lib/isodoc/presentation_function/sourcecode.rb +7 -4
  35. data/lib/isodoc/presentation_function/terms.rb +27 -2
  36. data/lib/isodoc/presentation_function/title.rb +107 -0
  37. data/lib/isodoc/presentation_function/xrefs.rb +17 -10
  38. data/lib/isodoc/presentation_xml_convert.rb +6 -2
  39. data/lib/isodoc/version.rb +1 -1
  40. data/lib/isodoc/word_function/body.rb +8 -36
  41. data/lib/isodoc/word_function/footnotes.rb +1 -1
  42. data/lib/isodoc/word_function/lists.rb +12 -10
  43. data/lib/isodoc/word_function/postprocess_cover.rb +0 -2
  44. data/lib/isodoc/word_function/postprocess_table.rb +1 -1
  45. data/lib/isodoc/word_function/table.rb +2 -2
  46. data/lib/isodoc/xref/clause_order.rb +2 -2
  47. data/lib/isodoc/xref/xref_anchor.rb +31 -16
  48. data/lib/isodoc/xref/xref_counter_types.rb +3 -2
  49. data/lib/isodoc/xref/xref_gen.rb +57 -33
  50. data/lib/isodoc/xref/xref_gen_seq.rb +145 -56
  51. data/lib/isodoc/xref/xref_sect_gen.rb +64 -47
  52. data/lib/isodoc/xref/xref_util.rb +49 -1
  53. data/lib/isodoc/xref.rb +3 -0
  54. data/lib/isodoc-yaml/i18n-ar.yaml +9 -9
  55. data/lib/isodoc-yaml/i18n-de.yaml +9 -9
  56. data/lib/isodoc-yaml/i18n-en.yaml +9 -9
  57. data/lib/isodoc-yaml/i18n-es.yaml +9 -9
  58. data/lib/isodoc-yaml/i18n-fr.yaml +9 -9
  59. data/lib/isodoc-yaml/i18n-ja.yaml +10 -10
  60. data/lib/isodoc-yaml/i18n-ru.yaml +9 -9
  61. data/lib/isodoc-yaml/i18n-zh-Hans.yaml +9 -9
  62. data/lib/nokogiri/xml/node.rb +1 -0
  63. metadata +9 -6
@@ -7,13 +7,14 @@ module IsoDoc
7
7
  prefix_container(container_container,
8
8
  anchor_xref(node, container, container: true),
9
9
  node, target)
10
- l10n(@i18n.nested_xref.sub("%1", container_label)
11
- .sub("%2", linkend))
10
+ l10n(connectives_spans(@i18n.nested_xref
11
+ .sub("%1", "<span class='fmt-xref-container'>#{container_label}</span>")
12
+ .sub("%2", linkend)))
12
13
  end
13
14
 
14
15
  def anchor_value(id)
15
- @xrefs.anchor(id, :bare_xref) || @xrefs.anchor(id, :value) ||
16
- @xrefs.anchor(id, :label) || @xrefs.anchor(id, :xref)
16
+ @xrefs.anchor(id, :bare_xref) || @xrefs.anchor(id, :label) ||
17
+ @xrefs.anchor(id, :value) || @xrefs.anchor(id, :xref)
17
18
  end
18
19
 
19
20
  def anchor_linkend(node, linkend)
@@ -55,14 +56,15 @@ module IsoDoc
55
56
 
56
57
  def anchor_xref_short(node, target, container)
57
58
  if (l = node["label"]) && !container
58
- @i18n.l10n("#{l} #{anchor_value(target)}")
59
+ v = anchor_value(target)
60
+ @i18n.l10n(%[<span class="fmt-element-name">#{l}</span> #{v}])
59
61
  else @xrefs.anchor(target, :xref)
60
62
  end
61
63
  end
62
64
 
63
65
  def anchor_xref_full(num, title)
64
66
  (!title.nil? && !title.empty?) or return nil
65
- l10n("#{num}, #{title}")
67
+ l10n("#{num}<span class='fmt-comma'>,</span> #{title}")
66
68
  end
67
69
 
68
70
  def prefix_container?(container, node)
@@ -133,9 +135,13 @@ module IsoDoc
133
135
  def combine_conn(list)
134
136
  list.size == 1 and list.first[:label]
135
137
  if list[1..].all? { |l| l[:conn] == "and" }
136
- @i18n.boolean_conj(list.map { |l| loc2xref(l) }, "and")
138
+ connectives_spans(@i18n.boolean_conj(list.map do |l|
139
+ loc2xref(l)
140
+ end, "and"))
137
141
  elsif list[1..].all? { |l| l[:conn] == "or" }
138
- @i18n.boolean_conj(list.map { |l| loc2xref(l) }, "or")
142
+ connectives_spans(@i18n.boolean_conj(list.map do |l|
143
+ loc2xref(l)
144
+ end, "or"))
139
145
  else
140
146
  ret = loc2xref(list[0])
141
147
  list[1..].each { |l| ret = i18n_chain_boolean(ret, l) }
@@ -144,8 +150,9 @@ module IsoDoc
144
150
  end
145
151
 
146
152
  def i18n_chain_boolean(value, entry)
147
- @i18n.send("chain_#{entry[:conn]}").sub("%1", value)
148
- .sub("%2", loc2xref(entry))
153
+ connectives_spans(@i18n.send("chain_#{entry[:conn]}")
154
+ .sub("%1", value)
155
+ .sub("%2", loc2xref(entry)))
149
156
  end
150
157
 
151
158
  def can_conflate_xref_rendering?(locs)
@@ -55,15 +55,16 @@ module IsoDoc
55
55
  # feeds middle_title
56
56
  # triggers xrefs reparse, so put references before all other sections,
57
57
  # which alter titles and thus can alter xrefs
58
- rearrange_clauses docxml # feeds toc, display_order, clausetitle,
58
+ rearrange_clauses docxml # feeds toc, display_order, clausetitle,
59
59
  # clause, middle_title
60
60
  middle_title docxml
61
+ missing_title docxml # feeds clause
61
62
  annex docxml
62
63
  clause docxml # feeds clausetitle
63
64
  term docxml
64
- index docxml
65
65
  clausetitle docxml # feeds floattitle
66
66
  floattitle docxml # feeds rearrange_clauses
67
+ index docxml # fed by strip_duplicate_ids
67
68
  toc docxml
68
69
  display_order docxml
69
70
  end
@@ -78,7 +79,10 @@ module IsoDoc
78
79
  note docxml
79
80
  admonition docxml
80
81
  source docxml
82
+ ul docxml
81
83
  ol docxml
84
+ dl docxml
85
+ quote docxml
82
86
  permission docxml
83
87
  requirement docxml
84
88
  recommendation docxml
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "2.12.0".freeze
2
+ VERSION = "2.12.2".freeze
3
3
  end
@@ -102,40 +102,12 @@ module IsoDoc
102
102
  end
103
103
  end
104
104
 
105
- def note_p_parse(node, div)
106
- name = node.at(ns("./name"))&.remove
107
- div.p class: "Note" do |p|
108
- p.span class: "note_label" do |s|
109
- name&.children&.each { |n| parse(n, s) }
110
- end
111
- insert_tab(p, 1)
112
- node.first_element_child.children.each { |n| parse(n, p) }
113
- end
114
- node.element_children[1..-1].each { |n| parse(n, div) }
105
+ def note_p_class
106
+ "Note"
115
107
  end
116
108
 
117
- def note_parse1(node, div)
118
- name = node.at(ns("./name"))&.remove
119
- div.p class: "Note" do |p|
120
- p.span class: "note_label" do |s|
121
- name&.children&.each { |n| parse(n, s) }
122
- end
123
- insert_tab(p, 1)
124
- end
125
- node.children.each { |n| parse(n, div) }
126
- end
127
-
128
- def termnote_parse(node, out)
129
- name = node&.at(ns("./name"))&.remove
130
- out.div **note_attrs(node) do |div|
131
- div.p class: "Note" do |p|
132
- if name
133
- name.children.each { |n| parse(n, p) }
134
- p << termnote_delim
135
- end
136
- para_then_remainder(node.first_element_child, node, p, div)
137
- end
138
- end
109
+ def termnote_p_class
110
+ "Note"
139
111
  end
140
112
 
141
113
  def para_attrs(node)
@@ -164,8 +136,8 @@ module IsoDoc
164
136
  div.p do |_p|
165
137
  parse(node.at(ns("./stem")), div)
166
138
  insert_tab(div, 1)
167
- if lbl = node&.at(ns("./name"))&.text
168
- div << "(#{lbl})"
139
+ if lbl = node&.at(ns("./fmt-name"))&.text
140
+ div << lbl
169
141
  end
170
142
  end
171
143
  end
@@ -185,10 +157,10 @@ module IsoDoc
185
157
  page_break(out)
186
158
  out.div **attr_code(preface_attrs(clause)) do |div|
187
159
  div.p class: "zzContents" do |p|
188
- clause.at(ns("./title"))&.children&.each { |c| parse(c, p) }
160
+ clause.at(ns("./fmt-title"))&.children&.each { |c| parse(c, p) }
189
161
  end
190
162
  clause.elements.each do |e|
191
- parse(e, div) unless e.name == "title"
163
+ parse(e, div) unless e.name == "fmt-title"
192
164
  end
193
165
  end
194
166
  end
@@ -83,7 +83,7 @@ module IsoDoc
83
83
 
84
84
  def footnote_parse(node, out)
85
85
  return table_footnote_parse(node, out) if (@in_table || @in_figure) &&
86
- !node.ancestors.map(&:name).include?("name")
86
+ !node.ancestors.map(&:name).include?("fmt-name")
87
87
 
88
88
  fn = node["reference"] || UUIDTools::UUID.random_create.to_s
89
89
  return seen_footnote_parse(node, out, fn) if @seen_footnote.include?(fn)
@@ -25,13 +25,13 @@ module IsoDoc
25
25
 
26
26
  def dl_parse_nontable(node, out)
27
27
  out.div **attr_code(class: "figdl") do |div|
28
- node["id"] and bookmark_parse(node, div)
29
- list_title_parse(node, div)
30
- node.elements.select { |n| dt_dd?(n) }
31
- .each_slice(2) do |dt, dd|
32
- dl_parse_nontable1(div, dt, dd)
33
- end
34
- dl_parse_notes(node, div)
28
+ node["id"] and bookmark_parse(node, div)
29
+ list_title_parse(node, div)
30
+ node.elements.select { |n| dt_dd?(n) }
31
+ .each_slice(2) do |dt, dd|
32
+ dl_parse_nontable1(div, dt, dd)
33
+ end
34
+ dl_parse_notes(node, div)
35
35
  end
36
36
  end
37
37
 
@@ -58,13 +58,13 @@ module IsoDoc
58
58
 
59
59
  def ddef_other_paras(out, ddef)
60
60
  ddef.elements&.first&.name == "p" or return
61
- ddef.children[1..-1].each { |n| parse(n, out) }
61
+ ddef.children[1..].each { |n| parse(n, out) }
62
62
  end
63
63
 
64
64
  def dl_parse_table(node, out)
65
65
  list_title_parse(node, out)
66
66
  out.table **attr_code(id: node["id"],
67
- class: (node["class"] || "dl")) do |v|
67
+ class: node["class"] || "dl") do |v|
68
68
  node.elements.select { |n| dt_dd?(n) }
69
69
  .each_slice(2) do |dt, dd|
70
70
  dl_parse_table1(v, dt, dd)
@@ -85,7 +85,9 @@ module IsoDoc
85
85
  end
86
86
 
87
87
  def dl_parse_table_notes(node, out)
88
- remainder = node.elements.reject { |n| dt_dd?(n) || n.name == "name" }
88
+ remainder = node.elements.reject do |n|
89
+ dt_dd?(n) || n.name == "fmt-name"
90
+ end
89
91
  remainder.empty? and return
90
92
  out.tr do |tr|
91
93
  tr.td colspan: 2 do |td|
@@ -22,7 +22,6 @@ module IsoDoc
22
22
  cover = File.read(@wordcoverpage, encoding: "UTF-8")
23
23
  cover = populate_template(cover, :word)
24
24
  coverxml = to_word_xhtml_fragment(cover)
25
- #ins.children.first.previous = coverxml.to_xml(encoding: "US-ASCII")
26
25
  ins.add_first_child coverxml.to_xml(encoding: "US-ASCII")
27
26
  end
28
27
 
@@ -32,7 +31,6 @@ module IsoDoc
32
31
  docxml, level)
33
32
  intro = populate_template(intro, :word)
34
33
  introxml = to_word_xhtml_fragment(intro)
35
- #ins.children.first.previous = introxml.to_xml(encoding: "US-ASCII")
36
34
  ins.add_first_child introxml.to_xml(encoding: "US-ASCII")
37
35
  end
38
36
 
@@ -44,7 +44,7 @@ module IsoDoc
44
44
 
45
45
  def word_nested_tables(docxml)
46
46
  docxml.xpath("//table").each do |t|
47
- t.xpath(".//table").reverse.each do |tt|
47
+ t.xpath(".//table").reverse_each do |tt|
48
48
  t.next = tt.remove
49
49
  end
50
50
  end
@@ -34,7 +34,7 @@ module IsoDoc
34
34
  def make_tr_attr_style(cell, row, rowmax, totalrows, opt)
35
35
  top = row.zero? ? "#{SW1} 1.5pt;" : "none;"
36
36
  bottom = "#{SW1} #{rowmax >= totalrows ? '1.5' : '1.0'}pt;"
37
- ret = <<~STYLE.gsub(/\n/, "")
37
+ ret = <<~STYLE.delete("\n")
38
38
  border-top:#{top}mso-border-top-alt:#{top}
39
39
  border-bottom:#{bottom}mso-border-bottom-alt:#{bottom}
40
40
  STYLE
@@ -46,7 +46,7 @@ module IsoDoc
46
46
  def keep_rows_together(_cell, rowmax, totalrows, opt)
47
47
  opt[:header] and return true
48
48
  @table_line_count > 15 and return false
49
- (totalrows <= 10 && rowmax < totalrows)
49
+ totalrows <= 10 && rowmax < totalrows
50
50
  end
51
51
 
52
52
  def tbody_parse(node, table)
@@ -17,10 +17,10 @@ module IsoDoc
17
17
  { path: "//sections/clause[@type = 'scope']" },
18
18
  { path: @klass.norm_ref_xpath },
19
19
  { path: "//sections/terms | " \
20
- "//sections/clause[descendant::terms]" },
20
+ "//sections/clause[descendant::terms]", multi: true },
21
21
  { path: "//sections/definitions | " \
22
22
  "//sections/clause[descendant::definitions]" \
23
- "[not(descendant::terms)]" },
23
+ "[not(descendant::terms)]", multi: true },
24
24
  { path: @klass.middle_clause(docxml), multi: true },
25
25
  ]
26
26
  end
@@ -1,4 +1,5 @@
1
1
  require "singleton"
2
+ require_relative "xref_util"
2
3
 
3
4
  module IsoDoc
4
5
  module XrefGen
@@ -29,37 +30,51 @@ module IsoDoc
29
30
  @anchors
30
31
  end
31
32
 
32
- def anchor_struct_label(lbl, elem)
33
+ def anchor_struct_label(lbl, node, elem)
33
34
  case elem
34
- when @labels["appendix"] then "#{elem} #{lbl}"
35
+ when @labels["appendix"]
36
+ s = "<semx element='autonum' source='#{node['id'] || node[:id]}'>" \
37
+ "#{lbl}</semx>"
38
+ "<span class='fmt-element-name'>#{elem}</span> #{s}"
35
39
  else
36
- lbl.to_s
40
+ anchor_struct_value(lbl, elem)
37
41
  end
38
42
  end
39
43
 
40
- def anchor_struct_xref(lbl, elem)
41
- l10n("#{elem} #{anchor_struct_value(lbl, elem)}")
44
+ def anchor_struct_xref(lbl, node, elem)
45
+ unless lbl.blank?
46
+ lbl = semx(node, lbl)
47
+ s = " #{anchor_struct_value(lbl, elem)}"
48
+ end
49
+ l10n("<span class='fmt-element-name'>#{elem}</span>#{s}")
50
+ .gsub(/ $/, "")
42
51
  end
43
52
 
44
53
  def anchor_struct_value(lbl, elem)
45
54
  case elem
46
- when @labels["formula"], @labels["inequality"] then "(#{lbl})"
55
+ # TODO hardcoded ( ) ?
56
+ when @labels["formula"], @labels["inequality"] then <<~SPAN.strip
57
+ #{delim_wrap('(')}#{lbl}#{delim_wrap(')')}
58
+ SPAN
47
59
  else
48
- lbl
60
+ lbl.to_s
49
61
  end
50
62
  end
51
63
 
52
- def anchor_struct(lbl, container, elem, type, unnumb = false)
53
- ret = {}
54
- ret[:label] = unnumb == "true" ? nil : anchor_struct_label(lbl, elem)
55
- ret[:xref] = anchor_struct_xref(unnumb == "true" ? "(??)" : lbl, elem)
56
- ret[:xref].gsub!(/ $/, "")
57
- ret[:container] = @klass.get_clause_id(container) unless container.nil?
58
- ret[:type] = type
59
- ret[:elem] = elem
60
- ret[:value] = anchor_struct_value(lbl, elem)
64
+ # def anchor_struct(lbl, container, elem, type, unnumb = false)
65
+ def anchor_struct(lbl, node, elem_name, type, opt = {})
66
+ ret = { type: type, elem: elem_name, label: nil }
67
+ opt[:unnumb] != "true" and
68
+ ret[:label] = anchor_struct_label(lbl, node, elem_name)
69
+ ret[:xref] =
70
+ anchor_struct_xref(opt[:unnumb] == "true" ? "(??)" : lbl, node,
71
+ elem_name)
72
+ ret[:container] = @klass.get_clause_id(node) if opt[:container]
73
+ ret[:value] = stripsemx(lbl)
61
74
  ret
62
75
  end
76
+
77
+ include ::IsoDoc::XrefGen::Util
63
78
  end
64
79
  end
65
80
  end
@@ -2,11 +2,12 @@ require_relative "xref_counter"
2
2
 
3
3
  module IsoDoc
4
4
  class Xref
5
- def clause_counter(num = 0, opts = { numerals: :arabic })
5
+ def clause_counter(num = 0, opts = {})
6
+ opts[:numerals] ||= :arabic
6
7
  ::IsoDoc::XrefGen::Counter.new(num, opts)
7
8
  end
8
9
 
9
- def list_counter(num = 0, opts = { numerals: :arabic })
10
+ def list_counter(num = 0, opts = {})
10
11
  ::IsoDoc::XrefGen::Counter.new(num, opts)
11
12
  end
12
13
  end
@@ -28,14 +28,18 @@ module IsoDoc
28
28
  autonum
29
29
  end
30
30
 
31
- def termnote_label(note)
32
- @labels["termnote"].gsub("%", note.to_s)
31
+ def termnote_label(node, label)
32
+ if label.blank?
33
+ @labels["termnote"].gsub(/%\s?/, "")
34
+ else
35
+ @labels["termnote"].gsub("%", semx(node, label.to_s))
36
+ end
33
37
  end
34
38
 
35
39
  def increment_label(elems, node, counter, increment: true)
36
40
  elems.size == 1 && !node["number"] and return ""
37
41
  counter.increment(node) if increment
38
- " #{counter.print}"
42
+ counter.print
39
43
  end
40
44
 
41
45
  def termnote_anchor_names(docxml)
@@ -44,10 +48,10 @@ module IsoDoc
44
48
  t.xpath(ns("./termnote")).noblank.each do |n|
45
49
  c.increment(n)
46
50
  @anchors[n["id"]] =
47
- { label: termnote_label(c.print), type: "termnote",
51
+ { label: termnote_label(n, c.print), type: "termnote",
48
52
  value: c.print, elem: @labels["termnote"],
49
53
  container: t["id"],
50
- xref: "#{@labels['note_xref']} #{c.print}" }
54
+ xref: anchor_struct_xref(c.print, n, @labels["note_xref"]) }
51
55
  end
52
56
  end
53
57
  end
@@ -63,7 +67,7 @@ module IsoDoc
63
67
  { label: idx, type: "termexample",
64
68
  value: idx, elem: @labels["example_xref"],
65
69
  container: t["id"],
66
- xref: "#{@labels['example_xref']} #{idx}" }
70
+ xref: anchor_struct_xref(idx, n, @labels["example_xref"]) }
67
71
  end
68
72
  end
69
73
  end
@@ -73,7 +77,7 @@ module IsoDoc
73
77
  notes = s.xpath(child_asset_path("note")) -
74
78
  s.xpath(ns(".//figure//note | .//table//note"))
75
79
  note_anchor_names1(notes, Counter.new)
76
- note_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
80
+ note_anchor_names(s.xpath(ns(child_sections)))
77
81
  end
78
82
  end
79
83
 
@@ -81,7 +85,8 @@ module IsoDoc
81
85
  notes.noblank.each do |n|
82
86
  @anchors[n["id"]] =
83
87
  anchor_struct(increment_label(notes, n, counter), n,
84
- @labels["note_xref"], "note", false)
88
+ @labels["note_xref"], "note",
89
+ { container: true, unnumb: false })
85
90
  end
86
91
  end
87
92
 
@@ -90,7 +95,7 @@ module IsoDoc
90
95
  s.at(ns(".//admonition[@type = 'box']")) or next
91
96
  notes = s.xpath(child_asset_path("admonition[@type = 'box']"))
92
97
  admonition_anchor_names1(notes, Counter.new)
93
- admonition_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
98
+ admonition_anchor_names(s.xpath(ns(child_sections)))
94
99
  end
95
100
  end
96
101
 
@@ -98,7 +103,8 @@ module IsoDoc
98
103
  notes.noblank.each do |n|
99
104
  @anchors[n["id"]] ||=
100
105
  anchor_struct(increment_label(notes, n, counter), n,
101
- @labels["box"], "admonition", n["unnumbered"])
106
+ @labels["box"], "admonition",
107
+ { container: true, unnumb: n["unnumbered"] })
102
108
  end
103
109
  end
104
110
 
@@ -106,7 +112,7 @@ module IsoDoc
106
112
  sections.each do |s|
107
113
  notes = s.xpath(child_asset_path("example"))
108
114
  example_anchor_names1(notes, Counter.new)
109
- example_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
115
+ example_anchor_names(s.xpath(ns(child_sections)))
110
116
  end
111
117
  end
112
118
 
@@ -114,7 +120,8 @@ module IsoDoc
114
120
  notes.noblank.each do |n|
115
121
  @anchors[n["id"]] ||=
116
122
  anchor_struct(increment_label(notes, n, counter), n,
117
- @labels["example_xref"], "example", n["unnumbered"])
123
+ @labels["example_xref"], "example",
124
+ { unnumb: n["unnumbered"], container: true })
118
125
  end
119
126
  end
120
127
 
@@ -122,27 +129,35 @@ module IsoDoc
122
129
  sections.each do |s|
123
130
  notes = s.xpath(ns(".//ol")) - s.xpath(ns(".//clause//ol")) -
124
131
  s.xpath(ns(".//appendix//ol")) - s.xpath(ns(".//ol//ol"))
125
- c = list_counter
132
+ c = list_counter(0, {})
126
133
  notes.noblank.each do |n|
127
- @anchors[n["id"]] = anchor_struct(increment_label(notes, n, c), n,
128
- @labels["list"], "list", false)
134
+ @anchors[n["id"]] =
135
+ anchor_struct(increment_label(notes, n, c), n,
136
+ @labels["list"], "list",
137
+ { unnumb: false, container: true })
129
138
  list_item_anchor_names(n, @anchors[n["id"]], 1, "", notes.size != 1)
130
139
  end
131
- list_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
140
+ list_anchor_names(s.xpath(ns(child_sections)))
132
141
  end
133
142
  end
134
143
 
135
- def list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list)
136
- c = list_counter(list["start"] ? list["start"].to_i - 1 : 0)
144
+ def list_item_delim
145
+ ")"
146
+ end
147
+
148
+ def list_item_anchor_names(list, list_anchor, depth, prev_label,
149
+ refer_list)
150
+ c = list_counter(list["start"] ? list["start"].to_i - 1 : 0, {})
137
151
  list.xpath(ns("./li")).each do |li|
138
152
  bare_label, label =
139
- list_item_value(li, c, depth, { list_anchor:, prev_label:,
140
- refer_list: depth == 1 ? refer_list : nil })
141
- li["id"] and @anchors[li["id"]] =
142
- { label: bare_label, bare_xref: "#{label})",
143
- xref: "#{label})",
144
- type: "listitem", refer_list:,
145
- container: list_anchor[:container] }
153
+ list_item_value(li, c, depth,
154
+ { list_anchor:, prev_label:,
155
+ refer_list: depth == 1 ? refer_list : nil })
156
+ li["id"] ||= "_#{UUIDTools::UUID.random_create}"
157
+ @anchors[li["id"]] =
158
+ { label: bare_label, bare_xref: "#{label})", type: "listitem",
159
+ xref: %[#{label}#{delim_wrap(list_item_delim)}], refer_list:,
160
+ container: list_anchor[:container] }
146
161
  (li.xpath(ns(".//ol")) - li.xpath(ns(".//ol//ol"))).each do |ol|
147
162
  list_item_anchor_names(ol, list_anchor, depth + 1, label,
148
163
  refer_list)
@@ -152,18 +167,21 @@ module IsoDoc
152
167
 
153
168
  def list_item_value(entry, counter, depth, opts)
154
169
  label = counter.increment(entry).listlabel(entry.parent, depth)
170
+ s = semx(entry, label)
155
171
  [label,
156
- list_item_anchor_label(label, opts[:list_anchor], opts[:prev_label],
172
+ list_item_anchor_label(s, opts[:list_anchor], opts[:prev_label],
157
173
  opts[:refer_list])]
158
174
  end
159
175
 
160
176
  def list_item_anchor_label(label, list_anchor, prev_label, refer_list)
161
177
  prev_label.empty? or
162
- label = @i18n.list_nested_xref.sub("%1", "#{prev_label})")
163
- .sub("%2", label)
178
+ label = @klass.connectives_spans(@i18n.list_nested_xref
179
+ .sub("%1", %[#{prev_label}#{delim_wrap(list_item_delim)}])
180
+ .sub("%2", label))
164
181
  refer_list and
165
- label = @i18n.list_nested_xref.sub("%1", list_anchor[:xref])
166
- .sub("%2", label)
182
+ label = @klass.connectives_spans(@i18n.list_nested_xref
183
+ .sub("%1", list_anchor[:xref])
184
+ .sub("%2", label))
167
185
  label
168
186
  end
169
187
 
@@ -172,7 +190,7 @@ module IsoDoc
172
190
  notes = s.xpath(ns(".//dl")) - s.xpath(ns(".//clause//dl")) -
173
191
  s.xpath(ns(".//appendix//dl")) - s.xpath(ns(".//dl//dl"))
174
192
  deflist_anchor_names1(notes, Counter.new)
175
- deflist_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
193
+ deflist_anchor_names(s.xpath(ns(child_sections)))
176
194
  end
177
195
  end
178
196
 
@@ -180,14 +198,15 @@ module IsoDoc
180
198
  notes.noblank.each do |n|
181
199
  @anchors[n["id"]] =
182
200
  anchor_struct(increment_label(notes, n, counter), n,
183
- @labels["deflist"], "deflist", false)
201
+ @labels["deflist"], "deflist",
202
+ { unnumb: false, container: true })
184
203
  deflist_term_anchor_names(n, @anchors[n["id"]])
185
204
  end
186
205
  end
187
206
 
188
207
  def deflist_term_anchor_names(list, list_anchor)
189
208
  list.xpath(ns("./dt")).each do |li|
190
- label = "#{list_anchor[:xref]}: #{dt2xreflabel(li)}"
209
+ label = deflist_term_anchor_lbl(li, list_anchor)
191
210
  li["id"] and @anchors[li["id"]] =
192
211
  { xref: label, type: "deflistitem",
193
212
  container: list_anchor[:container] }
@@ -197,6 +216,11 @@ module IsoDoc
197
216
  end
198
217
  end
199
218
 
219
+ def deflist_term_anchor_lbl(listitem, list_anchor)
220
+ s = semx(listitem, dt2xreflabel(listitem))
221
+ %(#{list_anchor[:xref]}#{delim_wrap(":")} #{s}</semx>)
222
+ end
223
+
200
224
  def dt2xreflabel(dterm)
201
225
  label = dterm.dup
202
226
  label.xpath(ns(".//p")).each { |x| x.replace(x.children) }