isodoc 2.10.0 → 3.0.0

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 (83) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/isodoc.gemspec +9 -4
  4. data/lib/isodoc/base_style/all.css +96 -0
  5. data/lib/isodoc/base_style/reset.css +96 -0
  6. data/lib/isodoc/base_style/reset.scss +75 -0
  7. data/lib/isodoc/base_style/scripts.html +45 -14
  8. data/lib/isodoc/class_utils.rb +4 -2
  9. data/lib/isodoc/convert.rb +0 -21
  10. data/lib/isodoc/css.rb +2 -4
  11. data/lib/isodoc/function/blocks.rb +37 -52
  12. data/lib/isodoc/function/blocks_example_note.rb +75 -29
  13. data/lib/isodoc/function/cleanup.rb +9 -44
  14. data/lib/isodoc/function/inline.rb +67 -13
  15. data/lib/isodoc/function/lists.rb +20 -14
  16. data/lib/isodoc/function/references.rb +9 -126
  17. data/lib/isodoc/function/reqt.rb +4 -3
  18. data/lib/isodoc/function/section.rb +30 -35
  19. data/lib/isodoc/function/section_titles.rb +22 -11
  20. data/lib/isodoc/function/table.rb +3 -3
  21. data/lib/isodoc/function/terms.rb +49 -26
  22. data/lib/isodoc/function/to_word_html.rb +46 -16
  23. data/lib/isodoc/function/utils.rb +11 -12
  24. data/lib/isodoc/gem_tasks.rb +1 -1
  25. data/lib/isodoc/html_function/footnotes.rb +2 -1
  26. data/lib/isodoc/html_function/html.rb +5 -7
  27. data/lib/isodoc/html_function/postprocess.rb +25 -6
  28. data/lib/isodoc/html_function/postprocess_cover.rb +13 -7
  29. data/lib/isodoc/html_function/postprocess_footnotes.rb +52 -47
  30. data/lib/isodoc/init.rb +31 -0
  31. data/lib/isodoc/metadata.rb +20 -13
  32. data/lib/isodoc/metadata_contributor.rb +5 -10
  33. data/lib/isodoc/metadata_date.rb +1 -1
  34. data/lib/isodoc/presentation_function/autonum.rb +153 -0
  35. data/lib/isodoc/presentation_function/bibdata.rb +4 -5
  36. data/lib/isodoc/presentation_function/block.rb +107 -40
  37. data/lib/isodoc/presentation_function/concepts.rb +184 -19
  38. data/lib/isodoc/presentation_function/docid.rb +78 -0
  39. data/lib/isodoc/presentation_function/erefs.rb +55 -31
  40. data/lib/isodoc/presentation_function/image.rb +64 -19
  41. data/lib/isodoc/presentation_function/index.rb +180 -0
  42. data/lib/isodoc/presentation_function/inline.rb +47 -16
  43. data/lib/isodoc/presentation_function/math.rb +128 -71
  44. data/lib/isodoc/presentation_function/metadata.rb +29 -66
  45. data/lib/isodoc/presentation_function/refs.rb +75 -28
  46. data/lib/isodoc/presentation_function/reqt.rb +7 -4
  47. data/lib/isodoc/presentation_function/section.rb +51 -129
  48. data/lib/isodoc/presentation_function/sourcecode.rb +52 -19
  49. data/lib/isodoc/presentation_function/terms.rb +107 -118
  50. data/lib/isodoc/presentation_function/title.rb +107 -0
  51. data/lib/isodoc/presentation_function/xrefs.rb +37 -17
  52. data/lib/isodoc/presentation_xml_convert.rb +24 -10
  53. data/lib/isodoc/version.rb +1 -1
  54. data/lib/isodoc/word_function/body.rb +9 -37
  55. data/lib/isodoc/word_function/comments.rb +0 -1
  56. data/lib/isodoc/word_function/footnotes.rb +1 -1
  57. data/lib/isodoc/word_function/lists.rb +13 -9
  58. data/lib/isodoc/word_function/postprocess.rb +6 -0
  59. data/lib/isodoc/word_function/postprocess_cover.rb +6 -4
  60. data/lib/isodoc/word_function/postprocess_table.rb +1 -1
  61. data/lib/isodoc/word_function/postprocess_toc.rb +10 -6
  62. data/lib/isodoc/word_function/table.rb +2 -2
  63. data/lib/isodoc/xref/clause_order.rb +41 -0
  64. data/lib/isodoc/xref/xref_anchor.rb +31 -16
  65. data/lib/isodoc/xref/xref_counter.rb +18 -3
  66. data/lib/isodoc/xref/xref_counter_types.rb +14 -0
  67. data/lib/isodoc/xref/xref_gen.rb +61 -37
  68. data/lib/isodoc/xref/xref_gen_seq.rb +148 -81
  69. data/lib/isodoc/xref/xref_sect_gen.rb +84 -88
  70. data/lib/isodoc/xref/xref_util.rb +53 -4
  71. data/lib/isodoc/xref.rb +29 -10
  72. data/lib/isodoc/xslfo_convert.rb +14 -9
  73. data/lib/isodoc-yaml/i18n-ar.yaml +17 -13
  74. data/lib/isodoc-yaml/i18n-de.yaml +17 -13
  75. data/lib/isodoc-yaml/i18n-en.yaml +18 -17
  76. data/lib/isodoc-yaml/i18n-es.yaml +17 -13
  77. data/lib/isodoc-yaml/i18n-fr.yaml +17 -13
  78. data/lib/isodoc-yaml/i18n-ja.yaml +56 -52
  79. data/lib/isodoc-yaml/i18n-ru.yaml +17 -16
  80. data/lib/isodoc-yaml/i18n-zh-Hans.yaml +17 -13
  81. data/lib/nokogiri/xml/node.rb +14 -0
  82. data/lib/relaton/render-isodoc/config.yml +1 -1
  83. metadata +90 -13
