lib/asciidoctor/standoc/base.rb in metanorma-standoc-1.3.24 vs lib/asciidoctor/standoc/base.rb in metanorma-standoc-1.3.25

- old
+ new

@@ -13,10 +13,11 @@ module Base XML_ROOT_TAG = "standard-document".freeze XML_NAMESPACE = "https://www.metanorma.org/ns/standoc".freeze Asciidoctor::Extensions.register do + preprocessor Asciidoctor::Standoc::Yaml2TextPreprocessor inline_macro Asciidoctor::Standoc::AltTermInlineMacro inline_macro Asciidoctor::Standoc::DeprecatedTermInlineMacro inline_macro Asciidoctor::Standoc::DomainTermInlineMacro inline_macro Asciidoctor::Standoc::InheritInlineMacro inline_macro Asciidoctor::Standoc::HTML5RubyMacro @@ -25,10 +26,18 @@ treeprocessor Asciidoctor::Standoc::ToDoInlineAdmonitionBlock block Asciidoctor::Standoc::PlantUMLBlockMacro block Asciidoctor::Standoc::PseudocodeBlockMacro end + def xml_root_tag + self.class::XML_ROOT_TAG + end + + def xml_namespace + self.class::XML_NAMESPACE + end + def content(node) node.content end def skip(node, name = nil) @@ -52,10 +61,11 @@ scripts: node.attr("scripts"), scripts_pdf: node.attr("scripts-pdf"), datauriimage: node.attr("data-uri-image"), htmltoclevels: node.attr("htmltoclevels") || node.attr("toclevels"), doctoclevels: node.attr("doctoclevels") || node.attr("toclevels"), + break_up_urls_in_tables: node.attr("break-up-urls-in-tables"), } end def html_converter(node) IsoDoc::HtmlConvert.new(html_extract_attributes(node)) @@ -76,10 +86,11 @@ wordintropage: node.attr("wordintropage"), ulstyle: node.attr("ulstyle"), olstyle: node.attr("olstyle"), htmltoclevels: node.attr("htmltoclevels") || node.attr("toclevels"), doctoclevels: node.attr("doctoclevels") || node.attr("toclevels"), + break_up_urls_in_tables: node.attr("break-up-urls-in-tables"), } end def doc_converter(node) IsoDoc::WordConvert.new(doc_extract_attributes(node)) @@ -163,21 +174,21 @@ ret end def makexml1(node) result = ["<?xml version='1.0' encoding='UTF-8'?>", - "<#{self.class::XML_ROOT_TAG}>"] + "<#{xml_root_tag}>"] result << noko { |ixml| front node, ixml } result << noko { |ixml| middle node, ixml } - result << "</#{self.class::XML_ROOT_TAG}>" + result << "</#{xml_root_tag}>" textcleanup(result) end def makexml(node) result = makexml1(node) ret1 = cleanup(Nokogiri::XML(result)) - ret1.root.add_namespace(nil, self.class::XML_NAMESPACE) + ret1.root.add_namespace(nil, xml_namespace) validate(ret1) unless @novalid ret1 end def draft? @@ -205,30 +216,33 @@ format: seen_xref.children[0]["format"], type: "inline" } end def add_term_source(xml_t, seen_xref, m) - xml_t.origin seen_xref.children[0].content, - **attr_code(term_source_attr(seen_xref)) + if seen_xref.children[0].name == "concept" + xml_t.origin { |o| o << seen_xref.children[0].to_xml } + else + xml_t.origin seen_xref.children[0].content, + **attr_code(term_source_attr(seen_xref)) + end m[:text] && xml_t.modification do |mod| mod.p { |p| p << m[:text].sub(/^\s+/, "") } end end TERM_REFERENCE_RE_STR = <<~REGEXP.freeze - ^(?<xref><xref[^>]+>([^<]*</xref>)?) + ^(?<xref><(xref|concept)[^>]+>([^<]*</(xref|concept)>)?) (,\s(?<text>.*))? $ REGEXP TERM_REFERENCE_RE = Regexp.new(TERM_REFERENCE_RE_STR.gsub(/\s/, "").gsub(/_/, "\\s"), Regexp::IGNORECASE | Regexp::MULTILINE) def extract_termsource_refs(text, node) matched = TERM_REFERENCE_RE.match text matched.nil? and - #Utils::warning(node, "term reference not in expected format", text) - @log.add("Asciidoctor Input", node, "term reference not in expected format: #{text}") + @log.add("Asciidoctor Input", node, "term reference not in expected format: #{text}") matched end def termsource(node) matched = extract_termsource_refs(node.content, node) || return