Class: Metanorma::Iho::Converter

Inherits:
Generic::Converter
  • Object
show all
Defined in:
lib/metanorma/iho/converter.rb

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



18
19
20
21
22
23
24
25
# File 'lib/metanorma/iho/converter.rb', line 18

def appendix_parse(attrs, xml, node)
  attrs[:"inline-header"] = 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



12
13
14
15
16
# File 'lib/metanorma/iho/converter.rb', line 12

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

#configurationObject



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

def configuration
  Metanorma::Iho.configuration
end

#doc_converter(node) ⇒ Object



119
120
121
# File 'lib/metanorma/iho/converter.rb', line 119

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

#html_converter(node) ⇒ Object



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

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

#metadata_commentperiod(node, xml) ⇒ Object



48
49
50
51
52
53
54
55
# File 'lib/metanorma/iho/converter.rb', line 48

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



57
58
59
60
61
62
63
64
# File 'lib/metanorma/iho/converter.rb', line 57

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



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

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



43
44
45
46
# File 'lib/metanorma/iho/converter.rb', line 43

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

#metadata_series(node, xml) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/metanorma/iho/converter.rb', line 35

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

#metadata_version(node, xml) ⇒ Object



89
90
91
92
93
94
95
96
97
# File 'lib/metanorma/iho/converter.rb', line 89

def (node, xml)
  if node.attr("edition-major")
    ed = node.attr("edition-major")
    e1 = node.attr("edition-minor") and ed += ".#{e1}"
    (e2 = node.attr("edition-patch")) && e1 and ed += ".#{e2}"
    node.set_attribute("edition", ed)
  end
  super
end

#pdf_converter(node) ⇒ Object



113
114
115
116
117
# File 'lib/metanorma/iho/converter.rb', line 113

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



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

def presentation_xml_converter(node)
  IsoDoc::Iho::PresentationXMLConvert
    .new(html_extract_attributes(node)
    .merge(output_formats: ::Metanorma::Iho::Processor.new.output_formats))
end