isodoc 3.4.2 → 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 (50) hide show
  1. checksums.yaml +4 -4
  2. data/lib/isodoc/base_style/typography.scss +5 -0
  3. data/lib/isodoc/convert.rb +2 -1
  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/references.rb +11 -4
  8. data/lib/isodoc/function/setup.rb +1 -1
  9. data/lib/isodoc/function/table.rb +2 -2
  10. data/lib/isodoc/function/to_word_html.rb +1 -0
  11. data/lib/isodoc/function/utils.rb +1 -1
  12. data/lib/isodoc/init.rb +15 -6
  13. data/lib/isodoc/metadata.rb +6 -5
  14. data/lib/isodoc/metadata_contributor.rb +13 -0
  15. data/lib/isodoc/presentation_function/autonum.rb +65 -4
  16. data/lib/isodoc/presentation_function/bibdata.rb +15 -4
  17. data/lib/isodoc/presentation_function/block.rb +36 -78
  18. data/lib/isodoc/presentation_function/erefs.rb +55 -28
  19. data/lib/isodoc/presentation_function/erefs_locality.rb +18 -10
  20. data/lib/isodoc/presentation_function/footnotes.rb +2 -1
  21. data/lib/isodoc/presentation_function/image.rb +15 -5
  22. data/lib/isodoc/presentation_function/index.rb +1 -5
  23. data/lib/isodoc/presentation_function/inline.rb +0 -20
  24. data/lib/isodoc/presentation_function/list.rb +3 -3
  25. data/lib/isodoc/presentation_function/metadata.rb +50 -32
  26. data/lib/isodoc/presentation_function/refs.rb +57 -74
  27. data/lib/isodoc/presentation_function/section.rb +0 -3
  28. data/lib/isodoc/presentation_function/section_refs.rb +55 -0
  29. data/lib/isodoc/presentation_function/source.rb +73 -0
  30. data/lib/isodoc/presentation_function/terms.rb +7 -5
  31. data/lib/isodoc/presentation_function/xrefs.rb +17 -6
  32. data/lib/isodoc/presentation_xml_convert.rb +8 -3
  33. data/lib/isodoc/version.rb +1 -1
  34. data/lib/isodoc/word_function/lists.rb +4 -2
  35. data/lib/isodoc/word_function/postprocess_table.rb +3 -1
  36. data/lib/isodoc/xref/xref_gen.rb +72 -119
  37. data/lib/isodoc/xref/xref_gen_seq.rb +18 -14
  38. data/lib/isodoc/xref/xref_list_gen.rb +107 -0
  39. data/lib/isodoc/xref/xref_sect_asset.rb +0 -1
  40. data/lib/isodoc/xref.rb +1 -0
  41. data/lib/isodoc/xslfo_convert.rb +5 -1
  42. data/lib/isodoc-yaml/i18n-ar.yaml +9 -0
  43. data/lib/isodoc-yaml/i18n-de.yaml +9 -0
  44. data/lib/isodoc-yaml/i18n-en.yaml +9 -0
  45. data/lib/isodoc-yaml/i18n-es.yaml +9 -0
  46. data/lib/isodoc-yaml/i18n-fr.yaml +9 -0
  47. data/lib/isodoc-yaml/i18n-ja.yaml +9 -0
  48. data/lib/isodoc-yaml/i18n-ru.yaml +9 -0
  49. data/lib/isodoc-yaml/i18n-zh-Hans.yaml +9 -0
  50. metadata +5 -2