@@ -28,15 +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
- return "" if elems.size == 1 && !node["number"]
37
-
40
+ elems.size == 1 && !node["number"] and return ""
38
41
  counter.increment(node) if increment
39
- " #{counter.print}"
42
+ counter.print
40
43
  end
41
44
 
42
45
  def termnote_anchor_names(docxml)
@@ -45,10 +48,10 @@ module IsoDoc
45
48
  t.xpath(ns("./termnote")).noblank.each do |n|
46
49
  c.increment(n)
47
50
  @anchors[n["id"]] =
48
- { label: termnote_label(c.print), type: "termnote",
51
+ { label: termnote_label(n, c.print), type: "termnote",
49
52
  value: c.print, elem: @labels["termnote"],
50
53
  container: t["id"],
51
- xref: l10n("#{@labels['note_xref']} #{c.print}") }
54
+ xref: anchor_struct_xref(c.print, n, @labels["note_xref"]) }
52
55
  end
53
56
  end
54
57
  end
@@ -64,7 +67,7 @@ module IsoDoc
64
67
  { label: idx, type: "termexample",
65
68
  value: idx, elem: @labels["example_xref"],
66
69
  container: t["id"],
67
- xref: l10n("#{@labels['example_xref']} #{idx}") }
70
+ xref: anchor_struct_xref(idx, n, @labels["example_xref"]) }
68
71
  end
69
72
  end
70
73
  end
@@ -74,7 +77,7 @@ module IsoDoc
74
77
  notes = s.xpath(child_asset_path("note")) -
75
78
  s.xpath(ns(".//figure//note | .//table//note"))
76
79
  note_anchor_names1(notes, Counter.new)
77
- note_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
80
+ note_anchor_names(s.xpath(ns(child_sections)))
78
81
  end
79
82
  end
80
83
 
@@ -82,7 +85,8 @@ module IsoDoc
82
85
  notes.noblank.each do |n|
83
86
  @anchors[n["id"]] =
84
87
  anchor_struct(increment_label(notes, n, counter), n,
85
- @labels["note_xref"], "note", false)
88
+ @labels["note_xref"], "note",
89
+ { container: true, unnumb: false })
86
90
  end
87
91
  end
88
92
 
@@ -91,7 +95,7 @@ module IsoDoc
91
95
  s.at(ns(".//admonition[@type = 'box']")) or next
92
96
  notes = s.xpath(child_asset_path("admonition[@type = 'box']"))
