Class: IsoDoc::Xref
- Includes:
- Function::Utils, IsoDoc::XrefGen::Anchor, IsoDoc::XrefGen::Blocks, IsoDoc::XrefGen::Sections, IsoDoc::XrefGen::Util
- Defined in:
- lib/isodoc/xref.rb,
lib/isodoc/xref/xref_counter_types.rb
Constant Summary
Constants included from IsoDoc::XrefGen::Util
IsoDoc::XrefGen::Util::CHILD_SECTIONS, IsoDoc::XrefGen::Util::SECTIONS_XPATH
Constants included from Function::Utils
Function::Utils::CLAUSE_ANCESTOR, Function::Utils::DOCTYPE_HDR, Function::Utils::HUGESTRICT, Function::Utils::LABELLED_ANCESTOR_ELEMENTS, Function::Utils::NOTE_CONTAINER_ANCESTOR
Constants included from IsoDoc::XrefGen::Sections
IsoDoc::XrefGen::Sections::SUBCLAUSES
Constants included from IsoDoc::XrefGen::Blocks
IsoDoc::XrefGen::Blocks::FIGURE_NO_CLASS, IsoDoc::XrefGen::Blocks::FIRST_LVL_REQ, IsoDoc::XrefGen::Blocks::FIRST_LVL_REQ_RULE, IsoDoc::XrefGen::Blocks::NUMBERED_BLOCKS, IsoDoc::XrefGen::Blocks::REQ_CHILDREN
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
- #anchor(ident, lbl, warning = true) ⇒ Object
- #clause_counter(num = 0, opts = {}) ⇒ Object
- #get ⇒ Object
-
#initialize(lang, script, klass, i18n, options = {}) ⇒ Xref
constructor
Note: if bibrender is no passed in, do not parse references.
- #initialize_empty ⇒ Object
- #initialize_i18n(i18n) ⇒ Object
- #l10n(text, lang = @lang, script = @script, locale = @locale) ⇒ Object
- #list_counter(num = 0, opts = {}) ⇒ Object
- #localise_anchors ⇒ Object
- #ns(xpath) ⇒ Object
-
#parse(docxml) ⇒ Object
extract names for all anchors, xref and label.
-
#parse_inclusions(options) ⇒ Object
parse only the elements set, if any are set defined are: clause: true, refs: true, assets: true.
Methods included from IsoDoc::XrefGen::Util
#blank?, #child_asset_path, #child_sections, #delim_wrap, #hiersemx, #labelled_autonum, #noblank, #sections_xpath, #semx, #stripsemx
Methods included from Function::Utils
#attr_code, #cleanup_entities, #date_range, #emf?, #empty2nil, #eps?, #external_path, #extract_delims, #from_xhtml, #get_clause_id, #get_note_container_id, #header_strip, #header_strip_elem?, #image_localfile, #insert_tab, #labelled_ancestor, #liquid, #noko, #numeric_escapes, #populate_template, #save_dataimage, #save_svg, #sentence_join, #start_of_sentence, #to_xhtml, #to_xhtml_fragment, #to_xhtml_prep, #to_xml
Methods included from IsoDoc::XrefGen::Sections
#annex_anchor_names, #annex_name_anchors, #annex_name_anchors1, #annex_name_lbl, #annex_names, #annex_names1, #asset_anchor_names, #back_anchor_names, #back_clauses_anchor_names, #back_names, #clause_number_semx, #clause_order, #clause_order_annex, #clause_order_back, #clause_order_main, #clause_order_preface, #clause_title, #clausesep, #initial_anchor_names, #main_anchor_names, #middle_section_asset_names, #preface_anchor_names, #preface_name_anchors, #preface_names, #preface_names1, #section_name_anchors, #section_names, #section_names1, #unnumbered_names, #unnumbered_section_name?
Methods included from IsoDoc::XrefGen::Blocks
#admonition_anchor_names, #admonition_anchor_names1, #amend_autonums, #amend_preprocess, #bookmark_anchor_names, #bookmark_container, #deflist_anchor_names, #deflist_anchor_names1, #deflist_term_anchor_lbl, #deflist_term_anchor_names, #dt2xreflabel, #example_anchor_names, #example_anchor_names1, #fig_subfig_label, #figure_anchor, #hier_separator, #hierarchical_asset_names, #hierarchical_figure_class_names, #hierarchical_figure_names, #hierarchical_formula_names, #hierarchical_permission_body, #hierarchical_permission_children, #hierarchical_permission_names, #hierarchical_table_names, #hierfigsep, #hierreqtsep, #hiersep, #id_ancestor, #increment_label, #list_anchor_names, #list_item_anchor_label, #list_item_anchor_names, #list_item_delim, #list_item_value, #nodeSet, #note_anchor_names, #note_anchor_names1, #reqt2class_label, #reqt2class_nested_label, #sequential_asset_names, #sequential_figure_class_names, #sequential_figure_names, #sequential_formula_names, #sequential_permission_body, #sequential_permission_children, #sequential_permission_names, #sequential_table_names, #subfigure_anchor, #subfigure_delim, #subfigure_increment, #subfigure_label, #subfigure_separator, #subreqt_separator, #termexample_anchor_names, #termnote_anchor_names, #termnote_label
Methods included from IsoDoc::XrefGen::Anchor
#anchor_struct, #anchor_struct_label, #anchor_struct_value, #anchor_struct_xref, #get_anchors
Constructor Details
#initialize(lang, script, klass, i18n, options = {}) ⇒ Xref
Note: if bibrender is no passed in, do not parse references
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/isodoc/xref.rb', line 21 def initialize(lang, script, klass, i18n, = {}) initialize_empty @lang = lang @script = script @klass = klass @options = initialize_i18n(i18n) @klass.bibrender ||= [:bibrender] @reqt_models = @klass.requirements_processor .new({ default: "default", lang:, script:, labels: @i18n.get }) end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
18 19 20 |
# File 'lib/isodoc/xref.rb', line 18 def klass @klass end |
Instance Method Details
#anchor(ident, lbl, warning = true) ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/isodoc/xref.rb', line 58 def anchor(ident, lbl, warning = true) return nil if ident.nil? || ident.empty? if warning && !@anchors[ident] @seen.seen(ident) or warn "No label has been processed for ID #{ident}" @seen.add(ident) return "[#{ident}]" end @anchors.dig(ident, lbl) end |
#clause_counter(num = 0, opts = {}) ⇒ Object
5 6 7 8 |
# File 'lib/isodoc/xref/xref_counter_types.rb', line 5 def clause_counter(num = 0, opts = {}) opts[:numerals] ||= :arabic ::IsoDoc::XrefGen::Counter.new(num, opts) end |
#get ⇒ Object
47 48 49 |
# File 'lib/isodoc/xref.rb', line 47 def get @anchors end |
#initialize_empty ⇒ Object
34 35 36 37 38 |
# File 'lib/isodoc/xref.rb', line 34 def initialize_empty @c = HTMLEntities.new @anchors = {} @parse_settings = {} end |
#initialize_i18n(i18n) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/isodoc/xref.rb', line 40 def initialize_i18n(i18n) @i18n = i18n @labels = @i18n.get @klass.i18n = @i18n @locale = @options[:locale] end |
#l10n(text, lang = @lang, script = @script, locale = @locale) ⇒ Object
93 94 95 |
# File 'lib/isodoc/xref.rb', line 93 def l10n(text, lang = @lang, script = @script, locale = @locale) @i18n.l10n(text, lang, script, locale) end |
#list_counter(num = 0, opts = {}) ⇒ Object
10 11 12 |
# File 'lib/isodoc/xref/xref_counter_types.rb', line 10 def list_counter(num = 0, opts = {}) ::IsoDoc::XrefGen::Counter.new(num, opts) end |
#localise_anchors ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/isodoc/xref.rb', line 81 def localise_anchors @anchors.each_value do |v| v[:label] &&= l10n(v[:label]) v[:value] &&= l10n(v[:value]) v[:xref] &&= l10n(v[:xref]) end end |
#ns(xpath) ⇒ Object
89 90 91 |
# File 'lib/isodoc/xref.rb', line 89 def ns(xpath) Common::ns(xpath) end |
#parse(docxml) ⇒ Object
extract names for all anchors, xref and label
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/isodoc/xref.rb', line 70 def parse(docxml) @doctype = docxml.at(ns("//bibdata/ext/doctype"))&.text @seen = SeenAnchor.new(docxml) amend_preprocess(docxml) if @parse_settings.empty? initial_anchor_names(docxml) back_anchor_names(docxml) asset_anchor_names(docxml) localise_anchors @parse_settings = {} end |
#parse_inclusions(options) ⇒ Object
parse only the elements set, if any are set defined are: clause: true, refs: true, assets: true
53 54 55 56 |
# File 'lib/isodoc/xref.rb', line 53 def parse_inclusions() @parse_settings.merge!() self end |