Module: IsoDoc::XrefGen::Blocks
- Included in:
- IsoDoc::Xref
- Defined in:
- lib/isodoc/xref/xref_gen.rb,
lib/isodoc/xref/xref_gen_seq.rb
Constant Summary collapse
- NUMBERED_BLOCKS =
%w(termnote termexample note example requirement recommendation permission figure table formula admonition sourcecode).freeze
- FIGURE_NO_CLASS =
<<~XPATH.freeze .//figure[not(@class)] | .//figure[@class = 'pseudocode'] | .//sourcecode[not(ancestor::example)] XPATH
Instance Method Summary collapse
- #admonition_anchor_names(sections) ⇒ Object
- #admonition_anchor_names1(notes, counter) ⇒ Object
- #amend_autonums(amend) ⇒ Object
- #amend_preprocess(xmldoc) ⇒ Object
- #bookmark_anchor_names(xml) ⇒ Object
- #bookmark_container(parent) ⇒ Object
- #deflist_anchor_names(sections) ⇒ Object
- #deflist_anchor_names1(notes, counter) ⇒ Object
- #deflist_term_anchor_lbl(listitem, list_anchor) ⇒ Object
- #deflist_term_anchor_names(list, list_anchor) ⇒ Object
- #dt2xreflabel(dterm) ⇒ Object
- #example_anchor_names(sections) ⇒ Object
- #example_anchor_names1(notes, counter) ⇒ Object
- #fig_subfig_label(label, sublabel) ⇒ Object
- #figure_anchor(elem, sublabel, label, klass, container: false) ⇒ Object
- #hierarchical_figure_class_names(clauses, num) ⇒ Object
-
#hierarchical_figure_names(clauses, num) ⇒ Object
these can take a NodeSet as argument; semx will point to members of the NodeSet, but numbering will be consecutive.
- #hierarchical_formula_names(clauses, num) ⇒ Object
- #hierarchical_permission_names(clauses, num) ⇒ Object
- #hierarchical_table_names(clauses, num) ⇒ Object
- #id_ancestor(node) ⇒ Object
- #list_anchor_names(sections) ⇒ Object
- #list_item_anchor_label(label, list_anchor, prev_label, refer_list) ⇒ Object
- #list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list) ⇒ Object
- #list_item_delim ⇒ Object
- #list_item_value(entry, counter, depth, opts) ⇒ Object
- #note_anchor_names(sections) ⇒ Object
- #note_anchor_names1(notes, counter) ⇒ Object
- #reqt2class_label(elem, model) ⇒ Object
- #reqt2class_nested_label(elem, model) ⇒ Object
- #sequential_figure_class_names(clause, container: false) ⇒ Object
- #sequential_figure_names(clause, container: false) ⇒ Object
- #sequential_formula_names(clause, container: false) ⇒ Object
- #sequential_permission_body(id, parent_id, elem, label, klass, model, container: false) ⇒ Object
- #sequential_permission_children(elem, lbl, klass, container: false) ⇒ Object
- #sequential_permission_names(clause, container: true) ⇒ Object
- #sequential_table_names(clause, container: false) ⇒ Object
- #subfigure_anchor(elem, sublabel, label, klass, container: false) ⇒ Object
- #subfigure_increment(idx, counter, elem) ⇒ Object
- #subfigure_label(subfignum) ⇒ Object
- #termexample_anchor_names(docxml) ⇒ Object
- #termnote_anchor_names(docxml) ⇒ Object
- #termnote_label(node, label) ⇒ Object
Instance Method Details
#admonition_anchor_names(sections) ⇒ Object
87 88 89 90 91 92 93 94 |
# File 'lib/isodoc/xref/xref_gen.rb', line 87 def admonition_anchor_names(sections) sections.each do |s| s.at(ns(".//admonition[@type = 'box']")) or next notes = s.xpath(child_asset_path("admonition[@type = 'box']")) admonition_anchor_names1(notes, Counter.new) admonition_anchor_names(s.xpath(ns(child_sections))) end end |
#admonition_anchor_names1(notes, counter) ⇒ Object
96 97 98 99 100 101 102 103 |
# File 'lib/isodoc/xref/xref_gen.rb', line 96 def admonition_anchor_names1(notes, counter) notes.noblank.each do |n| @anchors[n["id"]] ||= anchor_struct(increment_label(notes, n, counter), n, @labels["box"], "admonition", { container: true, unnumb: n["unnumbered"] }) end end |
#amend_autonums(amend) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/isodoc/xref/xref_gen.rb', line 23 def amend_autonums(amend) autonum = {} amend.xpath(ns("./autonumber")).each do |n| autonum[n["type"]] = n.text end autonum end |
#amend_preprocess(xmldoc) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/isodoc/xref/xref_gen.rb', line 11 def amend_preprocess(xmldoc) xmldoc.xpath(ns("//amend[newcontent]")).each do |a| autonum = amend_autonums(a) NUMBERED_BLOCKS.each do |b| a.xpath(ns("./newcontent//#{b}")).each_with_index do |e, i| autonum[b] && i.zero? and e["number"] = autonum[b] !autonum[b] and e["unnumbered"] = "true" end end end end |
#bookmark_anchor_names(xml) ⇒ Object
244 245 246 247 248 249 250 251 |
# File 'lib/isodoc/xref/xref_gen.rb', line 244 def bookmark_anchor_names(xml) xml.xpath(ns(".//bookmark")).noblank.each do |n| _parent, id = id_ancestor(n) @anchors[n["id"]] = { type: "bookmark", label: nil, value: nil, xref: @anchors.dig(id, :xref) || "???", container: @anchors.dig(id, :container) } end end |
#bookmark_container(parent) ⇒ Object
234 235 236 237 238 239 240 241 242 |
# File 'lib/isodoc/xref/xref_gen.rb', line 234 def bookmark_container(parent) if parent clause = parent.xpath(CLAUSE_ANCESTOR)&.last if clause["id"] == id then nil else @anchors.dig(clause["id"], :xref) end end end |
#deflist_anchor_names(sections) ⇒ Object
182 183 184 185 186 187 188 189 |
# File 'lib/isodoc/xref/xref_gen.rb', line 182 def deflist_anchor_names(sections) sections.each do |s| notes = s.xpath(ns(".//dl")) - s.xpath(ns(".//clause//dl")) - s.xpath(ns(".//appendix//dl")) - s.xpath(ns(".//dl//dl")) deflist_anchor_names1(notes, Counter.new) deflist_anchor_names(s.xpath(ns(child_sections))) end end |
#deflist_anchor_names1(notes, counter) ⇒ Object
191 192 193 194 195 196 197 198 199 |
# File 'lib/isodoc/xref/xref_gen.rb', line 191 def deflist_anchor_names1(notes, counter) notes.noblank.each do |n| @anchors[n["id"]] = anchor_struct(increment_label(notes, n, counter), n, @labels["deflist"], "deflist", { unnumb: false, container: true }) deflist_term_anchor_names(n, @anchors[n["id"]]) end end |
#deflist_term_anchor_lbl(listitem, list_anchor) ⇒ Object
213 214 215 216 |
# File 'lib/isodoc/xref/xref_gen.rb', line 213 def deflist_term_anchor_lbl(listitem, list_anchor) s = semx(listitem, dt2xreflabel(listitem)) %(#{list_anchor[:xref]}#{delim_wrap(":")} #{s}</semx>) end |
#deflist_term_anchor_names(list, list_anchor) ⇒ Object
201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/isodoc/xref/xref_gen.rb', line 201 def deflist_term_anchor_names(list, list_anchor) list.xpath(ns("./dt")).each do |li| label = deflist_term_anchor_lbl(li, list_anchor) li["id"] and @anchors[li["id"]] = { xref: label, type: "deflistitem", container: list_anchor[:container] } li.xpath(ns("./dl")).each do |dl| deflist_term_anchor_names(dl, list_anchor) end end end |
#dt2xreflabel(dterm) ⇒ Object
218 219 220 221 222 223 |
# File 'lib/isodoc/xref/xref_gen.rb', line 218 def dt2xreflabel(dterm) label = dterm.dup label.xpath(ns(".//p")).each { |x| x.replace(x.children) } label.xpath(ns(".//index")).each(&:remove) Common::to_xml(label.children) end |
#example_anchor_names(sections) ⇒ Object
105 106 107 108 109 110 111 |
# File 'lib/isodoc/xref/xref_gen.rb', line 105 def example_anchor_names(sections) sections.each do |s| notes = s.xpath(child_asset_path("example")) example_anchor_names1(notes, Counter.new) example_anchor_names(s.xpath(ns(child_sections))) end end |
#example_anchor_names1(notes, counter) ⇒ Object
113 114 115 116 117 118 119 120 |
# File 'lib/isodoc/xref/xref_gen.rb', line 113 def example_anchor_names1(notes, counter) notes.noblank.each do |n| @anchors[n["id"]] ||= anchor_struct(increment_label(notes, n, counter), n, @labels["example_xref"], "example", { unnumb: n["unnumbered"], container: true }) end end |
#fig_subfig_label(label, sublabel) ⇒ Object
62 63 64 65 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 62 def fig_subfig_label(label, sublabel) label && sublabel or return "#{label}#{subfigure_separator}#{sublabel}" end |
#figure_anchor(elem, sublabel, label, klass, container: false) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 50 def figure_anchor(elem, sublabel, label, klass, container: false) if sublabel label&.include?("<semx") or label = semx(elem.parent, label) subfigure_anchor(elem, sublabel, label, klass, container: false) else @anchors[elem["id"]] = anchor_struct( label, elem, @labels[klass] || klass.capitalize, klass, { unnumb: elem["unnumbered"], container: } ) end end |
#hierarchical_figure_class_names(clauses, num) ⇒ Object
186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 186 def hierarchical_figure_class_names(clauses, num) j = 0 nodeSet(clauses).each_with_object({}) do |clause, c| clause.xpath(ns(".//figure[@class][not(@class = 'pseudocode')]")) .noblank.each do |t| # labelled_ancestor(t, %w(figure)) and next c[t["class"]] ||= Counter.new j = subfigure_increment(j, c[t["class"]], t) sublabel = subfigure_label(j) figure_anchor(t, sublabel, hiersemx(clause, num, c[t["class"]], t), t["class"]) end end end |
#hierarchical_figure_names(clauses, num) ⇒ Object
these can take a NodeSet as argument; semx will point to members of the NodeSet, but numbering will be consecutive
172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 172 def hierarchical_figure_names(clauses, num) c = Counter.new j = 0 nodeSet(clauses).each do |clause| clause.xpath(ns(self.class::FIGURE_NO_CLASS)).noblank.each do |t| # labelled_ancestor(t, %w(figure)) and next j = subfigure_increment(j, c, t) sublabel = subfigure_label(j) figure_anchor(t, sublabel, hiersemx(clause, num, c, t), "figure") end hierarchical_figure_class_names(clause, num) end end |
#hierarchical_formula_names(clauses, num) ⇒ Object
214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 214 def hierarchical_formula_names(clauses, num) c = Counter.new nodeSet(clauses).each do |clause| clause.xpath(ns(".//formula")).noblank.each do |t| @anchors[t["id"]] = anchor_struct( hiersemx(clause, num, c.increment(t), t), t, t["inequality"] ? @labels["inequality"] : @labels["formula"], "formula", { unnumb: t["unnumbered"], container: false } ) @anchors[t["id"]][:bare_xref] = @anchors[t["id"]][:label] end end end |
#hierarchical_permission_names(clauses, num) ⇒ Object
228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 228 def (clauses, num) c = ReqCounter.new nodeSet(clauses).each do |clause| clause.xpath(ns(first_lvl_req)).noblank.each do |t| m = @reqt_models.model(t["model"]) klass, label = reqt2class_label(t, m) id = hiersemx(clause, num, c.increment(label, t), t) (id, nil, t, label, klass, m, container: false) (t, id, klass, container: false) end end end |
#hierarchical_table_names(clauses, num) ⇒ Object
201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 201 def hierarchical_table_names(clauses, num) c = Counter.new nodeSet(clauses).each do |clause| clause.xpath(ns(".//table")).noblank.each do |t| # labelled_ancestor(t) and next @anchors[t["id"]] = anchor_struct(hiersemx(clause, num, c.increment(t), t), t, @labels["table"], "table", { unnumb: t["unnumbered"], container: false }) end end end |
#id_ancestor(node) ⇒ Object
225 226 227 228 229 230 231 232 |
# File 'lib/isodoc/xref/xref_gen.rb', line 225 def id_ancestor(node) parent = nil node.ancestors.each do |a| (a["id"] && (parent = a) && @anchors.dig(a["id"], :xref)) or next break end parent ? [parent, parent["id"]] : [nil, nil] end |
#list_anchor_names(sections) ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/isodoc/xref/xref_gen.rb', line 122 def list_anchor_names(sections) sections.each do |s| notes = s.xpath(ns(".//ol")) - s.xpath(ns(".//clause//ol")) - s.xpath(ns(".//appendix//ol")) - s.xpath(ns(".//ol//ol")) c = list_counter(0, {}) notes.noblank.each do |n| @anchors[n["id"]] = anchor_struct(increment_label(notes, n, c), n, @labels["list"], "list", { unnumb: false, container: true }) list_item_anchor_names(n, @anchors[n["id"]], 1, "", notes.size != 1) end list_anchor_names(s.xpath(ns(child_sections))) end end |
#list_item_anchor_label(label, list_anchor, prev_label, refer_list) ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/isodoc/xref/xref_gen.rb', line 170 def list_item_anchor_label(label, list_anchor, prev_label, refer_list) prev_label.empty? or label = @klass.connectives_spans(@i18n.list_nested_xref .sub("%1", %[#{prev_label}#{delim_wrap(list_item_delim)}]) .sub("%2", label)) refer_list and label = @klass.connectives_spans(@i18n.list_nested_xref .sub("%1", list_anchor[:xref]) .sub("%2", label)) label end |
#list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list) ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/isodoc/xref/xref_gen.rb', line 142 def list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list) c = list_counter(list["start"] ? list["start"].to_i - 1 : 0, {}) list.xpath(ns("./li")).each do |li| , label = list_item_value(li, c, depth, { list_anchor:, prev_label:, refer_list: depth == 1 ? refer_list : nil }) #li["id"] ||= "_#{UUIDTools::UUID.random_create}" @anchors[li["id"]] = { label: , bare_xref: "#{label})", type: "listitem", xref: %[#{label}#{delim_wrap(list_item_delim)}], refer_list:, container: list_anchor[:container] } (li.xpath(ns(".//ol")) - li.xpath(ns(".//ol//ol"))).each do |ol| list_item_anchor_names(ol, list_anchor, depth + 1, label, refer_list) end end end |
#list_item_delim ⇒ Object
138 139 140 |
# File 'lib/isodoc/xref/xref_gen.rb', line 138 def list_item_delim ")" end |
#list_item_value(entry, counter, depth, opts) ⇒ Object
162 163 164 165 166 167 168 |
# File 'lib/isodoc/xref/xref_gen.rb', line 162 def list_item_value(entry, counter, depth, opts) label = counter.increment(entry).listlabel(entry.parent, depth) s = semx(entry, label) [label, list_item_anchor_label(s, opts[:list_anchor], opts[:prev_label], opts[:refer_list])] end |
#note_anchor_names(sections) ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/isodoc/xref/xref_gen.rb', line 69 def note_anchor_names(sections) sections.each do |s| notes = s.xpath(child_asset_path("note")) - s.xpath(ns(".//figure//note | .//table//note")) note_anchor_names1(notes, Counter.new) note_anchor_names(s.xpath(ns(child_sections))) end end |
#note_anchor_names1(notes, counter) ⇒ Object
78 79 80 81 82 83 84 85 |
# File 'lib/isodoc/xref/xref_gen.rb', line 78 def note_anchor_names1(notes, counter) notes.noblank.each do |n| @anchors[n["id"]] = anchor_struct(increment_label(notes, n, counter), n, @labels["note_xref"], "note", { container: true, unnumb: false }) end end |
#reqt2class_label(elem, model) ⇒ Object
153 154 155 156 157 158 159 160 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 153 def reqt2class_label(elem, model) elem["class"] and return [elem["class"], elem["class"]] model.req_class_paths.each do |n| v1 = ns("/#{n[:xpath]}").sub(%r{^/}, "") elem.at("./self::#{v1}") and return [n[:klass], n[:label]] end [nil, nil] end |
#reqt2class_nested_label(elem, model) ⇒ Object
162 163 164 165 166 167 168 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 162 def reqt2class_nested_label(elem, model) model.req_nested_class_paths.each do |n| v1 = ns("/#{n[:xpath]}").sub(%r{^/}, "") elem.at("./self::#{v1}") and return [n[:klass], n[:label]] end [nil, nil] end |
#sequential_figure_class_names(clause, container: false) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 32 def sequential_figure_class_names(clause, container: false) j = 0 clause.xpath(ns(".//figure[@class][not(@class = 'pseudocode')]")) .each_with_object({}) do |t, c| c[t["class"]] ||= Counter.new # labelled_ancestor(t, %w(figure)) and next j = subfigure_increment(j, c[t["class"]], t) sublabel = subfigure_label(j) figure_anchor(t, sublabel, c[t["class"]].print, t["class"], container: container) end end |
#sequential_figure_names(clause, container: false) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 20 def sequential_figure_names(clause, container: false) c = Counter.new j = 0 clause.xpath(ns(self.class::FIGURE_NO_CLASS)).noblank.each do |t| # labelled_ancestor(t, %w(figure)) and next # disable nested figure labelling j = subfigure_increment(j, c, t) sublabel = subfigure_label(j) figure_anchor(t, sublabel, c.print, "figure", container: container) end sequential_figure_class_names(clause, container:) end |
#sequential_formula_names(clause, container: false) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 94 def sequential_formula_names(clause, container: false) c = Counter.new clause.xpath(ns(".//formula")).noblank.each do |t| @anchors[t["id"]] = anchor_struct( c.increment(t).print, t, t["inequality"] ? @labels["inequality"] : @labels["formula"], "formula", { unnumb: t["unnumbered"], container: true } ) @anchors[t["id"]][:bare_xref] = @anchors[t["id"]][:label] end end |
#sequential_permission_body(id, parent_id, elem, label, klass, model, container: false) ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 131 def (id, parent_id, elem, label, klass, model, container: false) lbl = parent_id ? "#{parent_id}#{subreqt_separator}#{id}" : id @anchors[elem["id"]] = model.postprocess_anchor_struct( elem, anchor_struct(lbl, elem, label, klass, { unnumb: elem["unnumbered"], container: }) ) @anchors[elem["id"]][:semx] = semx(elem, lbl) if parent_id x = "#{subreqt_separator(markup: true)}#{semx(elem, id)}" @anchors[elem["id"]][:semx] = @anchors[elem.parent["id"]][:semx] + x @anchors[elem["id"]][:label] = "<span class='fmt-element-name'>#{label}</span> #{@anchors[elem['id']][:semx]}" @anchors[elem["id"]][:xref] = "<span class='fmt-element-name'>#{label}</span> #{@anchors[elem['id']][:semx]}" end model.(elem, id, label, klass).each do |n| @anchors[n[:id]] = anchor_struct(n[:number], n[:elem], n[:label], n[:klass], { unnumb: false, container: }) end end |
#sequential_permission_children(elem, lbl, klass, container: false) ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 118 def (elem, lbl, klass, container: false) c = ReqCounter.new elem.xpath(ns(req_children)).noblank.each do |t| m = @reqt_models.model(t["model"]) klass, label = reqt2class_nested_label(t, m) ctr = c.increment(label, t).print id = "#{lbl}#{subreqt_separator}#{ctr}" (ctr, lbl, t, label, klass, m, container:) (t, id, klass, container:) end end |
#sequential_permission_names(clause, container: true) ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 106 def (clause, container: true) c = ReqCounter.new clause.xpath(ns(first_lvl_req)).noblank.each do |t| m = @reqt_models.model(t["model"]) klass, label = reqt2class_label(t, m) id = c.increment(label, t).print (id, nil, t, label, klass, m, container:) (t, id, klass, container:) end end |
#sequential_table_names(clause, container: false) ⇒ Object
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 83 def sequential_table_names(clause, container: false) c = Counter.new clause.xpath(ns(".//table")).noblank.each do |t| # labelled_ancestor(t) and next @anchors[t["id"]] = anchor_struct( c.increment(t).print, t, @labels["table"], "table", { unnumb: t["unnumbered"], container: container } ) end end |
#subfigure_anchor(elem, sublabel, label, klass, container: false) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 67 def subfigure_anchor(elem, sublabel, label, klass, container: false) figlabel = fig_subfig_label(label, sublabel) @anchors[elem["id"]] = anchor_struct( figlabel, elem, @labels[klass] || klass.capitalize, klass, { unnumb: elem["unnumbered"] } ) if elem["unnumbered"] != "true" x = "#{subfigure_separator(markup: true)}#{semx(elem, sublabel)}" @anchors[elem["id"]][:label] = "#{label}#{x}" @anchors[elem["id"]][:xref] = @anchors[elem.parent["id"]][:xref] + x + delim_wrap(subfigure_delim) x = @anchors[elem.parent["id"]][:container] and @anchors[elem["id"]][:container] = x end end |
#subfigure_increment(idx, counter, elem) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 7 def subfigure_increment(idx, counter, elem) if elem.parent.name == "figure" then idx += 1 else idx = 0 counter.increment(elem) end idx end |
#subfigure_label(subfignum) ⇒ Object
45 46 47 48 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 45 def subfigure_label(subfignum) subfignum.zero? and return subfignum.to_s end |
#termexample_anchor_names(docxml) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/isodoc/xref/xref_gen.rb', line 53 def termexample_anchor_names(docxml) docxml.xpath(ns("//*[termexample]")).each do |t| examples = t.xpath(ns("./termexample")) c = Counter.new examples.noblank.each do |n| c.increment(n) idx = increment_label(examples, n, c, increment: false) @anchors[n["id"]] = { label: idx, type: "termexample", value: idx, elem: @labels["example_xref"], container: t["id"], xref: anchor_struct_xref(idx, n, @labels["example_xref"]) } end end end |
#termnote_anchor_names(docxml) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/isodoc/xref/xref_gen.rb', line 39 def termnote_anchor_names(docxml) docxml.xpath(ns("//*[termnote]")).each do |t| c = Counter.new t.xpath(ns("./termnote")).noblank.each do |n| c.increment(n) @anchors[n["id"]] = { label: termnote_label(n, c.print), type: "termnote", value: c.print, elem: @labels["termnote"], container: t["id"], xref: anchor_struct_xref(c.print, n, @labels["note_xref"]) } end end end |
#termnote_label(node, label) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/isodoc/xref/xref_gen.rb', line 31 def termnote_label(node, label) if label.blank? @labels["termnote"].gsub(/%\s?/, "") else @labels["termnote"].gsub("%", semx(node, label.to_s)) end end |