lib/asciidoctor/nist/converter.rb in metanorma-nist-0.2.13 vs lib/asciidoctor/nist/converter.rb in metanorma-nist-0.2.14
- old
+ new
@@ -10,10 +10,12 @@
require "fileutils"
module Asciidoctor
module NIST
class Converter < Standoc::Converter
+ XML_ROOT_TAG = "nist-standard".freeze
+ XML_NAMESPACE = "https://www.metanorma.com/ns/nist".freeze
register_for "nist"
def table(node)
role = node.role || node.attr("style")
@@ -69,33 +71,13 @@
end
end
end.join("\n")
end
- def nistvariable_insert(n)
- acc = []
- n.text.split(/((?<!\{)\{{3}(?!\{)|(?<!\})\}{3}(?!\}))/).each_slice(4).
- map do |a|
- acc << Nokogiri::XML::Text.new(a[0], n.document)
- next unless a.size == 4
- acc << Nokogiri::XML::Node.new("nistvariable", n)
- acc[-1].content = a[2]
- end
- acc
- end
-
def makexml(node)
- result = ["<?xml version='1.0' encoding='UTF-8'?>\n<nist-standard>"]
@draft = node.attributes.has_key?("draft")
- result << noko { |ixml| front node, ixml }
- result << noko { |ixml| middle node, ixml }
- result << "</nist-standard>"
- result = textcleanup(result)
- ret1 = cleanup(Nokogiri::XML(result))
- validate(ret1) unless @novalid
- ret1.root.add_namespace(nil, EXAMPLE_NAMESPACE)
- ret1
+ super
end
def doctype(node)
d = node.attr("doctype")
d = "standard" if d == "article" # article is Asciidoctor default
@@ -158,15 +140,24 @@
def style(n, t)
return
end
+ def sectiontype_streamline(ret)
+ case ret
+ when "glossary", "terminology"
+ "terms and definitions"
+ else
+ super
+ end
+ end
+
def section(node)
a = section_attributes(node)
noko do |xml|
case sectiontype(node)
#when "normative references" then norm_ref_parse(a, xml, node)
- when "glossary", "terminology"
+ when "terms and definitions"
if node.attr("style") == "appendix" && node.level == 1
@term_def = true
terms_annex_parse(a, xml, node)
@term_def = false
else