Module: IsoDoc::Function::References
- Included in:
- Common
- Defined in:
- lib/isodoc/function/references.rb
Instance Method Summary collapse
- #bibitem_entry(list, bib, _ordinal, biblio) ⇒ Object
- #bibitem_notes(list, bib, _ordinal, biblio) ⇒ Object
- #biblio_list(refs, div, biblio) ⇒ Object
- #bibliography(node, out) ⇒ Object
- #bibliography_parse(node, out) ⇒ Object
- #bibliography_xpath ⇒ Object
- #iso_bibitem_entry_attrs(bib, biblio) ⇒ Object
- #norm_ref(node, out) ⇒ Object
- #norm_ref_xpath ⇒ Object
- #reference_format(bib, out) ⇒ Object
Instance Method Details
#bibitem_entry(list, bib, _ordinal, biblio) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/isodoc/function/references.rb', line 4 def bibitem_entry(list, bib, _ordinal, biblio) list.p(**attr_code(iso_bibitem_entry_attrs(bib, biblio))) do |ref| children_parse(bib.at(ns("./biblio-tag")), ref) reference_format(bib, ref) end bibitem_notes(list, bib, _ordinal, biblio) end |
#bibitem_notes(list, bib, _ordinal, biblio) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/isodoc/function/references.rb', line 12 def bibitem_notes(list, bib, _ordinal, biblio) bib.xpath(ns("./formattedref/note")).each do |n| parse(n, list) list.parent.elements[-1]["class"] += biblio ? " Biblio" : " NormRef" end end |
#biblio_list(refs, div, biblio) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/isodoc/function/references.rb', line 28 def biblio_list(refs, div, biblio) i = 0 refs.children.each do |b| if b.name == "bibitem" b["hidden"] == "true" and next i += 1 bibitem_entry(div, b, i, biblio) else parse(b, div) unless %w(fmt-title).include? b.name end end end |
#bibliography(node, out) ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/isodoc/function/references.rb', line 65 def bibliography(node, out) node["hidden"] != "true" or return page_break(out) out.div do |div| div.h1 class: "Section3" do |h1| node.at(ns("./fmt-title"))&.children&.each { |c2| parse(c2, h1) } end biblio_list(node, div, true) end end |
#bibliography_parse(node, out) ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/isodoc/function/references.rb', line 76 def bibliography_parse(node, out) node["hidden"] != true or return out.div do |div| clause_parse_title(node, div, node.at(ns("./fmt-title")), out, { class: "Section3" }) biblio_list(node, div, true) end end |
#bibliography_xpath ⇒ Object
59 60 61 62 63 |
# File 'lib/isodoc/function/references.rb', line 59 def bibliography_xpath "//bibliography/clause[.//references]" \ "[not(.//references[@normative = 'true'])] | " \ "//bibliography/references[@normative = 'false']" end |
#iso_bibitem_entry_attrs(bib, biblio) ⇒ Object
19 20 21 |
# File 'lib/isodoc/function/references.rb', line 19 def iso_bibitem_entry_attrs(bib, biblio) { id: bib["id"], class: biblio ? "Biblio" : "NormRef" } end |
#norm_ref(node, out) ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/isodoc/function/references.rb', line 48 def norm_ref(node, out) node["hidden"] != "true" or return out.div do |div| clause_name(node, node.at(ns("./fmt-title")), div, nil) if node.name == "clause" node.elements.each { |e| parse(e, div) unless e.name == "fmt-title" } else biblio_list(node, div, false) end end end |
#norm_ref_xpath ⇒ Object
41 42 43 44 45 46 |
# File 'lib/isodoc/function/references.rb', line 41 def norm_ref_xpath "//bibliography/references[@normative = 'true'] | " \ "//bibliography/clause[.//references[@normative = 'true']] | " \ "//sections/references[@normative = 'true'] | " \ "//sections/clause[not(@type)][.//references[@normative = 'true']]" end |
#reference_format(bib, out) ⇒ Object
23 24 25 26 |
# File 'lib/isodoc/function/references.rb', line 23 def reference_format(bib, out) ftitle = bib.at(ns("./formattedref")) or return ftitle.children.each { |n| n.name == "note" or parse(n, out) } end |