require_relative "cleanup_biblio" module Metanorma module Iso class Converter < Standoc::Converter PRE_NORMREF_FOOTNOTES = "//preface//fn | " \ "//clause[@type = 'scope']//fn".freeze NORMREF_FOOTNOTES = "//references[@normative = 'true']//fn | " \ "//clause[.//references[@normative = 'true']]//fn".freeze POST_NORMREF_FOOTNOTES = "//sections//clause[not(@type = 'scope')]//fn | " \ "//annex//fn | //references[@normative = 'false']//fn | " \ "//clause[.//references[@normative = 'false']]//fn".freeze NORM_REF = "//bibliography/references[@normative = 'true'][not(@hidden)] | " \ "//bibliography/clause[.//references[@normative = 'true']] | "\ "//sections//references[@normative = 'true'][not(@hidden)]" .freeze def other_footnote_renumber(xmldoc) seen = {} i = 0 [PRE_NORMREF_FOOTNOTES, NORMREF_FOOTNOTES, POST_NORMREF_FOOTNOTES].each do |xpath| xmldoc.xpath(xpath).each do |fn| i, seen = other_footnote_renumber1(fn, i, seen) end end end def ol_cleanup(doc) doc.xpath("//ol[@explicit-type]").each do |x| x["type"] = x["explicit-type"] x.delete("explicit-type") @log.add("Style", x, "Style override set for ordered list") end end TERM_CLAUSE = "//sections//terms[not(preceding-sibling::clause)] | " \ "//sections//clause[descendant::terms][not(descendant::definitions)][@type = 'terms'] | " \ "//sections/clause[not(@type = 'terms')][not(descendant::definitions)]//terms".freeze def sections_cleanup(xml) super @amd or return xml.xpath("//*[@inline-header]").each { |h| h.delete("inline-header") } end def boilerplate_file(_xmldoc) file = case @lang when "fr" then "boilerplate-fr.adoc" when "ru" then "boilerplate-ru.adoc" else "boilerplate.adoc" end File.join(@libdir, file) end def footnote_cleanup(xmldoc) unpub_footnotes(xmldoc) super end def unpub_footnotes(xmldoc) xmldoc.xpath("//bibitem/note[@type = 'Unpublished-Status']").each do |n| e = xmldoc.at("//eref[@bibitemid = '#{n.parent['id']}']") or next fn = n.children.to_xml n.elements&.first&.name == "p" or fn = "
#{fn}
" e.next = "