@@ -0,0 +1,55 @@
1
+ module IsoDoc
2
+ class PresentationXMLConvert < ::IsoDoc::Convert
3
+ def references(docxml)
4
+ @ref_renderings = references_render(docxml)
5
+ docxml.xpath(ns("//references/bibitem")).each do |x|
6
+ bibitem(x, @ref_renderings)
7
+ reference_name(x)
8
+ end
9
+ bibliography_bibitem_number(docxml)
10
+ hidden_items(docxml)
11
+ move_norm_ref_to_sections(docxml)
12
+ end
13
+
14
+ def reference_names(docxml)
15
+ docxml.xpath(ns("//bibitem[not(ancestor::bibitem)]")).each do |ref|
16
+ reference_name(ref)
17
+ end
18
+ end
19
+
20
+ def reference_name(ref)
21
+ identifiers = render_identifier(bibitem_ref_code(ref))
22
+ reference = docid_l10n(identifiers[:content] || identifiers[:metanorma] ||
23
+ identifiers[:sdo] || identifiers[:ordinal] ||
24
+ identifiers[:doi])
25
+ @xrefs.get[ref["id"]] = { xref: esc(reference), type: "bibitem" }
26
+ end
27
+
28
+ def move_norm_ref_to_sections(docxml)
29
+ docxml.at(ns(@xrefs.klass.norm_ref_xpath)) or return
30
+ s = move_norm_ref_to_sections_insert_pt(docxml) or return
31
+ docxml.xpath(ns(@xrefs.klass.norm_ref_xpath)).each do |r|
32
+ r.at("./ancestor::xmlns:bibliography") or next
33
+ s << r.remove
34
+ end
35
+ end
36
+
37
+ def move_norm_ref_to_sections_insert_pt(docxml)
38
+ s = docxml.at(ns("//sections")) and return s
39
+ s = docxml.at(ns("//preface")) and
40
+ return s.after("<sections/>").next_element
41
+ docxml.at(ns("//annex | //bibliography"))&.before("<sections/>")
42
+ &.previous_element
43
+ end
44
+
45
+ def hidden_items(docxml)
46
+ docxml.xpath(ns("//references[bibitem/@hidden = 'true']")).each do |x|
47
+ x.at(ns("./bibitem[not(@hidden = 'true')]")) and next
48
+ x.elements.map(&:name).any? do |n|
49
+ !%w(title bibitem).include?(n)
50
+ end and next
51
+ x["hidden"] = "true"
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,73 @@
1
+ module IsoDoc
2
+ class PresentationXMLConvert < ::IsoDoc::Convert
3
+ # TODO will go back to just one source/modification, preserving it
4
+ def source(docxml)
5
+ fmt_source(docxml)
6
+ docxml.xpath(ns("//fmt-source/source/modification")).each do |f|
7
+ source_modification(f)
8
+ end
9
+ source_types(docxml)
10
+ docxml.xpath(ns("//fmt-source/source")).each do |f|
11
+ f.replace(semx_fmt_dup(f))
12
+ end
13
+ end
14
+
15
+ def source_types(docxml)
16
+ docxml.xpath(ns("//table/fmt-source")).each { |f| tablesource(f) }
17
+ docxml.xpath(ns("//figure/fmt-source")).each { |f| figuresource(f) }
18
+ end
19
+
20
+ def fmt_source(docxml)
21
+ n = docxml.xpath(ns("//source")) - docxml.xpath(ns("//term//source")) -
22
+ docxml.xpath(ns("//quote/source"))
23
+ n.each do |s|
24
+ dup = s.clone
25
+ modification_dup_align(s, dup)
26
+ s.next = "<fmt-source>#{to_xml(dup)}</fmt-source>"
27
+ end
28
+ end
29
+
30
+ def tablesource(elem)
31
+ source1(elem, :table)
32
+ end
33
+
34
+ def figuresource(elem)
35
+ source1(elem, :figure)
36
+ end
37
+
38
+ def source_join_delim(_elem)
39
+ "; "
40
+ end
41
+
42
+ def source1(elem, ancestor)
43
+ esc_origin(elem)
44
+ source_elems = source1_gather(elem)
45
+ source_elems.each do |e|
46
+ esc_origin(e)
47
+ elem << "#{source_join_delim(elem)}#{to_xml(e.remove.children).strip}"
48
+ end
49
+ source1_label(elem, @i18n.l10n(to_xml(elem.children).strip), ancestor)
50
+ end
51
+
52
+ def source1_gather(elem)
53
+ source_elems = []
54
+ while elem = elem&.next_element
55
+ case elem.name
56
+ when "source"
57
+ when "fmt-source"
58
+ source_elems << elem
59
+ else break
60
+ end
61
+ end
62
+ source_elems
63
+ end
64
+
65
+ def source1_label(elem, sources, _ancestor)
66
+ elem.children = l10n("[#{@i18n.source}: #{esc sources}]")
67
+ end
68
+
69
+ def source_modification(mod)
70
+ termsource_modification(mod.parent)
71
+ end
72
+ end
73
+ end
@@ -148,6 +148,12 @@ module IsoDoc
148
148
  m1.replace("<modification>#{to_xml(new_m1)}</modification>")
149
149
  end
150
150
 
