Class: IsoDoc::Ieee::Xref
- Inherits:
-
Xref
- Object
- Xref
- IsoDoc::Ieee::Xref
- Defined in:
- lib/isodoc/ieee/xref.rb
Instance Method Summary collapse
- #annex_name_lbl(clause, num) ⇒ Object
- #clause_order_back(docxml) ⇒ Object
- #clause_order_main(docxml) ⇒ Object
- #initial_anchor_names(doc) ⇒ Object
-
#initialize(lang, script, klass, labels, options) ⇒ Xref
constructor
A new instance of Xref.
- #middle_section_asset_names(doc) ⇒ Object
- #middle_sections ⇒ Object
- #note_anchor_names1(notes, counter) ⇒ Object
- #sequential_formula_names(clause, container: false) ⇒ Object
- #termnote_anchor_names(docxml) ⇒ Object
Constructor Details
#initialize(lang, script, klass, labels, options) ⇒ Xref
Returns a new instance of Xref.
9 10 11 12 |
# File 'lib/isodoc/ieee/xref.rb', line 9 def initialize(lang, script, klass, labels, ) super @hierarchical_assets = [:hierarchicalassets] end |
Instance Method Details
#annex_name_lbl(clause, num) ⇒ Object
110 111 112 113 114 115 116 117 |
# File 'lib/isodoc/ieee/xref.rb', line 110 def annex_name_lbl(clause, num) if @doctype == "whitepaper" title = Common::case_with_markup(@labels["annex"], "capital", @script) l10n(labelled_autonum(title, num)) else super end end |
#clause_order_back(docxml) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/isodoc/ieee/xref.rb', line 35 def clause_order_back(docxml) ret = super docxml.at(ns("//bibdata/ext/doctype"))&.text == "whitepaper" and ret.shift ret end |
#clause_order_main(docxml) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/isodoc/ieee/xref.rb', line 19 def clause_order_main(docxml) ret = [ { path: "//sections/abstract" }, # whitepaper { path: "//clause[@type = 'overview']" }, { path: @klass.norm_ref_xpath }, { path: "//sections/terms | " \ "//sections/clause[descendant::terms]" }, { path: "//sections/definitions | " \ "//sections/clause[descendant::definitions][not(descendant::terms)]" }, { path: @klass.middle_clause(docxml), multi: true }, ] docxml.at(ns("//bibdata/ext/doctype"))&.text == "whitepaper" and ret << { path: @klass.bibliography_xpath } ret end |
#initial_anchor_names(doc) ⇒ Object
14 15 16 17 |
# File 'lib/isodoc/ieee/xref.rb', line 14 def initial_anchor_names(doc) @doctype = doc&.at(ns("//bibdata/ext/doctype"))&.text super end |
#middle_section_asset_names(doc) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/isodoc/ieee/xref.rb', line 48 def middle_section_asset_names(doc) middle_sections = "#{@klass.norm_ref_xpath} | //sections/terms | " \ "//sections/definitions | //clause[parent::sections]" if @hierarchical_assets hierarchical_asset_names(doc.xpath("//xmlns:preface/child::*"), "Preface") doc.xpath(ns(middle_sections)).each do |c| hierarchical_asset_names(c, @anchors[c["id"]][:label]) end else sequential_asset_names(doc.xpath(ns("//preface/* | " + middle_sections))) #sequential_asset_names(doc.xpath(ns(middle_sections))) end end |
#middle_sections ⇒ Object
42 43 44 45 46 |
# File 'lib/isodoc/ieee/xref.rb', line 42 def middle_sections " #{@klass.norm_ref_xpath} | " \ "//sections/terms | " \ "//sections/definitions | //clause[parent::sections]" end |
#note_anchor_names1(notes, counter) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/isodoc/ieee/xref.rb', line 98 def note_anchor_names1(notes, counter) sequence = UUIDTools::UUID.random_create.to_s notes.each do |n| next if @anchors[n["id"]] || blank?(n["id"]) @anchors[n["id"]] = anchor_struct(increment_label(notes, n, counter), n, @labels["note_xref"], "note", { container: true }) .merge(sequence: sequence) end end |
#sequential_formula_names(clause, container: false) ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/isodoc/ieee/xref.rb', line 63 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", { container: container, unnumb: t["unnumbered"] } ) end end |
#termnote_anchor_names(docxml) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/isodoc/ieee/xref.rb', line 74 def termnote_anchor_names(docxml) docxml.xpath(ns("//*[termnote]")).each do |t| c = Counter.new sequence = UUIDTools::UUID.random_create.to_s notes = t.xpath(ns("./termnote")) notes.noblank.each do |n| @anchors[n["id"]] = { label: termnote_label(n, increment_label(notes, n, c)), type: "termnote", value: c.print, elem: @labels["termnote"], container: t["id"], xref: anchor_struct_xref(c.print, n, @labels["note_xref"]) } .merge(sequence: sequence) =begin anchor_struct( termnote_label(n, increment_label(notes, n, c)), #labelled_autonum(@labels["termnote"], increment_label(notes, n, c)), #"#{@labels['termnote']} #{increment_label(notes, n, c)}", n, @labels["note_xref"], "termnote", { container: true }) .merge(sequence: sequence) =end end end end |