93
97
  admonition_anchor_names1(notes, Counter.new)
94
- admonition_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
98
+ admonition_anchor_names(s.xpath(ns(child_sections)))
95
99
  end
96
100
  end
97
101
 
@@ -99,7 +103,8 @@ module IsoDoc
99
103
  notes.noblank.each do |n|
100
104
  @anchors[n["id"]] ||=
101
105
  anchor_struct(increment_label(notes, n, counter), n,
102
- @labels["box"], "admonition", n["unnumbered"])
106
+ @labels["box"], "admonition",
107
+ { container: true, unnumb: n["unnumbered"] })
103
108
  end
104
109
  end
105
110
 
@@ -107,7 +112,7 @@ module IsoDoc
107
112
  sections.each do |s|
108
113
  notes = s.xpath(child_asset_path("example"))
109
114
  example_anchor_names1(notes, Counter.new)
110
- example_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
115
+ example_anchor_names(s.xpath(ns(child_sections)))
111
116
  end
112
117
  end
113
118
 
@@ -115,7 +120,8 @@ module IsoDoc
115
120
  notes.noblank.each do |n|
116
121
  @anchors[n["id"]] ||=
117
122
  anchor_struct(increment_label(notes, n, counter), n,
118
- @labels["example_xref"], "example", n["unnumbered"])
123
+ @labels["example_xref"], "example",
124
+ { unnumb: n["unnumbered"], container: true })
119
125
  end
120
126
  end
121
127
 
@@ -123,47 +129,59 @@ module IsoDoc
123
129
  sections.each do |s|
124
130
  notes = s.xpath(ns(".//ol")) - s.xpath(ns(".//clause//ol")) -
125
131
  s.xpath(ns(".//appendix//ol")) - s.xpath(ns(".//ol//ol"))
126
- c = Counter.new
132
+ c = list_counter(0, {})
127
133
  notes.noblank.each do |n|
128
- @anchors[n["id"]] = anchor_struct(increment_label(notes, n, c), n,
129
- @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 })
130
138
  list_item_anchor_names(n, @anchors[n["id"]], 1, "", notes.size != 1)
131
139
  end
132
- list_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
140
+ list_anchor_names(s.xpath(ns(child_sections)))
133
141
  end
134
142
  end
135
143
 
136
- def list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list)
137
- c = Counter.new(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, {})
138
151
  list.xpath(ns("./li")).each do |li|
139
152
  bare_label, label =
140
- list_item_value(li, c, depth, { list_anchor: list_anchor, prev_label: prev_label,
141
- refer_list: depth == 1 ? refer_list : nil })
142
- li["id"] and @anchors[li["id"]] =
143
- { label: bare_label, bare_xref: "#{label})",
144
- xref: "#{label})",
145
- type: "listitem", refer_list: refer_list,
146
- 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] }
147
161
  (li.xpath(ns(".//ol")) - li.xpath(ns(".//ol//ol"))).each do |ol|
148
- list_item_anchor_names(ol, list_anchor, depth + 1, label, refer_list)
162
+ list_item_anchor_names(ol, list_anchor, depth + 1, label,
163
+ refer_list)
149
164
  end
150
165
  end