151
+ def esc_origin(element)
152
+ element.xpath(ns(".//origin")).each do |origin|
153
+ origin.wrap("<esc></esc>")
154
+ end
155
+ end
156
+
151
157
  # concatenate sources. localise the concatenation, escaping the docids
152
158
  # within the concatenands
153
159
  # from punctuation localisation: l10n(<esc>A</esc>, <esc>B</esc>)
@@ -158,11 +164,7 @@ module IsoDoc
158
164
  while elem.next_element&.name == "source"
159
165
  ret << semx_fmt_dup(elem.next_element.remove)
160
166
  end
161
- ret.each do |element|
162
- element.xpath(ns(".//origin")).each do |origin|
163
- origin.wrap("<esc></esc>")
164
- end
165
- end
167
+ ret.each { |element| esc_origin(element) }
166
168
  s = ret.map { |x| to_xml(x) }.map(&:strip)
167
169
  .join(termsource_join_delim(elem))
168
170
  termsource_label(elem, @i18n.l10n(s))
@@ -15,13 +15,13 @@ module IsoDoc
15
15
 
16
16
  def prefix_container(container, linkend, node, target)
17
17
  prefix_container?(container, node) or return linkend
18
- container_container = @xrefs.anchor(container, :container, false)
19
- container_label =
18
+ container_container = prefix_container_container(container)
19
+ cntnr_label =
20
20
  prefix_container(container_container,
21
21
  anchor_xref(node, container, container: true),
22
22
  node, target)
23
23
  l10n(connectives_spans(@i18n.nested_xref
24
- .sub("%1", "<span class='fmt-xref-container'>#{esc container_label}</span>")
24
+ .sub("%1", "<span class='fmt-xref-container'>#{esc cntnr_label}</span>")
25
25
  .sub("%2", esc(linkend))))
26
26
  end
27
27
 
@@ -135,7 +135,8 @@ module IsoDoc
135
135
  def gather_xref_locations(node)
136
136
  node.xpath(ns("./location")).each_with_object([]) do |l, m|
137
137
  type = @xrefs.anchor(l["target"], :type)
