class IsoDoc::NIST::PresentationXMLConvert
Public Instance Methods
annex1(f)
click to toggle source
# File lib/isodoc/nist/presentation_xml_convert.rb, line 32 def annex1(f) lbl = @xrefs.anchor(f['id'], :label) if t = f.at(ns("./title")) t.children = "<strong>#{t.children.to_xml}</strong>" end prefix_name(f, " — ", lbl, "title") t = f.at(ns("./title")) t["xref"] = lbl.gsub(/<[^>]+>/, "") end
bibitem(x)
click to toggle source
# File lib/isodoc/nist/presentation_xml_convert.rb, line 85 def bibitem(x) if f = x.at(ns("./formattedref")) code = render_identifier(bibitem_ref_code(x)) f << " [#{code[1]}] " if code[1] else x.children = ::Iso690Render.render(x.to_xml) end if id = x.at(ns("./docidentifier[@type = 'metanorma']")) id["display"] = "true" id.children = bracket_if_num(id) end end
bracket_if_num(x)
click to toggle source
# File lib/isodoc/nist/presentation_xml_convert.rb, line 79 def bracket_if_num(x) return nil if x.nil? x = x.text.sub(/^\[/, "").sub(/\]$/, "") "[#{x}]" end
clause1(f)
click to toggle source
Calls superclass method
# File lib/isodoc/nist/presentation_xml_convert.rb, line 67 def clause1(f) return if f.name == "references" && suppress_biblio_title(f) super end
convert1(docxml, filename, dir)
click to toggle source
Calls superclass method
# File lib/isodoc/nist/presentation_xml_convert.rb, line 7 def convert1(docxml, filename, dir) info docxml, nil insert_preface_sections(docxml) super end
get_linkend(node)
click to toggle source
# File lib/isodoc/nist/presentation_xml_convert.rb, line 23 def get_linkend(node) contents = non_locality_elems(node).select { |c| !c.text? || /\S/.match(c) } return unless contents.empty? link = anchor_linkend(node, docid_l10n(node["target"] || wrap_brackets(node['citeas']))) link += eref_localities(node.xpath(ns("./locality | ./localityStack")), link, node) non_locality_elems(node).each { |n| n.remove } node.add_child(link) end
insert_keywords(docxml)
click to toggle source
# File lib/isodoc/nist/presentation_xml_convert.rb, line 51 def insert_keywords(docxml) kw = @meta.get[:keywords] kw.empty? and return if abstract = docxml.at(ns("//preface/abstract")) abstract.next = keyword_clause(kw) elsif foreword = docxml.at(ns("//preface/foreword")) foreword.next = keyword_clause(kw) else preface_init_insert_pt(docxml)&.children&.first&.add_previous_sibling(keyword_clause(kw)) end end
insert_preface_sections(docxml)
click to toggle source
# File lib/isodoc/nist/presentation_xml_convert.rb, line 13 def insert_preface_sections(docxml) insert_keywords(docxml) end
keyword_clause(kw)
click to toggle source
# File lib/isodoc/nist/presentation_xml_convert.rb, line 42 def keyword_clause(kw) <<~END <clause id="_#{UUIDTools::UUID.random_create}" type="keyword"> <title>#{@i18n.keywords}</title> #{@i18n.keywords_intro} <p>#{@i18n.l10n(kw.join("; "))}</p></clause> END end
preface_init_insert_pt(docxml)
click to toggle source
# File lib/isodoc/nist/presentation_xml_convert.rb, line 63 def preface_init_insert_pt(docxml) docxml.at(ns("//preface")) || docxml.at(ns("//sections")).add_previous_sibling("<preface> </preface>").first end
references(docxml)
click to toggle source
# File lib/isodoc/nist/presentation_xml_convert.rb, line 72 def references(docxml) docxml.xpath(ns("//references/bibitem")).each do |x| bibitem(x) end @xrefs.parse docxml end
wrap_brackets(txt)
click to toggle source
# File lib/isodoc/nist/presentation_xml_convert.rb, line 17 def wrap_brackets(txt) return txt if /^\[.*\]$/.match txt "[#{txt}]" end