151
166
  end
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 = l10n("#{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) }
@@ -227,7 +251,7 @@ module IsoDoc
227
251
  def bookmark_anchor_names(xml)
228
252
  xml.xpath(ns(".//bookmark")).noblank.each do |n|
229
253
  _parent, id = id_ancestor(n)
230
- #container = bookmark_container(parent)
254
+ # container = bookmark_container(parent)
231
255
  @anchors[n["id"]] = { type: "bookmark", label: nil, value: nil,
232
256
  xref: @anchors.dig(id, :xref) || "???",
233
257
  container: @anchors.dig(id, :container) }
@@ -11,6 +11,10 @@ module IsoDoc
11
11
  "-"
12
12
  end
13
13
 
14
+ def hierreqtsep
15
+ "-"
16
+ end
17
+
14
18
  def subfigure_increment(idx, counter, elem)
15
19
  if elem.parent.name == "figure" then idx += 1
16
20
  else
@@ -27,11 +31,13 @@ module IsoDoc
27
31
  def sequential_figure_names(clause, container: false)
28
32
  c = Counter.new
29
33
  j = 0
30
- clause.xpath(ns(FIGURE_NO_CLASS)).noblank.each do |t|
34
+ clause.xpath(ns(self.class::FIGURE_NO_CLASS)).noblank.each do |t|
35
+ # labelled_ancestor(t, %w(figure)) and next # disable nested figure labelling
31
36
  j = subfigure_increment(j, c, t)
32
- sequential_figure_body(j, c, t, "figure", container: container)
37
+ sublabel = subfigure_label(j)
38
+ figure_anchor(t, sublabel, c.print, "figure", container: container)
33
39
  end
34
- sequential_figure_class_names(clause, container: container)
40
+ sequential_figure_class_names(clause, container:)
35
41
  end
36
42
 
37
43
  def sequential_figure_class_names(clause, container: false)
@@ -40,34 +46,81 @@ module IsoDoc
40
46
  clause.xpath(ns(".//figure[@class][not(@class = 'pseudocode')]"))
41
47
  .each do |t|
42
48
  c[t["class"]] ||= Counter.new
49
+ # labelled_ancestor(t, %w(figure)) and next
43
50
  j = subfigure_increment(j, c[t["class"]], t)
44
- sequential_figure_body(j, c[t["class"]], t, t["class"],
45
- container: container)
51
+ sublabel = subfigure_label(j)
52
+ figure_anchor(t, sublabel, c[t["class"]].print, t["class"],
53
+ container: container)
46
54
  end
47
55
  end
48
56
 
57
+ def hier_separator(markup: false)
58
+ h = hiersep
59
+ h.blank? || !markup or h = delim_wrap(h)
60
+ h
61
+ end
62
+
49
63
  def subfigure_label(subfignum)
50
- subfignum.zero? and return ""
51
- "-#{subfignum}"
64
+ subfignum.zero? and return
65
+ subfignum.to_s
66
+ end
67
+
68
+ def subfigure_separator(markup: false)
69
+ h = hierfigsep
70
+ h.blank? || !markup or h = delim_wrap(h)
71
+ h
72
+ end
73
+
74
+ def subreqt_separator(markup: false)
75
+ h = hierreqtsep
76
+ h.blank? || !markup or h = delim_wrap(h)
77
+ h
78
+ end
79
+
80
+ def subfigure_delim
81
+ ""
82
+ end
83
+
84
+ def figure_anchor(elem, sublabel, label, klass, container: false)
85
+ if sublabel
86
+ /<semx/.match?(label) or label = semx(elem.parent, label)
87
+ subfigure_anchor(elem, sublabel, label, klass, container: false)
88
+ else
89
+ @anchors[elem["id"]] = anchor_struct(
90
+ label, elem, @labels[klass] || klass.capitalize, klass,
91
+ { unnumb: elem["unnumbered"], container: }
92
+ )
93
+ end
94
+ end
95
+
96
+ def fig_subfig_label(label, sublabel)
97
+ label && sublabel or return
98
+ "#{label}#{subfigure_separator}#{sublabel}"
52
99
  end
53
100
 
54
- def sequential_figure_body(subfig, counter, elem, klass, container: false)
55
- label = counter.print
56
- label &&= label + subfigure_label(subfig)
101
+ def subfigure_anchor(elem, sublabel, label, klass, container: false)
102
+ figlabel = fig_subfig_label(label, sublabel)
57
103
  @anchors[elem["id"]] = anchor_struct(
58
- label, container ? elem : nil,
59
- @labels[klass] || klass.capitalize, klass,
60
- elem["unnumbered"]
104
+ figlabel, elem, @labels[klass] || klass.capitalize, klass,
105
+ { unnumb: elem["unnumbered"] }
61
106
  )
107
+ if elem["unnumbered"] != "true"
108
+ x = "#{subfigure_separator(markup: true)}#{semx(elem, sublabel)}"
109
+ @anchors[elem["id"]][:label] = "#{label}#{x}" # "#{semx(elem.parent, label)}#{x}"
110
+ @anchors[elem["id"]][:xref] = @anchors[elem.parent["id"]][:xref] + x +
111
+ delim_wrap(subfigure_delim)
112
+ x = @anchors[elem.parent["id"]][:container] and
113
+ @anchors[elem["id"]][:container] = x
114
+ end
62
115
  end
63
116
 
64
117
  def sequential_table_names(clause, container: false)
65
118
  c = Counter.new
66
119
  clause.xpath(ns(".//table")).noblank.each do |t|
67
- labelled_ancestor(t) and next
120
+ # labelled_ancestor(t) and next
68
121
  @anchors[t["id"]] = anchor_struct(
69
- c.increment(t).print, container ? t : nil,
70
- @labels["table"], "table", t["unnumbered"]
122
+ c.increment(t).print, t,
123
+ @labels["table"], "table", { unnumb: t["unnumbered"], container: container }
71
124
  )
72
125
  end
73
126
  end
@@ -78,7 +131,7 @@ module IsoDoc
78
131
  @anchors[t["id"]] = anchor_struct(
79
132
  c.increment(t).print, t,
80
133
  t["inequality"] ? @labels["inequality"] : @labels["formula"],
81
- "formula", t["unnumbered"]
134
+ "formula", { unnumb: t["unnumbered"], container: true }
82
135
  )
83
136
  end
84
137
  end
@@ -93,42 +146,54 @@ module IsoDoc
93
146
  ./permission | ./requirement | ./recommendation
94
147
  XPATH
95
148
 
96
- def sequential_permission_names(clause, container: false)
149
+ def sequential_permission_names(clause, container: true)
97
150
  c = ReqCounter.new
98
151
  clause.xpath(ns(FIRST_LVL_REQ)).noblank.each do |t|
99
152
  m = @reqt_models.model(t["model"])
100
153
  klass, label = reqt2class_label(t, m)
101
154
  id = c.increment(label, t).print
102
- sequential_permission_body(id, t, label, klass, m,
103
- container: container)
104
- sequential_permission_children(t, id, container: container)
155
+ sequential_permission_body(id, nil, t, label, klass, m,
156
+ container:)
157
+ sequential_permission_children(t, id, klass, container:)
105
158
  end
106
159
  end
107
160
 
108
- def sequential_permission_children(elem, lbl, container: false)
161
+ def sequential_permission_children(elem, lbl, klass, container: false)
109
162
  c = ReqCounter.new
110
163
  elem.xpath(ns(REQ_CHILDREN)).noblank.each do |t|
111
164
  m = @reqt_models.model(t["model"])
112
165
  klass, label = reqt2class_nested_label(t, m)
113
- id = "#{lbl}#{hierfigsep}#{c.increment(label, t).print}"
114
- sequential_permission_body(id, t, label, klass, m,
115
- container: container)
116
- sequential_permission_children(t, id, container: container)
166
+ ctr = c.increment(label, t).print
167
+ id = "#{lbl}#{subreqt_separator}#{ctr}"
168
+ sequential_permission_body(ctr, lbl, t, label, klass, m,
169
+ container:)
170
+ sequential_permission_children(t, id, klass, container:)
117
171
  end
118
172
  end
119
173
 
120
- def sequential_permission_body(id, elem, label, klass, model, container: false)
174
+ def sequential_permission_body(id, parent_id, elem, label, klass, model,
175
+ container: false)
176
+ lbl = parent_id ? "#{parent_id}#{subreqt_separator}#{id}" : id
121
177
  @anchors[elem["id"]] = model.postprocess_anchor_struct(
122
- elem, anchor_struct(id, elem,
123
- label, klass, elem["unnumbered"])
178
+ elem, anchor_struct(lbl, elem,
179
+ label, klass, { unnumb: elem["unnumbered"], container: })
124
180
  )
181
+ @anchors[elem["id"]][:semx] = semx(elem, lbl)
182
+ if parent_id
183
+ x = "#{subreqt_separator(markup: true)}#{semx(elem, id)}"
184
+ @anchors[elem["id"]][:semx] = @anchors[elem.parent["id"]][:semx] + x
185
+ @anchors[elem["id"]][:label] =
186
+ "<span class='fmt-element-name'>#{label}</span> #{@anchors[elem["id"]][:semx]}"
187
+ @anchors[elem["id"]][:xref] = "<span class='fmt-element-name'>#{label}</span> #{@anchors[elem["id"]][:semx]}"
188
+ end
125
189
  model.permission_parts(elem, id, label, klass).each do |n|
126
190
  @anchors[n[:id]] = anchor_struct(n[:number], n[:elem], n[:label],
127
- n[:klass], false)
191
+ n[:klass], { unnumb: false, container: })
128
192
  end
