Class: Metanorma::Itu::Converter
- Inherits:
-
Standoc::Converter
- Object
- Standoc::Converter
- Metanorma::Itu::Converter
- Defined in:
- lib/metanorma/itu/log.rb,
lib/metanorma/itu/front.rb,
lib/metanorma/itu/front_id.rb,
lib/metanorma/itu/converter.rb,
lib/metanorma/itu/front_contrib.rb
Constant Summary collapse
- ITU_LOG_MESSAGES =
{ # rubocop:disable Naming/VariableNumber "ITU_1": { category: "Document Attributes", error: "%s is not a recognised document type", severity: 2 }, "ITU_2": { category: "Document Attributes", error: "%s is not a recognised status", severity: 2 }, "ITU_3": { category: "Document Attributes", error: "Title includes series name %s", severity: 2 }, "ITU_4": { category: "Style", error: "Requirement possibly in preface: %s", severity: 2 }, "ITU_6": { category: "Document Attributes", error: "Recommendation Status %s inconsistent with AAP", severity: 2 }, "ITU_7": { category: "Document Attributes", error: "Recommendation Status %s inconsistent with TAP", severity: 2 }, "ITU_8": { category: "Style", error: "%s does not match ITU document identifier conventions", severity: 2 }, "ITU_9": { category: "Style", error: "Unnumbered clause out of place", severity: 2 }, "ITU_10": { category: "Style", error: "No Summary has been provided", severity: 2 }, "ITU_11": { category: "Style", error: "No Keywords have been provided", severity: 2 }, "ITU_12": { category: "Style", error: "(terms) %s: %s", severity: 2 }, }.freeze
- ITULANG =
KILL
{ "en" => "E", "fr" => "F", "ar" => "A", "es" => "S", "zh" => "C", "ru" => "R" }.freeze
Instance Method Summary collapse
- #abstract_parse(attrs, xml, node) ⇒ Object
- #clause_parse(attrs, xml, node) ⇒ Object
- #committee_contributors(node, xml, agency, opt) ⇒ Object
- #compact_blank(hash) ⇒ Object
- #default_publisher ⇒ Object
- #doc_converter(node) ⇒ Object
- #doc_extract_attributes(node) ⇒ Object
- #document_scheme(node) ⇒ Object
- #extract_org_attrs_complex(node, opts, source, suffix) ⇒ Object
- #full_committee_id(contrib) ⇒ Object
- #group_period(node, prefix, suffix) ⇒ Object
- #html_converter(node) ⇒ Object
- #html_extract_attributes(node) ⇒ Object
- #init(node) ⇒ Object
- #init_metadata(node) ⇒ Object
- #iso_id(node, xml) ⇒ Object
- #itu_id(node, xml) ⇒ Object
- #itu_id_default(node, params) ⇒ Object
- #itu_id_lang(node, params) ⇒ Object
- #itu_id_out(node, xml, params) ⇒ Object
- #itu_id_params(node) ⇒ Object
- #itu_id_params_add(node) ⇒ Object
- #itu_id_params_core(node) ⇒ Object
- #itu_id_params_num(num) ⇒ Object
- #itu_id_params_sector(node) ⇒ Object
- #itu_id_pub(node) ⇒ Object
- #itu_id_resolve(_node, core, add) ⇒ Object
-
#log_messages ⇒ Object
rubocop:enable Naming/VariableNumber.
- #metadata_committee_prep(node) ⇒ Object
- #metadata_committee_types(_node) ⇒ Object
- #metadata_contribution(node, xml) ⇒ Object
- #metadata_ext(node, xml) ⇒ Object
- #metadata_id_nonprimary(node, xml) ⇒ Object
- #metadata_id_primary(node, xml) ⇒ Object
- #metadata_id_primary_type(_node) ⇒ Object
- #metadata_ip_notice(node, xml) ⇒ Object
- #metadata_keywords(node, xml) ⇒ Object
- #metadata_meeting(mtg, acronym, xml) ⇒ Object
- #metadata_meeting_date(val, xml) ⇒ Object
- #metadata_question(node, xml) ⇒ Object
- #metadata_recommendationstatus(node, xml) ⇒ Object
- #metadata_series(node, xml) ⇒ Object
- #metadata_status(node, xml) ⇒ Object
- #metadata_studyperiod(node, xml) ⇒ Object
- #metadata_techreport(node, xml) ⇒ Object
- #ol_attrs(node) ⇒ Object
- #org_abbrev ⇒ Object
- #org_attrs_add_committees(node, ret, opts, opts_orig) ⇒ Object
- #other_title_defaultlang(node, xml, type) ⇒ Object
- #other_title_otherlangs(node, xml, type) ⇒ Object
- #outputs(node, ret) ⇒ Object
- #pdf_converter(node) ⇒ Object
- #personal_role(node, contrib, suffix) ⇒ Object
- #presentation_xml_converter(node) ⇒ Object
- #provisional_id(node, xml) ⇒ Object
- #recommendation_id(node, xml) ⇒ Object
- #relaton_relations ⇒ Object
- #sectiontype(node, level = true) ⇒ Object
- #sectiontype_streamline(ret) ⇒ Object
- #structured_id(node, xml) ⇒ Object
- #td_id(node, xml) ⇒ Object
- #term_def_subclause_parse(attrs, xml, node) ⇒ Object
- #title(node, xml) ⇒ Object
- #title_defaultlang(node, xml) ⇒ Object
- #title_otherlangs(node, xml) ⇒ Object
- #title_validate(_root) ⇒ Object
Instance Method Details
#abstract_parse(attrs, xml, node) ⇒ Object
100 101 102 103 104 105 106 |
# File 'lib/metanorma/itu/converter.rb', line 100 def abstract_parse(attrs, xml, node) xml.abstract **attr_code(attrs) do |xml_section| # xml_section.title { |name| name << node.title } add_noko_elem(xml_section, "title", node.title) xml_section << node.content end end |
#clause_parse(attrs, xml, node) ⇒ Object
90 91 92 93 94 95 96 97 98 |
# File 'lib/metanorma/itu/converter.rb', line 90 def clause_parse(attrs, xml, node) node.option?("unnumbered") and attrs[:unnumbered] = true case sectiontype1(node) when "conventions" then attrs = attrs.merge(type: "conventions") when "history", "source" attrs[:preface] and attrs = attrs.merge(type: sectiontype1(node)) end super end |
#committee_contributors(node, xml, agency, opt) ⇒ Object
14 15 16 17 |
# File 'lib/metanorma/itu/front_contrib.rb', line 14 def committee_contributors(node, xml, agency, opt) (node) or return super end |
#compact_blank(hash) ⇒ Object
48 49 50 |
# File 'lib/metanorma/itu/front_id.rb', line 48 def compact_blank(hash) hash.compact.reject { |_, v| v.is_a?(String) && v.empty? } end |
#default_publisher ⇒ Object
4 5 6 |
# File 'lib/metanorma/itu/front_contrib.rb', line 4 def default_publisher @i18n.get["ITU"] || @i18n.international_telecommunication_union end |
#doc_converter(node) ⇒ Object
137 138 139 |
# File 'lib/metanorma/itu/converter.rb', line 137 def doc_converter(node) IsoDoc::Itu::WordConvert.new(doc_extract_attributes(node)) end |
#doc_extract_attributes(node) ⇒ Object
117 118 119 120 |
# File 'lib/metanorma/itu/converter.rb', line 117 def doc_extract_attributes(node) super.merge(hierarchicalassets: node.attr("hierarchical-object-numbering")) end |
#document_scheme(node) ⇒ Object
108 109 110 |
# File 'lib/metanorma/itu/converter.rb', line 108 def document_scheme(node) super || "current" end |
#extract_org_attrs_complex(node, opts, source, suffix) ⇒ Object
23 24 25 |
# File 'lib/metanorma/itu/front_contrib.rb', line 23 def extract_org_attrs_complex(node, opts, source, suffix) super.merge(ident: node.attr("#{source}-acronym#{suffix}")).compact end |
#full_committee_id(contrib) ⇒ Object
27 |
# File 'lib/metanorma/itu/front_contrib.rb', line 27 def full_committee_id(contrib); end |
#group_period(node, prefix, suffix) ⇒ Object
78 79 80 81 82 83 |
# File 'lib/metanorma/itu/front.rb', line 78 def group_period(node, prefix, suffix) s = node.attr("#{prefix}group-year-start#{suffix}") || (Date.today.year - (Date.today.year % 2)) e = node.attr("#{prefix}group-year-end#{suffix}") || (s.to_i + 2) [s, e] end |
#html_converter(node) ⇒ Object
129 130 131 |
# File 'lib/metanorma/itu/converter.rb', line 129 def html_converter(node) IsoDoc::Itu::HtmlConvert.new(html_extract_attributes(node)) end |
#html_extract_attributes(node) ⇒ Object
112 113 114 115 |
# File 'lib/metanorma/itu/converter.rb', line 112 def html_extract_attributes(node) super.merge(hierarchicalassets: node.attr("hierarchical-object-numbering")) end |
#init(node) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/metanorma/itu/converter.rb', line 16 def init(node) super @smartquotes = node.attr("smartquotes") == "true" @no_insert_missing_sections = doctype(node) != "recommendation" || node.attr("legacy-do-not-insert-missing-sections") || node.attr("document-schema") == "legacy" end |
#init_metadata(node) ⇒ Object
24 25 26 27 |
# File 'lib/metanorma/itu/converter.rb', line 24 def (node) super @default_doctype = "recommendation" end |
#iso_id(node, xml) ⇒ Object
25 26 27 28 |
# File 'lib/metanorma/itu/front_id.rb', line 25 def iso_id(node, xml) add_noko_elem(xml, "docidentifier", node.attr("common-text-docnumber"), type: "ISO") end |
#itu_id(node, xml) ⇒ Object
42 43 44 45 46 |
# File 'lib/metanorma/itu/front_id.rb', line 42 def itu_id(node, xml) node.attr("docnumber") or return params = itu_id_params(node) itu_id_out(node, xml, params) end |
#itu_id_default(node, params) ⇒ Object
117 118 119 120 121 |
# File 'lib/metanorma/itu/front_id.rb', line 117 def itu_id_default(node, params) p = params.dup p[:base] &&= itu_id_default(node, p[:base]) Pubid::Itu::Identifier.create(**p) end |
#itu_id_lang(node, params) ⇒ Object
123 124 125 126 127 |
# File 'lib/metanorma/itu/front_id.rb', line 123 def itu_id_lang(node, params) params[:base] &&= itu_id_lang(node, params[:base]) params[:language] = @lang Pubid::Itu::Identifier.create(**params) end |
#itu_id_out(node, xml, params) ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/metanorma/itu/front_id.rb', line 104 def itu_id_out(node, xml, params) add_noko_elem(xml, "docidentifier", itu_id_default(node, params) .to_s(i18n_lang: @lang), type: "ITU", primary: "true") id_lang = itu_id_lang(node, params) add_noko_elem(xml, "docidentifier", id_lang.to_s(language: @lang, i18n_lang: @lang), type: "ITU-lang") add_noko_elem(xml, "docidentifier", id_lang .to_s(language: @lang, i18n_lang: @lang, format: :long), type: "ITU-lang-long") end |
#itu_id_params(node) ⇒ Object
57 58 59 |
# File 'lib/metanorma/itu/front_id.rb', line 57 def itu_id_params(node) itu_id_resolve(node, itu_id_params_core(node), itu_id_params_add(node)) end |
#itu_id_params_add(node) ⇒ Object
96 97 98 99 100 101 102 |
# File 'lib/metanorma/itu/front_id.rb', line 96 def itu_id_params_add(node) ret = { part: node.attr("partnumber") } @doctype == "contribution" and ret[:series] = node.attr("group-acronym") || node.attr("group")&.sub("Study Group ", "SG") compact_blank(ret) end |
#itu_id_params_core(node) ⇒ Object
73 74 75 76 77 78 79 80 81 82 |
# File 'lib/metanorma/itu/front_id.rb', line 73 def itu_id_params_core(node) pub = itu_id_pub(node) num = node.attr("docnumber") ret = { sector: itu_id_params_sector(node), publisher: pub[0], copublisher: pub[1..-1] }.compact ret.merge!(itu_id_params_num(num)) ret[:copublisher].empty? and ret.delete(:copublisher) ret end |
#itu_id_params_num(num) ⇒ Object
89 90 91 92 93 94 |
# File 'lib/metanorma/itu/front_id.rb', line 89 def itu_id_params_num(num) if m = /^(?:(?<series>[A-Z])\.)?(?<number>\d+)$/.match(num) { series: m[:series], number: m[:number] } else { number: num } end end |
#itu_id_params_sector(node) ⇒ Object
84 85 86 87 |
# File 'lib/metanorma/itu/front_id.rb', line 84 def itu_id_params_sector(node) node.attr("doctype") == "service-publication" and return nil node.attr("bureau") || "T" end |
#itu_id_pub(node) ⇒ Object
52 53 54 55 |
# File 'lib/metanorma/itu/front_id.rb', line 52 def itu_id_pub(node) (node.attr("publisher") || "ITU").split(/[;,]/) .map(&:strip).map { |x| org_abbrev[x] || x } end |
#itu_id_resolve(_node, core, add) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/metanorma/itu/front_id.rb', line 61 def itu_id_resolve(_node, core, add) ret = core.merge(add) case @doctype when "service-publication" base = ret.merge(series: "OB") ret = { type: :annex, base: base } when "contribution" ret[:type] = :contribution end ret end |
#log_messages ⇒ Object
rubocop:enable Naming/VariableNumber
42 43 44 |
# File 'lib/metanorma/itu/log.rb', line 42 def super.merge(ITU_LOG_MESSAGES) end |
#metadata_committee_prep(node) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/metanorma/itu/front_contrib.rb', line 29 def (node) a = node.attributes.dup a.each do |k, v| /group(type|acronym)/.match?(k) and node.set_attr(k.sub(/group(type|acronym)/, "group-\\1"), v) /group(yearstart|yearend)/.match?(k) and node.set_attr(k.sub(/groupyear(start|end)/, "group-year-\\1"), v) end end |
#metadata_committee_types(_node) ⇒ Object
19 20 21 |
# File 'lib/metanorma/itu/front_contrib.rb', line 19 def (_node) %w(bureau sector group subgroup workgroup) end |
#metadata_contribution(node, xml) ⇒ Object
135 136 137 138 139 140 |
# File 'lib/metanorma/itu/front.rb', line 135 def (node, xml) %w(timing).each do |k| add_noko_elem(xml, k, node.attr(k)) # a = node.attr(k) and xml.send k, a end end |
#metadata_ext(node, xml) ⇒ Object
174 175 176 177 178 179 180 181 182 |
# File 'lib/metanorma/itu/front.rb', line 174 def (node, xml) super (node, xml) (node, xml) (node, xml) (node, xml) (node, xml) (node, xml) end |
#metadata_id_nonprimary(node, xml) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/metanorma/itu/front_id.rb', line 6 def (node, xml) provisional_id(node, xml) td_id(node, xml) recommendation_id(node, xml) iso_id(node, xml) end |
#metadata_id_primary(node, xml) ⇒ Object
38 39 40 |
# File 'lib/metanorma/itu/front_id.rb', line 38 def (node, xml) itu_id(node, xml) end |
#metadata_id_primary_type(_node) ⇒ Object
34 35 36 |
# File 'lib/metanorma/itu/front_id.rb', line 34 def (_node) "ITU" end |
#metadata_ip_notice(node, xml) ⇒ Object
110 111 112 113 114 |
# File 'lib/metanorma/itu/front.rb', line 110 def (node, xml) add_noko_elem(xml, "ip-notice-received", node.attr("ip-notice-received") || "false") # xml.ip_notice_received (node.attr("ip-notice-received") || "false") end |
#metadata_keywords(node, xml) ⇒ Object
81 82 83 84 85 86 87 88 |
# File 'lib/metanorma/itu/converter.rb', line 81 def (node, xml) node.attr("keywords") or return node.attr("keywords").split(/, */).sort.each_with_index do |kw, i| kw_out = i.zero? ? Metanorma::Utils.strict_capitalize_first(kw) : kw add_noko_elem(xml, "keyword", kw_out) # xml.keyword kw_out end end |
#metadata_meeting(mtg, acronym, xml) ⇒ Object
128 129 130 131 132 133 |
# File 'lib/metanorma/itu/front.rb', line 128 def (mtg, acronym, xml) add_noko_elem(xml, "meeting", mtg, acronym: acronym) # xml.meeting **attr_code(acronym: acronym) do |m| # m << mtg # end end |
#metadata_meeting_date(val, xml) ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/metanorma/itu/front.rb', line 142 def (val, xml) xml.meeting_date do |m| d = val.split("/") if d.size > 1 add_noko_elem(m, "from", d[0]) # m.from d[0] add_noko_elem(m, "to", d[1]) # m.to d[1] else add_noko_elem(m, "on", d[0]) # m.on d[0] end end end |
#metadata_question(node, xml) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/metanorma/itu/front.rb', line 64 def (node, xml) vals = csv_split(node.attr("question"), ",").map do |s1| t, v = s1.split(":", 2).map(&:strip) { id: t, value: v } end vals.each do |v| xml.question do |q| add_noko_elem(q, "identifier", v[:id]) # q.identifier a add_noko_elem(q, "name", v[:value]) # q.name a end end end |
#metadata_recommendationstatus(node, xml) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/metanorma/itu/front.rb', line 95 def (node, xml) node.attr("recommendation-from") || node.attr("approval-process") or return xml.recommendationstatus do |s| add_noko_elem(s, "from", node.attr("recommendation-from")) add_noko_elem(s, "to", node.attr("recommendation-to")) node.attr("approval-process") and add_noko_elem(s, "approvalstage", node.attr("approval-status"), process: node.attr("approval-process")) # s.approvalstage **{ process: node.attr("approval-process") } do |x| # x << node.attr("approval-status") # end end end |
#metadata_series(node, xml) ⇒ Object
85 86 87 88 89 90 91 92 93 |
# File 'lib/metanorma/itu/front.rb', line 85 def (node, xml) { series: "main", series1: "secondary", series2: "tertiary" } .each do |k, v| node.attr(k.to_s) and xml.series type: v do |s| add_noko_elem(s, "title", node.attr(k.to_s)) end end end |
#metadata_status(node, xml) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/metanorma/itu/front.rb', line 8 def (node, xml) stage = node.attr("status") || node.attr("docstage") || "published" stage = "draft" if node.attributes.has_key?("draft") xml.status do |s| add_noko_elem(s, "stage", stage, abbreviation: node.attr("docstage-abbrev")) end end |
#metadata_studyperiod(node, xml) ⇒ Object
166 167 168 169 170 171 172 |
# File 'lib/metanorma/itu/front.rb', line 166 def (node, xml) s, e = group_period(node, "", "") xml.studyperiod do |p| add_noko_elem(p, "start", s.to_s) add_noko_elem(p, "end", e.to_s) end end |
#metadata_techreport(node, xml) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/metanorma/itu/front.rb', line 116 def (node, xml) a = node.attr("meeting") and (a, node.attr("meeting-acronym"), xml) add_noko_elem(xml, "meeting_place", node.attr("meeting-place")) # a = node.attr("meeting-place") and xml.meeting_place a a = node.attr("meeting-date") and (a, xml) add_noko_elem(xml, "intended_type", node.attr("intended-type")) # a = node.attr("intended-type") and xml.intended_type a add_noko_elem(xml, "source", node.attr("source")) # a = node.attr("source") and xml.source a end |
#ol_attrs(node) ⇒ Object
29 30 31 32 33 |
# File 'lib/metanorma/itu/converter.rb', line 29 def ol_attrs(node) ret = super ret.delete(:type) ret.merge(class: node.attr("class")) end |
#org_abbrev ⇒ Object
8 9 10 11 12 |
# File 'lib/metanorma/itu/front_contrib.rb', line 8 def org_abbrev if @i18n.get["ITU"] { @i18n.international_telecommunication_union => @i18n.get["ITU"] } else {} end end |
#org_attrs_add_committees(node, ret, opts, opts_orig) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/metanorma/itu/front_contrib.rb', line 39 def org_attrs_add_committees(node, ret, opts, opts_orig) opts_orig[:groups]&.each_with_index do |g, i| i.zero? and next contributors_committees_pad_multiples(ret.first, node, g) opts = committee_contrib_org_prep(node, g, nil, opts_orig) ret << org_attrs_parse_core(node, opts).map do |x| x.merge(subdivtype: opts[:subdivtype]) end end contributors_committees_nest1(ret) end |
#other_title_defaultlang(node, xml, type) ⇒ Object
51 52 53 54 |
# File 'lib/metanorma/itu/front.rb', line 51 def other_title_defaultlang(node, xml, type) a = node.attr(type) || node.attr("#{type}-#{@lang}") add_title_xml(xml, a, @lang, type.sub("-title", "")) end |
#other_title_otherlangs(node, xml, type) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/metanorma/itu/front.rb', line 56 def other_title_otherlangs(node, xml, type) node.attributes.each do |k, v| m = /^#{type}-(?<lang>.+)$/.match(k) or next m[:lang] == @lang and next add_title_xml(xml, v, m[:lang], type.sub("-title", "")) end end |
#outputs(node, ret) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/metanorma/itu/converter.rb', line 35 def outputs(node, ret) File.open("#{@filename}.xml", "w:UTF-8") { |f| f.write(ret) } presentation_xml_converter(node).convert("#{@filename}.xml") html_converter(node).convert("#{@filename}.presentation.xml", nil, false, "#{@filename}.html") doc_converter(node).convert("#{@filename}.presentation.xml", nil, false, "#{@filename}.doc") node.attr("no-pdf") or pdf_converter(node)&.convert("#{@filename}.presentation.xml", nil, false, "#{@filename}.pdf") end |
#pdf_converter(node) ⇒ Object
133 134 135 |
# File 'lib/metanorma/itu/converter.rb', line 133 def pdf_converter(node) IsoDoc::Itu::PdfConvert.new(pdf_extract_attributes(node)) end |
#personal_role(node, contrib, suffix) ⇒ Object
157 158 159 160 161 162 163 164 |
# File 'lib/metanorma/itu/front.rb', line 157 def personal_role(node, contrib, suffix) if node.attr("role#{suffix}")&.downcase == "rapporteur" add_noko_elem(contrib, "role", "raporteur", type: "editor") # contrib.role "raporteur", **{ type: "editor" } else super end end |
#presentation_xml_converter(node) ⇒ Object
122 123 124 125 126 127 |
# File 'lib/metanorma/itu/converter.rb', line 122 def presentation_xml_converter(node) IsoDoc::Itu::PresentationXMLConvert .new(html_extract_attributes(node) .merge(output_formats: ::Metanorma::Itu::Processor.new .output_formats)) end |
#provisional_id(node, xml) ⇒ Object
13 14 15 16 17 |
# File 'lib/metanorma/itu/front_id.rb', line 13 def provisional_id(node, xml) node.attr("provisional-name") or return add_noko_elem(xml, "docidentifier", node.attr("provisional-name"), type: "ITU-provisional") end |
#recommendation_id(node, xml) ⇒ Object
129 130 131 132 133 134 |
# File 'lib/metanorma/itu/front_id.rb', line 129 def recommendation_id(node, xml) node.attr("recommendationnumber") or return node.attr("recommendationnumber").split("/").each do |s| add_noko_elem(xml, "docidentifier", s, type: "ITU-Recommendation") end end |
#relaton_relations ⇒ Object
17 18 19 |
# File 'lib/metanorma/itu/front.rb', line 17 def relaton_relations super + %w(complements) end |
#sectiontype(node, level = true) ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/metanorma/itu/converter.rb', line 59 def sectiontype(node, level = true) ret = super hdr = sectiontype_streamline(node.attr("heading")&.downcase) return nil if ret == "terms and definitions" && hdr != "terms and definitions" && node.level > 1 return nil if ret == "symbols and abbreviated terms" && hdr != "symbols and abbreviated terms" && node.level > 1 ret end |
#sectiontype_streamline(ret) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/metanorma/itu/converter.rb', line 47 def sectiontype_streamline(ret) case ret when "definitions", "terms defined elsewhere", "terms defined in this recommendation" "terms and definitions" when "abbreviations and acronyms" then "symbols and abbreviated terms" when "references" then "normative references" else super end end |
#structured_id(node, xml) ⇒ Object
136 137 138 139 140 141 142 143 144 145 |
# File 'lib/metanorma/itu/front_id.rb', line 136 def structured_id(node, xml) node.attr("docnumber") or return xml.structuredidentifier do |i| add_noko_elem(i, "bureau", node.attr("bureau") || "T") add_noko_elem(i, "docnumber", node.attr("docnumber")) add_noko_elem(i, "annexid", node.attr("annexid")) add_noko_elem(i, "amendment", node.attr("amendment-number")) add_noko_elem(i, "corrigendum", node.attr("corrigendum-number")) end end |
#td_id(node, xml) ⇒ Object
19 20 21 22 23 |
# File 'lib/metanorma/itu/front_id.rb', line 19 def td_id(node, xml) node.attr("td-number") or return add_noko_elem(xml, "docidentifier", node.attr("td-number"), type: "ITU-TemporaryDocument") end |
#term_def_subclause_parse(attrs, xml, node) ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/metanorma/itu/converter.rb', line 70 def term_def_subclause_parse(attrs, xml, node) case sectiontype1(node) when "terms defined in this recommendation" term_def_parse(attrs.merge(type: "internal"), xml, node, false) when "terms defined elsewhere" term_def_parse(attrs.merge(type: "external"), xml, node, false) else super end end |
#title(node, xml) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/metanorma/itu/front.rb', line 40 def title(node, xml) title_defaultlang(node, xml) title_otherlangs(node, xml) title_fallback(node, xml) %w(subtitle amendment-title corrigendum-title collection-title slogan-title).each do |t| other_title_defaultlang(node, xml, t) other_title_otherlangs(node, xml, t) end end |
#title_defaultlang(node, xml) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/metanorma/itu/front.rb', line 21 def title_defaultlang(node, xml) a = node.attr("title") || node.attr("title-#{@lang}") or return add_title_xml(xml, a, @lang, "main") if a = node.attr("annextitle") || node.attr("annextitle-#{@lang}") add_title_xml(xml, a, @lang, "annex") end title_nums(node, xml, @lang) end |
#title_otherlangs(node, xml) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/metanorma/itu/front.rb', line 30 def title_otherlangs(node, xml) node.attributes.each do |k, v| /^(?:annex)?title-(?<lang>.+)$/ =~ k or next lang == @lang and next type = /^annex/.match?(k) ? "annex" : "main" add_title_xml(xml, v, lang, type) title_nums(node, xml, lang) end end |
#title_validate(_root) ⇒ Object
12 13 14 |
# File 'lib/metanorma/itu/converter.rb', line 12 def title_validate(_root) nil end |