Class: Metanorma::IHO::Converter

Inherits:
Generic::Converter
  • Object
show all
Defined in:
lib/metanorma/iho/converter.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 =
"iho-standard".freeze
XML_NAMESPACE =
"https://www.metanorma.org/ns/iho".freeze
SERIESNAME =
{
  B: "Bathymetric",
  C: "Capacity Building",
  M: "Miscellaneous",
  P: "Periodic",
  S: "Standards and Specifications",
}.freeze

Instance Method Summary collapse

Instance Method Details

#appendix_parse(attrs, xml, node) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/metanorma/iho/converter.rb', line 21

def appendix_parse(attrs, xml, node)
  attrs["inline-header".to_sym] = node.option? "inline-header"
  set_obligation(attrs, node)
  xml.appendix **attr_code(attrs) do |xml_section|
    xml_section.title { |name| name << node.title }
    xml_section << node.content
  end
end

#clause_parse(attrs, xml, node) ⇒ Object



15
16
17
18
19
# File 'lib/metanorma/iho/converter.rb', line 15

def clause_parse(attrs, xml, node)
  node.option? "appendix" and
    return appendix_parse(attrs, xml, node)
  super
end

#configurationObject



92
93
94
# File 'lib/metanorma/iho/converter.rb', line 92

def configuration
  Metanorma::IHO.configuration
end

#doc_converter(node) ⇒ Object



110
111
112
# File 'lib/metanorma/iho/converter.rb', line 110

def doc_converter(node)
  IsoDoc::IHO::WordConvert.new(doc_extract_attributes(node))
end

#html_converter(node) ⇒ Object



100
101
102
# File 'lib/metanorma/iho/converter.rb', line 100

def html_converter(node)
  IsoDoc::IHO::HtmlConvert.new(html_extract_attributes(node))
end

#metadata_commentperiod(node, xml) ⇒ Object



51
52
53
54
55
56
57
58
# File 'lib/metanorma/iho/converter.rb', line 51

def (node, xml)
  from = node.attr("comment-from") or return
  to = node.attr("comment-to")
  xml.commentperiod do |c|
    c.from from
    c.to to if to
  end
end

#metadata_committee(node, xml) ⇒ Object



60
61
62
63
64
65
66
67
# File 'lib/metanorma/iho/converter.rb', line 60

def (node, xml)
  unless node.attr("workgroup")
    @log.add("AsciiDoc Input", nil,
             "Missing workgroup attribute for document")
    return
  end
  (node, xml)
end

#metadata_committee1(node, xml) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/metanorma/iho/converter.rb', line 69

def (node, xml)
  xml.editorialgroup do |a|
    a.committee do |n|
      n.abbreviation node.attr("committee").upcase
    end
    a.workgroup do |n|
      n.abbreviation node.attr("workgroup").upcase
    end
  end
  i = 2
  while node.attr("workgroup_#{i}")
    xml.editorialgroup do |a|
      a.committee do |n|
        n.abbreviation node.attr("committee_#{i}").upcase
      end
      a.workgroup do |n|
        n.abbreviation node.attr("workgroup_#{i}").upcase
      end
    end
    i += 1
  end
end

#metadata_ext(node, ext) ⇒ Object



46
47
48
49
# File 'lib/metanorma/iho/converter.rb', line 46

def (node, ext)
  super
  (node, ext)
end

#metadata_series(node, xml) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/metanorma/iho/converter.rb', line 38

def (node, xml)
  series = node.attr("series") or return
  xml.series **{ type: "main" } do |s|
    s.title SERIESNAME[series.to_sym] || "N/A"
    s.abbreviation series
  end
end

#pdf_converter(node) ⇒ Object



104
105
106
107
108
# File 'lib/metanorma/iho/converter.rb', line 104

def pdf_converter(node)
  return nil if node.attr("no-pdf")

  IsoDoc::IHO::PdfConvert.new(pdf_extract_attributes(node))
end

#presentation_xml_converter(node) ⇒ Object



96
97
98
# File 'lib/metanorma/iho/converter.rb', line 96

def presentation_xml_converter(node)
  IsoDoc::IHO::PresentationXMLConvert.new(html_extract_attributes(node))
end