129
193
  end
130
194
 
131
195
  def reqt2class_label(elem, model)
196
+ elem["class"] and return [elem["class"], elem["class"]]
132
197
  model.req_class_paths.each do |n|
133
198
  v1 = ns("/#{n[:xpath]}").sub(%r{^/}, "")
134
199
  elem.at("./self::#{v1}") and return [n[:klass], n[:label]]
@@ -146,49 +211,67 @@ module IsoDoc
146
211
 
147
212
  # container makes numbering be prefixed with the parent clause reference
148
213
  def sequential_asset_names(clause, container: false)
149
- sequential_table_names(clause, container: container)
150
- sequential_figure_names(clause, container: container)
151
- sequential_formula_names(clause, container: container)
152
- sequential_permission_names(clause, container: container)
214
+ sequential_table_names(clause, container:)
215
+ sequential_figure_names(clause, container:)
216
+ sequential_formula_names(clause, container:)
217
+ sequential_permission_names(clause, container:)
153
218
  end
154
219
 
155
- def hierarchical_figure_names(clause, num)
220
+ def nodeSet(clauses)
221
+ case clauses
222
+ when Nokogiri::XML::Node
223
+ [clauses]
224
+ when Nokogiri::XML::NodeSet
225
+ clauses
226
+ end
227
+ end
228
+
229
+ # these can take a NodeSet as argument; semx will point to members of the NodeSet,
230
+ # but numbering will be consecutive
231
+ def hierarchical_figure_names(clauses, num)
156
232
  c = Counter.new