138
- m << { conn: l["connective"], target: l["target"],
138
+ m << { conn: l["connective"], custom: l["custom-connective"],
139
+ target: l["target"],
139
140
  type:, node: l, elem: @xrefs.anchor(l["target"], :elem),
140
141
  container: @xrefs.anchor(l["target"], :container, false) ||
141
142
  %w(termnote).include?(type) }
@@ -165,14 +166,24 @@ module IsoDoc
165
166
  else
166
167
  ret = loc2xref(list[0])
167
168
  list[1..].each { |l| ret = i18n_chain_boolean(ret, l) }
169
+ if list[0][:conn] == "from" && list[0][:custom]
170
+ # TODO: languages with mandatory from, include from in chain_to
171
+ ret = connectives_spans("<conn>#{list[0][:custom]}</conn> ") + ret
172
+ end
168
173
  ret
169
174
  end
170
175
  end
171
176
 
177
+ def conn_sub(str, conn)
178
+ str.sub(%r{<conn>[^<]+</conn>}, "<conn>#{conn}</conn>")
179
+ end
180
+
172
181
  def i18n_chain_boolean(value, entry)
173
- connectives_spans(@i18n.send("chain_#{entry[:conn]}")
182
+ ret = @i18n.send("chain_#{entry[:conn]}")
174
183
  .sub("%1", value)
175
- .sub("%2", loc2xref(entry)))
184
+ .sub("%2", loc2xref(entry))
185
+ c = entry[:custom] and ret = conn_sub(ret, c)
186
+ connectives_spans(ret)
176
187
  end
177
188
 
178
189
  def can_conflate_xref_rendering?(locs)
@@ -1,4 +1,5 @@
1
1
  require_relative "presentation_function/block"
2
+ require_relative "presentation_function/source"
2
3
  require_relative "presentation_function/list"
3
4
  require_relative "presentation_function/reqt"
4
5
  require_relative "presentation_function/concepts"
@@ -9,6 +10,10 @@ require_relative "presentation_function/erefs"
9
10
  require_relative "presentation_function/inline"
10
11
  require_relative "presentation_function/math"
11
12
  require_relative "presentation_function/section"
13
+ require_relative "presentation_function/section_refs"
14
+ require_relative "presentation_function/title"
15
+ require_relative "presentation_function/refs"
16
+ require_relative "presentation_function/docid"
12
17
  require_relative "presentation_function/index"
13
18
  require_relative "presentation_function/bibdata"
14
19
  require_relative "presentation_function/metadata"
@@ -42,6 +47,7 @@ module IsoDoc
42
47
  @outputfile = Pathname.new(filename).basename.to_s
43
48
  docid_prefixes(docxml) # feeds @xrefs.parse citation processing
44
49
  provide_ids docxml # feeds @xrefs.parse
50
+ bibitem_lookup(docxml) # feeds citeas
45
51
  @xrefs.parse docxml
46
52
  @xrefs.klass.meta = @meta
47
53
  counter_init
@@ -54,7 +60,7 @@ module IsoDoc
54
60
  def bibitem_lookup(docxml)
55
61
  @bibitem_lookup ||= docxml.xpath(ns("//references/bibitem"))
56
62
  .each_with_object({}) do |b, m|
57
- m[b["id"]] = b
63
+ m[b["id"]] = b
58
64
  end
59
65
  end
60
66
 
@@ -90,6 +96,7 @@ module IsoDoc
90
96
  end
91
97
 
92
98
  def block(docxml)
99
+ amend docxml # feeds all other blocks
93
100
  table docxml
94
101
  figure docxml
95
102
  sourcecode docxml
@@ -106,13 +113,11 @@ module IsoDoc
106
113
  requirement docxml
107
114
  recommendation docxml
108
115
  requirement_render docxml
109
- amend docxml
110
116
  end
111
117
 
112
118
  def inline(docxml)
113
119
  document_footnotes docxml
114
120
  comments docxml
115
- bibitem_lookup(docxml) # feeds citeas
116
121
  fmt_ref docxml # feeds citeas, xref, eref, origin, concept
117
122
  citeas docxml # feeds xref, eref, origin, concept
118
123
  xref docxml
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "3.4.2".freeze
2
+ VERSION = "3.4.3".freeze
3
3
  end
@@ -62,9 +62,11 @@ module IsoDoc
62
62
  end
63
63
 
64
64
  def dl_table_attrs(node)
65
+ key = node.parent.name == "key" && node.parent["class"] == "formula_dl"
66
+ klass = key ? node.parent["class"] : nil
65
67
  { id: node["id"],
66
- style: node["class"] == "formula_dl" ? "text-align:left;" : nil,
67
- class: node["class"] || "dl" }
68
+ style: key ? "text-align:left;" : nil,
69
+ class: klass || node["class"] || "dl" }
68
70
  end
69
71
 
70
72
  def dl_parse_table(node, out)
@@ -44,7 +44,9 @@ 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
+ nested_tables = t.xpath(".//table") - t.xpath(".//td//table") -
48
+ t.xpath(".//th//table")
49
+ nested_tables.reverse_each do |tt|
48
50
  t.next = tt.remove
49
51
  end
50
52
  end
@@ -1,6 +1,3 @@
1
- require_relative "xref_gen_seq"
2
- require_relative "xref_util"
3
-
4
1
  module IsoDoc
5
2
  module XrefGen
6
3
  module Blocks
@@ -10,13 +7,17 @@ module IsoDoc
10
7
 
11
8
  def amend_preprocess(xmldoc)
12
9
  xmldoc.xpath(ns("//amend[newcontent]")).each do |a|
13
- autonum = amend_autonums(a)
14
- NUMBERED_BLOCKS.each do |b|
15
- a.xpath(ns("./newcontent//#{b}")).each_with_index do |e, i|
16
- autonum[b] && i.zero? and e["number"] = autonum[b]
17
- !autonum[b] and e["unnumbered"] = "true"
18
- end
19
- end
10
+ amend_preprocess1(a)
11
+ end
12
+ end
13
+
14
+ def amend_preprocess1(amend, subclause: false)
15
+ autonum = amend_autonums(amend)
16
+ NUMBERED_BLOCKS.each do |b|
17
+ amend_blocks(amend, autonum, b, subclause)
18
+ end
19
+ amend.xpath(ns(".#{amend_newcontent(subclause)}/clause")).each do |c|
20
+ amend_preprocess1(c, subclause: true)
20
21
  end
21
22
  end
22
23
 
@@ -28,6 +29,20 @@ module IsoDoc
28
29
  autonum
29
30
  end
30
31
 
