require_relative "init"
require "roman-numerals"
require "isodoc"
require_relative "../../relaton/render/general"
require_relative "presentation_bibdata"
require_relative "presentation_preface"
module IsoDoc
module ITU
class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
def initialize(options)
@hierarchical_assets = options[:hierarchicalassets]
super
end
def convert1(docxml, filename, dir)
insert_preface_sections(docxml)
super
end
def prefix_container(container, linkend, node, _target)
l10n("#{linkend} #{@i18n.get['in']} #{anchor_xref(node, container)}")
end
def eref(docxml)
docxml.xpath(ns("//eref")).each { |f| eref1(f) }
end
def origin(docxml)
docxml.xpath(ns("//origin[not(termref)]")).each { |f| eref1(f) }
end
def quotesource(docxml)
docxml.xpath(ns("//quote/source")).each { |f| eref1(f) }
end
def eref1(elem)
get_eref_linkend(elem)
end
def note1(elem)
elem["type"] == "title-footnote" and return
super
end
def get_eref_linkend(node)
contents = non_locality_elems(node).select do |c|
!c.text? || /\S/.match(c)
end
return unless contents.empty?
link = anchor_linkend(node,
docid_l10n(node["target"] || node["citeas"]))
link && !/^\[.*\]$/.match(link) and link = "[#{link}]"
link += eref_localities(node.xpath(ns("./locality | ./localityStack")),
link, node)
non_locality_elems(node).each(&:remove)
node.add_child(link)
end
def bibrenderer
::Relaton::Render::ITU::General.new(language: @lang)
end
def bibrender_formattedref(formattedref, _xml)
formattedref << "." unless /\.$/.match?(formattedref.text)
end
def bibrender_relaton(xml, renderings)
f = renderings[xml["id"]][:formattedref]
f &&= "
" \ "#{@i18n.get['section'].upcase} #{lbl}
" end def annex1(elem) elem.at(ns("//bibdata/ext/doctype"))&.text == "resolution" or return super elem.elements.first.previous = annex1_supertitle(elem) t = elem.at(ns("./title")) and t.children = "#{to_xml(t.children)}" end def annex1_supertitle(elem) lbl = @xrefs.anchor(elem["id"], :label) res = elem.at(ns("//bibdata/title[@type = 'resolution']")) subhead = @i18n.l10n("(#{@i18n.get['to']} #{to_xml(res.children)})") "#{lbl}
#{subhead}
#{res.children.to_xml}
" t = @meta.get[:doctitle] and out.previous = "#{t}
" middle_title_resolution_subtitle(isoxml, out) end def middle_title_resolution_subtitle(isoxml, out) ret = "(" d = isoxml.at(ns("//bibdata/title[@type = 'resolution-placedate']")) ret += "#{d.children.to_xml.strip})" ret += "#{title_footnotes(isoxml)}
" out.previous = ret end def middle_title_recommendation(isoxml, out) ret = "" type = @meta.get[:doctype] @meta.get[:unpublished] && @meta.get[:draft_new_doctype] and type = @meta.get[:draft_new_doctype] id = @meta.get[:docnumber] and ret += "<#{type} #{id}
" t = @meta.get[:doctitle] and ret += "#{t}" ret += "#{title_footnotes(isoxml)}
" s = @meta.get[:docsubtitle] and ret += "#{s}
" out.previous = ret end def title_footnotes(isoxml) ret = "" isoxml.xpath(ns("//note[@type = 'title-footnote']")) .each_with_index do |f, i| ret += "