157
233
  j = 0
158
- clause.xpath(ns(FIGURE_NO_CLASS)).noblank.each do |t|
159
- # next if labelled_ancestor(t) && t.ancestors("figure").empty?
234
+ nodeSet(clauses).each do |clause|
235
+ clause.xpath(ns(self.class::FIGURE_NO_CLASS)).noblank.each do |t|
236
+ # labelled_ancestor(t, %w(figure)) and next
160
237
  j = subfigure_increment(j, c, t)
161
- hierarchical_figure_body(num, j, c, t, "figure")
238
+ sublabel = subfigure_label(j)
239
+ # hierarchical_figure_body(num, j, c, t, "figure")
240
+ #figure_anchor(t, sublabel, "#{num}#{hier_separator}#{c.print}", "figure")
241
+ #require "debug"; binding.b
242
+ figure_anchor(t, sublabel, hiersemx(clause, num, c, t), "figure")
162
243
  end
163
244
  hierarchical_figure_class_names(clause, num)
245
+ end
164
246
  end
165
247
 
166
- def hierarchical_figure_class_names(clause, num)
248
+ def hierarchical_figure_class_names(clauses, num)
167
249
  c = {}
168
250
  j = 0
251
+ nodeSet(clauses).each do |clause|
169
252
  clause.xpath(ns(".//figure[@class][not(@class = 'pseudocode')]"))
170
253
  .noblank.each do |t|
254
+ # labelled_ancestor(t, %w(figure)) and next
171
255
  c[t["class"]] ||= Counter.new
172
256
  j = subfigure_increment(j, c[t["class"]], t)
173
- hierarchical_figure_body(num, j, c[t["class"]], t, t["class"])
257
+ sublabel = subfigure_label(j)
258
+ # hierarchical_figure_body(num, j, c[t["class"]], t, t["class"])
259
+ #figure_anchor(t, sublabel, "#{num}#{hier_separator}#{c[t['class']].print}", t["class"])
260
+ figure_anchor(t, sublabel, hiersemx(clause, num, c[t["class"]], t), t["class"])
261
+ end
174
262
  end
175
263
  end
176
264
 