32
+ def amend_blocks(amend, autonum, blocktype, subclause)
33
+ newc = amend_newcontent(subclause)
34
+ (amend.xpath(ns(".#{newc}//#{blocktype}")) -
35
+ amend.xpath(ns(".#{newc}/clause//#{blocktype}")))
36
+ .each_with_index do |e, i|
37
+ autonum[blocktype] && i.zero? and e["number"] = autonum[blocktype]
38
+ !autonum[blocktype] and e["unnumbered"] = "true"
39
+ end
40
+ end
41
+
42
+ def amend_newcontent(subclause)
43
+ subclause ? "" : "/newcontent"
44
+ end
45
+
31
46
  def termnote_label(node, label)
32
47
  if label.blank?
33
48
  @labels["termnote"].gsub(/%\s?/, "")
@@ -50,17 +65,42 @@ module IsoDoc
50
65
  end
51
66
  end
52
67
 
68
+ # processed from Presentation XML notes_inside_bibitem(),
69
+ # after notes moved: need docid from references processing
70
+ def bibitem_note_names(bib)
71
+ notes = bib.xpath(ns("./formattedref/note"))
72
+ counter = Counter.new
73
+ notes.noblank.each do |n|
74
+ lbl = increment_label(notes, n, counter)
75
+ @anchors[n["id"]] =
76
+ { label: lbl, value: lbl, container: bib["id"],
77
+ xref: anchor_struct_xref(lbl, n, @labels["note_xref"]),
78
+ elem: @labels["note_xref"], type: "note" }
79
+ end
80
+ end
81
+
82
+ # note within an asset: table, figure, provision
83
+ def nested_notes(asset, container: true)
84
+ notes = asset.xpath(ns(".//note"))
85
+ counter = Counter.new
86
+ notes.noblank.each do |n|
87
+ lbl = increment_label(notes, n, counter)
88
+ @anchors[n["id"]] =
89
+ { label: lbl, value: lbl, container: container ? asset["id"] : nil,
90
+ xref: anchor_struct_xref(lbl, n, @labels["note_xref"]),
91
+ elem: @labels["note_xref"], type: "note" }.compact
92
+ end
93
+ end
94
+
53
95
  def termexample_anchor_names(docxml)
54
96
  docxml.xpath(ns("//*[termexample]")).each do |t|
55
97
  examples = t.xpath(ns("./termexample"))
56
- c = Counter.new
57
- examples.noblank.each do |n|
98
+ examples.noblank.each_with_object(Counter.new) do |n, c|
58
99
  c.increment(n)
59
100
  idx = increment_label(examples, n, c, increment: false)
60
101
  @anchors[n["id"]] =
