Class: IsoDoc::Plateau::Xref
- Inherits:
-
Jis::Xref
- Object
- Jis::Xref
- IsoDoc::Plateau::Xref
- Defined in:
- lib/isodoc/plateau/xref.rb
Instance Method Summary collapse
- #clause_order_main(_docxml) ⇒ Object
- #hierarchical_figure_class_names(clause, num) ⇒ Object
- #hierarchical_figure_names(clauses, num) ⇒ Object
- #hiersep ⇒ Object
-
#initialize(lang, script, klass, i18n, options) ⇒ Xref
constructor
A new instance of Xref.
- #list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list) ⇒ Object
- #list_item_value(entry, counter, depth, opts) ⇒ Object
-
#middle_asset_names(clause, container: false) ⇒ Object
container makes numbering be prefixed with the parent clause reference.
- #middle_section_asset_names(doc) ⇒ Object
Constructor Details
#initialize(lang, script, klass, i18n, options) ⇒ Xref
7 8 9 10 |
# File 'lib/isodoc/plateau/xref.rb', line 7 def initialize(lang, script, klass, i18n, ) @iso = ::IsoDoc::Iso::Xref.new(lang, script, klass, i18n, ) super end |
Instance Method Details
#clause_order_main(_docxml) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/isodoc/plateau/xref.rb', line 12 def clause_order_main(_docxml) [ { path: "//sections/introduction | //sections/clause | " \ "//sections/terms | //sections/definitions | " \ "//sections/references", multi: true }, ] end |
#hierarchical_figure_class_names(clause, num) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/isodoc/plateau/xref.rb', line 62 def hierarchical_figure_class_names(clause, num) c = {} j = 0 clause.xpath(ns(".//figure[@class][not(@class = 'pseudocode')]")) .noblank.each do |t| c[t["class"]] ||= IsoDoc::XrefGen::Counter.new labelled_ancestor(t, %w(figure)) and next j = subfigure_increment(j, c[t["class"]], t) #label = "#{num}#{hier_separator}#{c.print}" sublabel = j.zero? ? nil : "#{(j + 96).chr})" figure_anchor(t, sublabel, hiersemx(clause, num, c[t["class"]], t), t["class"]) end end |
#hierarchical_figure_names(clauses, num) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/isodoc/plateau/xref.rb', line 47 def hierarchical_figure_names(clauses, num) c = IsoDoc::XrefGen::Counter.new j = 0 nodeSet(clauses).each do |clause| clause.xpath(ns(FIGURE_NO_CLASS)).noblank.each do |t| labelled_ancestor(t, %w(figure)) and next # do not label nested figure j = subfigure_increment(j, c, t) #label = "#{num}#{hier_separator}#{c.print}" sublabel = subfigure_label(j) figure_anchor(t, sublabel, hiersemx(clause, num, c, t), "figure") end hierarchical_figure_class_names(clause, num) end end |
#hiersep ⇒ Object
31 32 33 |
# File 'lib/isodoc/plateau/xref.rb', line 31 def hiersep "-" end |
#list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list) ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/isodoc/plateau/xref.rb', line 76 def list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list) @iso.anchors.merge!(@anchors) @iso.list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list) @anchors.merge!(@iso.anchors) end |
#list_item_value(entry, counter, depth, opts) ⇒ Object
84 85 86 87 88 |
# File 'lib/isodoc/plateau/xref.rb', line 84 def list_item_value(entry, counter, depth, opts) @iso.anchors.merge!(@anchors) @iso.list_item_value(entry, counter, depth, opts) @anchors.merge!(@iso.anchors) end |
#middle_asset_names(clause, container: false) ⇒ Object
container makes numbering be prefixed with the parent clause reference
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/isodoc/plateau/xref.rb', line 36 def middle_asset_names(clause, container: false) sequential_formula_names(clause, container:) (clause, container:) clause.each do |c| num = @anchors.dig(c["id"], :label) || @anchors.dig(c["id"], :xref) || c.at(ns("./title"))&.text hierarchical_table_names(c, num) hierarchical_figure_names(c, num) end end |
#middle_section_asset_names(doc) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/isodoc/plateau/xref.rb', line 22 def middle_section_asset_names(doc) middle_sections = "//clause[@type = 'scope'] | #{@klass.norm_ref_xpath} | " \ "//sections/terms | //preface/* | " \ "//sections/definitions | //clause[parent::sections]" # sequential_asset_names(doc.xpath(ns(middle_sections))) middle_asset_names(doc.xpath(ns(middle_sections))) end |