Module: IsoDoc::Function::Footnotes
- Included in:
- Common
- Defined in:
- lib/isodoc/function/footnotes.rb
Instance Method Summary collapse
- #fmt_review_body_parse(node, out) ⇒ Object
- #footnote_parse(node, out) ⇒ Object
- #get_table_ancestor_id(node) ⇒ Object
- #make_table_footnote_link(out, fnid, node) ⇒ Object
- #table_footnote?(node) ⇒ Boolean
-
#table_footnote_parse(node, out) ⇒ Object
@seen_footnote: do not output footnote text if we have already seen it for this table.
- #update_table_fn_body_ref(fnote, table, reference) ⇒ Object
Instance Method Details
#fmt_review_body_parse(node, out) ⇒ Object
61 |
# File 'lib/isodoc/function/footnotes.rb', line 61 def fmt_review_body_parse(node, out); end |
#footnote_parse(node, out) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/isodoc/function/footnotes.rb', line 51 def footnote_parse(node, out) table_footnote?(node) and return table_footnote_parse(node, out) fn = node["target"] # || UUIDTools::UUID.random_create.to_s attrs = { class: "FootnoteRef", href: "#fn:#{fn}" } f = node.at(ns("./fmt-fn-label")) out.a **attrs do |a| children_parse(f, a) end end |
#get_table_ancestor_id(node) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/isodoc/function/footnotes.rb', line 12 def get_table_ancestor_id(node) table = node.ancestors("table") table.empty? and table = node.ancestors("figure") table.empty? and return [nil, UUIDTools::UUID.random_create.to_s] [table.last, table.last["id"]] end |
#make_table_footnote_link(out, fnid, node) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/isodoc/function/footnotes.rb', line 4 def make_table_footnote_link(out, fnid, node) attrs = { href: "##{fnid}", class: "TableFootnoteRef" } sup = node.at(ns("./sup")) and sup.replace(sup.children) out.a **attrs do |a| children_parse(node, a) end end |
#table_footnote?(node) ⇒ Boolean
46 47 48 49 |
# File 'lib/isodoc/function/footnotes.rb', line 46 def table_footnote?(node) (@in_table || @in_figure) && !node.ancestors.map(&:name).include?("fmt-name") end |
#table_footnote_parse(node, out) ⇒ Object
@seen_footnote: do not output footnote text if we have already seen it for this table
22 23 24 25 26 27 28 29 30 |
# File 'lib/isodoc/function/footnotes.rb', line 22 def table_footnote_parse(node, out) fn = node["reference"] || UUIDTools::UUID.random_create.to_s table, tid = get_table_ancestor_id(node) make_table_footnote_link(out, tid + fn, node.at(ns("./fmt-fn-label"))) # do not output footnote text if we have already seen it for this table @seen_footnote.include?(tid + fn) and return update_table_fn_body_ref(node, table, tid + fn) @seen_footnote << (tid + fn) end |
#update_table_fn_body_ref(fnote, table, reference) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/isodoc/function/footnotes.rb', line 32 def update_table_fn_body_ref(fnote, table, reference) fnbody = table.at(ns(".//fmt-fn-body[@id = '#{fnote['target']}']")) or return fnbody["reference"] = reference fnbody["is_table"] = true sup = fnbody.at(ns(".//fmt-fn-label/sup")) and sup.replace(sup.children) fnbody.xpath(ns(".//fmt-fn-label")).each do |s| s["class"] = "TableFootnoteRef" s.name = "span" d = s.at(ns("./span[@class = 'fmt-caption-delim']")) and s.next = d end end |