Sha256: 50950ffdbb8a63712bb25bc199c05a7e2543a23f98bded4d14ec3a29ddaaa225

Contents?: true

Size: 1.85 KB

Versions: 8

Compression:

Stored size: 1.85 KB

Contents

module Asciidoctor
  module MPFA

    # A {Converter} implementation that generates MPFD output, and a document
    # schema encapsulation of the document for validation
    #
    class Converter < Standoc::Converter

      def sections_cleanup(xml)
        super
        xml.xpath("//*[@inline-header]").each do |h|
          h.delete("inline-header")
        end
        xml.xpath("//*[@guidance]").each do |h|
          c = h.xpath("./preceding-sibling::clause")
          c.empty? and next
          c.last.add_child h.remove
        end
      end

      def sectiontype_streamline(ret)
        case ret
        when "glossary" then "terms and definitions"
        else
          super
        end
      end

      def term_def_title(_toplevel, node)
        node.title
      end

      def move_sections_into_preface(x, preface)
        foreword = x.at("//foreword")
        preface.add_child foreword.remove if foreword
        introduction = x.at("//introduction")
        preface.add_child introduction.remove if introduction
        terms = x.at("//sections/clause[descendant::terms]") || x.at("//terms")
        preface.add_child terms.remove if terms
        move_clauses_into_preface(x, preface)
        acknowledgements = x.at("//acknowledgements")
        preface.add_child acknowledgements.remove if acknowledgements
      end

      def make_preface(x, s)
        if x.at("//foreword | //introduction | //terms | //acknowledgements |"\
            "//abstract[not(ancestor::bibitem)] | //clause[@preface]")
          preface = s.add_previous_sibling("<preface/>").first
          move_sections_into_preface(x, preface)
          make_abstract(x, s)
        end
      end

      def clause_parse(attrs, xml, node)
        attrs[:guidance] = true if node.role == "guidance"
        attrs[:container] = true if node.role == "container"
        super
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
metanorma-mpfa-0.7.5 lib/asciidoctor/mpfa/section.rb
metanorma-mpfa-0.7.4 lib/asciidoctor/mpfa/section.rb
metanorma-mpfa-0.7.3 lib/asciidoctor/mpfa/section.rb
metanorma-mpfa-0.7.2 lib/asciidoctor/mpfa/section.rb
metanorma-mpfa-0.7.1 lib/asciidoctor/mpfa/section.rb
metanorma-mpfa-0.7.0 lib/asciidoctor/mpfa/section.rb
metanorma-mpfa-0.6.13 lib/asciidoctor/mpfa/section.rb
metanorma-mpfa-0.6.12 lib/asciidoctor/mpfa/section.rb