177
- def hierarchical_figure_body(num, subfignum, counter, block, klass)
178
- label = "#{num}#{hiersep}#{counter.print}" +
179
- subfigure_label(subfignum)
180
- @anchors[block["id"]] =
181
- anchor_struct(label, nil, @labels[klass] || klass.capitalize,
182
- klass, block["unnumbered"])
183
- end
184
-
185
- def hierarchical_table_names(clause, num)
265
+ def hierarchical_table_names(clauses, num)
186
266
  c = Counter.new
267
+ nodeSet(clauses).each do |clause|
187
268
  clause.xpath(ns(".//table")).noblank.each do |t|
188
- labelled_ancestor(t) and next
269
+ # labelled_ancestor(t) and next
189
270
  @anchors[t["id"]] =
190
- anchor_struct("#{num}#{hiersep}#{c.increment(t).print}",
191
- nil, @labels["table"], "table", t["unnumbered"])
271
+ #anchor_struct("#{num}#{hier_separator}#{c.increment(t).print}",
272
+ anchor_struct(hiersemx(clause, num, c.increment(t), t),
273
+ t, @labels["table"], "table", { unnumb: t["unnumbered"], container: false })
274
+ end
192
275
  end
193
276
  end
194
277
 
@@ -199,48 +282,32 @@ module IsoDoc
199
282
  hierarchical_permission_names(clause, num)
200
283
  end
201
284
 
202
- def hierarchical_formula_names(clause, num)
285
+ def hierarchical_formula_names(clauses, num)
203
286
  c = Counter.new
287
+ nodeSet(clauses).each do |clause|
204
288
  clause.xpath(ns(".//formula")).noblank.each do |t|
205
289
  @anchors[t["id"]] = anchor_struct(
206
- "#{num}#{hiersep}#{c.increment(t).print}", nil,
290
+ #"#{num}#{hier_separator}#{c.increment(t).print}", t,
291
+ hiersemx(clause, num, c.increment(t), t), t,
207
292
  t["inequality"] ? @labels["inequality"] : @labels["formula"],
208
- "formula", t["unnumbered"]
293
+ "formula", { unnumb: t["unnumbered"], container: false }
209
294
  )
210
295
  end
296
+ end
211
297
  end
212
298
 
213
- def hierarchical_permission_names(clause, num)
299
+ def hierarchical_permission_names(clauses, num)
214
300
  c = ReqCounter.new
301
+ nodeSet(clauses).each do |clause|
215
302
  clause.xpath(ns(FIRST_LVL_REQ)).noblank.each do |t|
216
303
  m = @reqt_models.model(t["model"])
217
304
  klass, label = reqt2class_label(t, m)
218
- id = "#{num}#{hiersep}#{c.increment(label, t).print}"
219
- hierarchical_permission_body(id, t, label, klass, m)
220
- hierarchical_permission_children(t, id)
221
- end
222
- end
223
-
224
- def hierarchical_permission_children(block, lbl)
225
- c = ReqCounter.new
226
- block.xpath(ns(REQ_CHILDREN)).noblank.each do |t|
227
- m = @reqt_models.model(t["model"])
228
- klass, label = reqt2class_nested_label(t, m)
229
- id = "#{lbl}#{hierfigsep}#{c.increment(label, t).print}"
230
- hierarchical_permission_body(id, t, label, klass, m)
231
- hierarchical_permission_children(t, id)
232
- end
233
- end
234
-
235
- def hierarchical_permission_body(id, block, label, klass, model)
236
- @anchors[block["id"]] = model.postprocess_anchor_struct(
237
- block, anchor_struct(id, nil,
238
- label, klass, block["unnumbered"])
239
- )
240
- model.permission_parts(block, id, label, klass).each do |n|
241
- @anchors[n[:id]] = anchor_struct(n[:number], nil, n[:label],
242
- n[:klass], false)
305
+ #id = "#{num}#{hier_separator}#{c.increment(label, t).print}"
306
+ id = hiersemx(clause, num, c.increment(label, t), t)
307
+ sequential_permission_body(id, nil, t, label, klass, m, container: false)
308
+ sequential_permission_children(t, id, klass, container: false)
243
309
  end
310
+ end
244
311
  end
245
312
  end
246
313
  end