lib/isodoc/iso/base_convert.rb in metanorma-iso-1.3.19 vs lib/isodoc/iso/base_convert.rb in metanorma-iso-1.3.20

- old
+ new

@@ -17,11 +17,10 @@ f = isoxml.at(ns("//introduction")) || return num = f.at(ns(".//clause")) ? "0" : nil title_attr = { class: "IntroTitle" } page_break(out) out.div **{ class: "Section3", id: f["id"] } do |div| - # div.h1 "Introduction", **attr_code(title_attr) clause_name(num, @introduction_lbl, div, title_attr) f.elements.each do |e| if e.name == "patent-notice" e.elements.each { |e1| parse(e1, div) } else @@ -197,9 +196,51 @@ ref end def table_footnote_reference_format(a) a.content = a.content + ")" + end + + def clause_parse_title(node, div, c1, out) + return inline_header_title(out, node, c1) if c1.nil? + super + end + + def cleanup(docxml) + super + remove_internal_hyperlinks(docxml) + table_th_center(docxml) + docxml + end + + def remove_internal_hyperlinks(docxml) + docxml.xpath("//a[@href]").each do |a| + next unless /^#/.match(a[:href]) + anchor = a[:href].sub(/^#/, "") + next if a["epub:type"] == "footnote" + next unless @anchors[anchor] + next unless @anchors[anchor][:type] + next if @anchors[anchor][:type] == "clause" + a.replace(a.children) + end + end + + def table_th_center(docxml) + docxml.xpath("//thead//th | //thead//td").each do |th| + th["align"] = "center" + th["valign"] = "middle" + end + end + + def hierarchical_formula_names(clause, num) + c = IsoDoc::Function::XrefGen::Counter.new + clause.xpath(ns(".//formula")).each do |t| + next if t["id"].nil? || t["id"].empty? + @anchors[t["id"]] = + anchor_struct("#{num}#{hiersep}#{c.increment(t).print}", t, + t["inequality"] ? @inequality_lbl : @formula_lbl, + "formula", t["unnumbered"]) + end end end end end