Class: Asciidoctor::Rsd::Converter
- Inherits:
-
Generic::Converter
- Object
- Generic::Converter
- Asciidoctor::Rsd::Converter
- Defined in:
- lib/asciidoctor/rsd/converter.rb,
lib/asciidoctor/rsd/validate.rb
Overview
A Converter implementation that generates RSD output, and a document schema encapsulation of the document for validation
Constant Summary collapse
- XML_ROOT_TAG =
'rsd-standard'.freeze
- XML_NAMESPACE =
'https://www.metanorma.org/ns/rsd'.freeze
Instance Method Summary collapse
- #bibdata_validate(doc) ⇒ Object
- #clause_parse(attrs, xml, node) ⇒ Object
- #configuration ⇒ Object
- #content_validate(doc) ⇒ Object
- #executivesummary_parse(attrs, xml, node) ⇒ Object
- #html_converter(node) ⇒ Object
- #make_preface(x, s) ⇒ Object
- #pdf_converter(node) ⇒ Object
- #sectiontype(node, level = true) ⇒ Object
- #stage_validate(xmldoc) ⇒ Object
- #word_converter(node) ⇒ Object
Instance Method Details
#bibdata_validate(doc) ⇒ Object
9 10 11 |
# File 'lib/asciidoctor/rsd/validate.rb', line 9 def bibdata_validate(doc) stage_validate(doc) end |
#clause_parse(attrs, xml, node) ⇒ Object
40 41 42 43 44 |
# File 'lib/asciidoctor/rsd/converter.rb', line 40 def clause_parse(attrs, xml, node) sectiontype(node) == "executive summary" and return executivesummary_parse(attrs, xml, node) super end |
#configuration ⇒ Object
54 55 56 |
# File 'lib/asciidoctor/rsd/converter.rb', line 54 def configuration Metanorma::Rsd.configuration end |
#content_validate(doc) ⇒ Object
4 5 6 7 |
# File 'lib/asciidoctor/rsd/validate.rb', line 4 def content_validate(doc) super bibdata_validate(doc.root) end |
#executivesummary_parse(attrs, xml, node) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/asciidoctor/rsd/converter.rb', line 46 def executivesummary_parse(attrs, xml, node) xml.executivesummary **attr_code(attrs) do |xml_section| xml_section.title { |t| t << node.title || "Executive Summary" } content = node.content xml_section << content end end |
#html_converter(node) ⇒ Object
58 59 60 |
# File 'lib/asciidoctor/rsd/converter.rb', line 58 def html_converter(node) IsoDoc::Rsd::HtmlConvert.new(html_extract_attributes(node)) end |
#make_preface(x, s) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/asciidoctor/rsd/converter.rb', line 27 def make_preface(x, s) if x.at("//foreword | //introduction | //acknowledgements | "\ "//clause[@preface] | //executivesummary") preface = s.add_previous_sibling("<preface/>").first f = x.at("//foreword") and preface.add_child f.remove f = x.at("//executivesummary") and preface.add_child f.remove f = x.at("//introduction") and preface.add_child f.remove move_clauses_into_preface(x, preface) f = x.at("//acknowledgements") and preface.add_child f.remove end make_abstract(x, s) end |
#pdf_converter(node) ⇒ Object
62 63 64 65 |
# File 'lib/asciidoctor/rsd/converter.rb', line 62 def pdf_converter(node) return nil if node.attr("no-pdf") IsoDoc::Rsd::PdfConvert.new(html_extract_attributes(node)) end |
#sectiontype(node, level = true) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/asciidoctor/rsd/converter.rb', line 15 def sectiontype(node, level = true) ret = node&.attr("heading")&.downcase || node.title.gsub(/<[^>]+>/, "").downcase ret1 = sectiontype_streamline(ret) return ret1 if "symbols and abbreviated terms" == ret1 return ret1 if "executive summary" == ret1 return nil unless !level || node.level == 1 return nil if @seen_headers.include? ret @seen_headers << ret ret1 end |
#stage_validate(xmldoc) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/asciidoctor/rsd/validate.rb', line 13 def stage_validate(xmldoc) stage = xmldoc&.at("//bibdata/status/stage")&.text %w(proposal working-draft committee-draft draft-standard final-draft published withdrawn).include? stage or @log.add("Document Attributes", nil, "#{stage} is not a recognised status") end |
#word_converter(node) ⇒ Object
67 68 69 |
# File 'lib/asciidoctor/rsd/converter.rb', line 67 def word_converter(node) IsoDoc::Rsd::WordConvert.new(doc_extract_attributes(node)) end |