61
- { label: idx, type: "termexample",
62
- value: idx, elem: @labels["example_xref"],
63
- container: t["id"],
102
+ { label: idx, type: "termexample", value: idx,
103
+ elem: @labels["example_xref"], container: t["id"],
64
104
  xref: anchor_struct_xref(idx, n, @labels["example_xref"]) }
65
105
  end
66
106
  end
@@ -69,7 +109,8 @@ module IsoDoc
69
109
  def note_anchor_names(sections)
70
110
  sections.each do |s|
71
111
  notes = s.xpath(child_asset_path("note")) -
72
- s.xpath(ns(".//figure//note | .//table//note"))
112
+ s.xpath(ns(".//figure//note | .//table//note | //permission//note | " \
113
+ "//recommendation//note | //requirement//note"))
73
114
  note_anchor_names1(notes, Counter.new)
74
115
  note_anchor_names(s.xpath(ns(child_sections)))
75
116
  end
@@ -102,9 +143,23 @@ module IsoDoc
102
143
  end
103
144
  end
104
145
 
146
+ # note within an asset: provision
147
+ def nested_examples(asset, container: true)
148
+ notes = asset.xpath(ns(".//example"))
149
+ notes.noblank.each_with_object(Counter.new) do |n, counter|
150
+ @anchors[n["id"]] ||=
151
+ anchor_struct(increment_label(notes, n, counter), n,
152
+ @labels["example_xref"], "example",
153
+ { unnumb: n["unnumbered"] })
154
+ @anchors[n["id"]][:container] = container ? asset["id"] : nil
155
+ end
156
+ end
157
+
105
158
  def example_anchor_names(sections)
106
159
  sections.each do |s|
107
- notes = s.xpath(child_asset_path("example"))
160
+ notes = s.xpath(child_asset_path("example")) -
161
+ s.xpath(ns("//permission//note | " \
162
+ "//recommendation//note | //requirement//note"))
108
163
  example_anchor_names1(notes, Counter.new)
109
164
  example_anchor_names(s.xpath(ns(child_sections)))
110
165
  end
@@ -119,108 +174,6 @@ module IsoDoc
119
174
  end
120
175
  end
121
176
 
122
- def list_anchor_names(sections)
123
- sections.each do |s|
124
- notes = s.xpath(ns(".//ol")) - s.xpath(ns(".//clause//ol")) -
125
- s.xpath(ns(".//appendix//ol")) - s.xpath(ns(".//ol//ol"))
126
- c = list_counter(0, {})
127
- notes.noblank.each do |n|
128
- @anchors[n["id"]] =
129
- anchor_struct(increment_label(notes, n, c), n,
130
- @labels["list"], "list",
131
- { unnumb: false, container: true })
132
- list_item_anchor_names(n, @anchors[n["id"]], 1, "", notes.size != 1)
133
- end
134
- list_anchor_names(s.xpath(ns(child_sections)))
135
- end
136
- end
137
-
138
- def list_item_delim
139
- ")"
140
- end
141
-
142
- def list_item_anchor_names(list, list_anchor, depth, prev_label,
143
- refer_list)
144
- c = list_counter(list["start"] ? list["start"].to_i - 1 : 0, {})
145
- list.xpath(ns("./li")).each do |li|
146
- bare_label, label =
147
- list_item_value(li, c, depth,
148
- { list_anchor:, prev_label:,
149
- refer_list: depth == 1 ? refer_list : nil })
150
- @anchors[li["id"]] =
151
- { label: bare_label, bare_xref: "#{label})", type: "listitem",
152
- xref: %[#{label}#{delim_wrap(list_item_delim)}], refer_list:,
153
- container: list_anchor[:container] }
154
- (li.xpath(ns(".//ol")) - li.xpath(ns(".//ol//ol"))).each do |ol|
155
- list_item_anchor_names(ol, list_anchor, depth + 1, label,
156
- refer_list)
157
- end
158
- end
159
- end
160
-
161
- def list_item_value(entry, counter, depth, opts)
162
- label = counter.increment(entry).listlabel(entry.parent, depth)
163
- s = semx(entry, label)
164
- [label,
165
- list_item_anchor_label(s, opts[:list_anchor], opts[:prev_label],
166
- opts[:refer_list])]
167
- end
168
-
169
- def list_item_anchor_label(label, list_anchor, prev_label, refer_list)
170
- prev_label.empty? or
171
- label = @klass.connectives_spans(@i18n.list_nested_xref
172
- .sub("%1", %[#{prev_label}#{delim_wrap(list_item_delim)}])
173
- .sub("%2", label))
174
- refer_list and
175
- label = @klass.connectives_spans(@i18n.list_nested_xref
176
- .sub("%1", list_anchor[:xref])
177
- .sub("%2", label))
178
- label
179
- end
180
-
181
- def deflist_anchor_names(sections)
182
- sections.each do |s|
183
- notes = s.xpath(ns(".//dl")) - s.xpath(ns(".//clause//dl")) -
184
- s.xpath(ns(".//appendix//dl")) - s.xpath(ns(".//dl//dl"))
185
- deflist_anchor_names1(notes, Counter.new)
186
- deflist_anchor_names(s.xpath(ns(child_sections)))
187
- end
188
- end
189
-
190
- def deflist_anchor_names1(notes, counter)
191
- notes.noblank.each do |n|
192
- @anchors[n["id"]] =
193
- anchor_struct(increment_label(notes, n, counter), n,
194
- @labels["deflist"], "deflist",
195
- { unnumb: false, container: true })
196
- deflist_term_anchor_names(n, @anchors[n["id"]])
197
- end
198
- end
199
-
200
- def deflist_term_anchor_names(list, list_anchor)
201
- list.xpath(ns("./dt")).each do |li|
202
- label = deflist_term_anchor_lbl(li, list_anchor)
203
- li["id"] and @anchors[li["id"]] =
204
- { xref: label, type: "deflistitem",
205
- container: list_anchor[:container] }
206
- li.xpath(ns("./dl")).each do |dl|
207
- deflist_term_anchor_names(dl, list_anchor)
208
- end
209
- end
210
- end
211
-
212
- def deflist_term_anchor_lbl(listitem, list_anchor)
213
- s = semx(listitem, dt2xreflabel(listitem))
214
- %(#{list_anchor[:xref]}#{delim_wrap(":")} #{s}</semx>)
215
- end
216
-
217
- def dt2xreflabel(dterm)
218
- label = dterm.dup
219
- label.xpath(ns(".//p")).each { |x| x.replace(x.children) }
220
- label.xpath(ns(".//index")).each(&:remove)
221
- Common::to_xml(label.children)
222
- end
223
-
224
177
  def id_ancestor(node)
225
178
  parent = nil
226
179
  node.ancestors.each do |a|
@@ -56,6 +56,7 @@ module IsoDoc
56
56
  { unnumb: elem["unnumbered"], container: }
57
57
  )
58
58
  end
59
+ nested_notes(elem)
59
60
  end
60
61
 
61
62
  def fig_subfig_label(label, sublabel)
@@ -87,6 +88,7 @@ module IsoDoc
87
88
  c.increment(t).print, t, @labels["table"], "table",
88
89
  { unnumb: t["unnumbered"], container: container }
89
90
  )
91
+ nested_notes(t)
90
92
  end
91
93
  end
92
94
 
@@ -114,11 +116,6 @@ module IsoDoc
114
116
  end
115
117
  end
116
118
 
117
- def delim_wrap(delim, klass = "fmt-autonum-delim")
118
- delim.blank? and return ""
119
- "<span class='#{klass}'><esc>#{delim}</esc></span>"
120
- end
121
-
122
119
  def sequential_permission_children(elem, lbl, klass, container: false)
123
120
  elem.xpath(ns(req_children)).noblank
124
121
  .each_with_object(ReqCounter.new) do |t, c|
@@ -137,23 +134,29 @@ container: false)
137
134
  lbl = parent_id ? "#{parent_id}#{subreqt_separator}#{id}" : id
138
135
  e = elem["id"] || elem["original-id"]
139
136
  @anchors[e] = model.postprocess_anchor_struct(
140
- elem, anchor_struct(lbl, elem,
141
- label, klass, { unnumb: elem["unnumbered"], container: })
137
+ elem, anchor_struct(lbl, elem, label, klass,
138
+ { unnumb: elem["unnumbered"], container: })
142
139
  )
140
+ nested_notes(elem)
141
+ nested_examples(elem)
143
142
  @anchors[e][:semx] = semx(elem, lbl)
144
- if parent_id
145
- x = "#{subreqt_separator(markup: true)}#{semx(elem, id)}"
146
- @anchors[e][:semx] = @anchors[elem.parent["id"] || elem.parent["original-id"]][:semx] + x
147
- @anchors[e][:label] =
148
- "<span class='fmt-element-name'>#{label}</span> #{@anchors[e][:semx]}"
149
- @anchors[e][:xref] = @anchors[e][:label]
150
- end
143
+ sequential_permission_body_parent_id(id, parent_id, elem, label, e)
151
144
  model.permission_parts(elem, id, label, klass).each do |n|
152
145
  @anchors[n[:id]] = anchor_struct(n[:number], n[:elem], n[:label],
153
146
  n[:klass], { unnumb: false, container: })
154
147
  end
155
148
  end
156
149
 
150
+ def sequential_permission_body_parent_id(id, parent_id, elem, label, e)
151
+ parent_id or return
152
+ x = "#{subreqt_separator(markup: true)}#{semx(elem, id)}"
153
+ @anchors[e][:semx] =
154
+ @anchors[elem.parent["id"] || elem.parent["original-id"]][:semx] + x
155
+ @anchors[e][:label] =
156
+ "<span class='fmt-element-name'>#{label}</span> #{@anchors[e][:semx]}"
157
+ @anchors[e][:xref] = @anchors[e][:label]
158
+ end
159
+
157
160
  def reqt2class_label(elem, model)
158
161
  elem["class"] and return [elem["class"], elem["class"]]
159
162
  model.req_class_paths.each do |n|
@@ -207,6 +210,7 @@ container: false)
207
210
  anchor_struct(hiersemx(clause, num, c.increment(t), t),
208
211
  t, @labels["table"], "table",
209
212
  { unnumb: t["unnumbered"], container: false })
213
+ nested_notes(t)
210
214
  end
211
215
  end
212
216
  end