Class: Metanorma::Ietf::Converter
- Inherits:
-
Standoc::Converter
- Object
- Standoc::Converter
- Metanorma::Ietf::Converter
- Defined in:
- lib/metanorma/ietf/front.rb,
lib/metanorma/ietf/blocks.rb,
lib/metanorma/ietf/cleanup.rb,
lib/metanorma/ietf/validate.rb,
lib/metanorma/ietf/converter.rb
Constant Summary collapse
- BCP_KEYWORDS =
["MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", "NOT RECOMMENDED", "OPTIONAL"].freeze
- XML_ROOT_TAG =
"ietf-standard".freeze
- XML_NAMESPACE =
"https://www.metanorma.org/ns/ietf".freeze
Instance Method Summary collapse
- #abstract_cleanup(xmldoc) ⇒ Object
- #annex_attrs_preprocess(attrs, node) ⇒ Object
- #bcp14(node, xml) ⇒ Object
- #bcp14_cleanup(xmldoc) ⇒ Object
-
#boilerplate_isodoc(xmldoc) ⇒ Object
simplified.
- #cache_workgroup(_node) ⇒ Object
- #clause_attrs_preprocess(attrs, node) ⇒ Object
- #cleanup(xmldoc) ⇒ Object
- #content_validate(doc) ⇒ Object
- #cref_cleanup(xmldoc) ⇒ Object
- #default_publisher ⇒ Object
- #dl_attrs(node) ⇒ Object
- #dt_cleanup(xmldoc) ⇒ Object
- #eref_text(node) ⇒ Object
- #html_extract_attributes(node) ⇒ Object
- #image_attributes(node) ⇒ Object
- #image_validate(doc) ⇒ Object
- #init_misc(node) ⇒ Object
-
#initialize(backend, opts) ⇒ Converter
constructor
A new instance of Converter.
- #inline_anchor_xref(node) ⇒ Object
- #inline_indexterm(node) ⇒ Object
- #inline_indexterm1(has_primary, terms, xml) ⇒ Object
- #inline_quoted(node) ⇒ Object
- #introduction_parse(attrs, xml, node) ⇒ Object
- #isodoc(lang, script, locale, i18nyaml = nil) ⇒ Object
- #listing_attrs(node) ⇒ Object
- #literal(node) ⇒ Object
- #makexml(node) ⇒ Object
- #metadata_author(node, xml) ⇒ Object
- #metadata_committee(node, xml) ⇒ Object
- #metadata_committee_types(_node) ⇒ Object
- #metadata_ext(node, xml) ⇒ Object
- #metadata_series(node, xml) ⇒ Object
- #norm_ref_preface(sect) ⇒ Object
- #note(node) ⇒ Object
- #note_cleanup(xmldoc) ⇒ Object
- #ns(path) ⇒ Object
- #ol_attrs(node) ⇒ Object
- #org_abbrev ⇒ Object
- #org_author(node, xml) ⇒ Object
- #outputs(node, ret) ⇒ Object
- #para_attrs(node) ⇒ Object
- #pi_code(rfc_pis, processing_instruction) ⇒ Object
- #quotesource_cleanup(xmldoc) ⇒ Object
- #relaton_relations ⇒ Object
- #rfc_converter(node) ⇒ Object
- #schema_file ⇒ Object
- #section_names_refs_cleanup(xml) ⇒ Object
- #set_pi(node, pi) ⇒ Object
- #sidebar(node) ⇒ Object
- #sidebar_attrs(node) ⇒ Object
- #smartquotes_cleanup(xmldoc) ⇒ Object
- #submission_validate(doc) ⇒ Object
- #table_attrs(node) ⇒ Object
- #title(node, xml) ⇒ Object
- #ul_attrs(node) ⇒ Object
- #workgroup_validate(doc) ⇒ Object
- #xref_cleanup(xmldoc) ⇒ Object
- #xref_rel(node) ⇒ Object
- #xref_text(node) ⇒ Object
- #xref_to_eref(xref, name) ⇒ Object
Constructor Details
#initialize(backend, opts) ⇒ Converter
Returns a new instance of Converter.
22 23 24 25 |
# File 'lib/metanorma/ietf/converter.rb', line 22 def initialize(backend, opts) super @libdir = File.dirname(__FILE__) end |
Instance Method Details
#abstract_cleanup(xmldoc) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/metanorma/ietf/cleanup.rb', line 30 def abstract_cleanup(xmldoc) xmldoc.xpath("//abstract[not(text())]").each do |x| x.remove warn "Empty abstract section removed" end end |
#annex_attrs_preprocess(attrs, node) ⇒ Object
133 134 135 136 137 138 |
# File 'lib/metanorma/ietf/converter.rb', line 133 def annex_attrs_preprocess(attrs, node) attrs[:numbered] = node.attr("numbered") attrs[:removeInRFC] = node.attr("removeInRFC") attrs[:toc] = node.attr("toc") super end |
#bcp14(node, xml) ⇒ Object
65 66 67 68 69 |
# File 'lib/metanorma/ietf/converter.rb', line 65 def bcp14(node, xml) xml.span **{ class: "bcp14" } do |s| s << node.text.upcase end end |
#bcp14_cleanup(xmldoc) ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/metanorma/ietf/cleanup.rb', line 55 def bcp14_cleanup(xmldoc) @bcp_bold or return xmldoc.xpath("//strong").each do |s| BCP_KEYWORDS.include?(s.text) or next s["class"] = "bcp14" s.name = "span" end end |
#boilerplate_isodoc(xmldoc) ⇒ Object
simplified
14 15 16 17 18 19 20 21 |
# File 'lib/metanorma/ietf/cleanup.rb', line 14 def boilerplate_isodoc(xmldoc) x = xmldoc.dup x.root.add_namespace(nil, xml_namespace) #xml = Nokogiri::XML(x.to_xml) @isodoc ||= isodoc(@lang, @script, @locale) # initialise @isodoc.xrefs, for @isodoc.xrefs.info @isodoc end |
#cache_workgroup(_node) ⇒ Object
50 51 52 |
# File 'lib/metanorma/ietf/validate.rb', line 50 def cache_workgroup(_node) Metanorma::Ietf::Data::WORKGROUPS end |
#clause_attrs_preprocess(attrs, node) ⇒ Object
126 127 128 129 130 131 |
# File 'lib/metanorma/ietf/converter.rb', line 126 def clause_attrs_preprocess(attrs, node) attrs[:numbered] = node.attr("numbered") attrs[:removeInRFC] = node.attr("removeInRFC") attrs[:toc] = node.attr("toc") super end |
#cleanup(xmldoc) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/metanorma/ietf/cleanup.rb', line 4 def cleanup(xmldoc) bcp14_cleanup(xmldoc) abstract_cleanup(xmldoc) super cref_cleanup(xmldoc) dt_cleanup(xmldoc) xmldoc end |
#content_validate(doc) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/metanorma/ietf/validate.rb', line 7 def content_validate(doc) super image_validate(doc) workgroup_validate(doc) submission_validate(doc) end |
#cref_cleanup(xmldoc) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/metanorma/ietf/cleanup.rb', line 37 def cref_cleanup(xmldoc) xmldoc.xpath("//crefref").each do |r| if c = xmldoc.at("//annotation[@anchor = '#{r.text}']") id = "_#{UUIDTools::UUID.random_create}" c["from"] = id c["to"] = id r.replace("<bookmark id='#{id}'/>") else @log.add("Crossrefences", r, "No matching annotation for cref:[#{r.text}]", severity: 1) end end end |
#default_publisher ⇒ Object
15 16 17 |
# File 'lib/metanorma/ietf/front.rb', line 15 def default_publisher "IETF" end |
#dl_attrs(node) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/metanorma/ietf/blocks.rb', line 33 def dl_attrs(node) attr_code(id_attr(node).merge( newline: node.attr("newline"), indent: node.attr("indent"), spacing: node.attr("spacing"), )) end |
#dt_cleanup(xmldoc) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/metanorma/ietf/cleanup.rb', line 23 def dt_cleanup(xmldoc) xmldoc.xpath("//dt").each do |dt| /:$/.match?(dt.text.strip) and next dt << ":" end end |
#eref_text(node) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/metanorma/ietf/converter.rb', line 88 def eref_text(node) matched = /^(of|comma|parens|bare),(.*+)$/.match node.text if matched.nil? f = nil c = node&.text&.sub(/^fn: /, "") else f = matched[1] c = matched[2] end [f, c] end |
#html_extract_attributes(node) ⇒ Object
164 165 166 |
# File 'lib/metanorma/ietf/converter.rb', line 164 def html_extract_attributes(node) super.merge(usexinclude: node.attr("use-xinclude")) end |
#image_attributes(node) ⇒ Object
75 76 77 |
# File 'lib/metanorma/ietf/blocks.rb', line 75 def image_attributes(node) super.merge(attr_code(align: node.attr("align"))) end |
#image_validate(doc) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/metanorma/ietf/validate.rb', line 26 def image_validate(doc) doc.xpath("//image").each do |i| i["mimetype"] == "image/svg+xml" and next @log.add("Images", i, "image #{i['src'][0, 40]} is not SVG!", severity: 1) end end |
#init_misc(node) ⇒ Object
39 40 41 42 |
# File 'lib/metanorma/ietf/converter.rb', line 39 def init_misc(node) super @default_doctype = "internet-draft" end |
#inline_anchor_xref(node) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/metanorma/ietf/converter.rb', line 71 def inline_anchor_xref(node) f, c = xref_text(node) f1, c = eref_text(node) if f.nil? t, rel = xref_rel(node) attrs = { target: t, type: "inline", displayFormat: f1, format: f, relative: rel } noko do |xml| xml.xref **attr_code(attrs) do |x| x << c end end end |
#inline_indexterm(node) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/metanorma/ietf/converter.rb', line 144 def inline_indexterm(node) noko do |xml| node.type == :visible and xml << node.text.sub(/^primary:(?=\S)/, "") terms = (node.attr("terms") || [node.text]).map { |x| xml_encode(x) } if /^primary:\S/.match?(terms[0]) terms[0].sub!(/^primary:/, "") has_primary = true end inline_indexterm1(has_primary, terms, xml) end end |
#inline_indexterm1(has_primary, terms, xml) ⇒ Object
156 157 158 159 160 161 162 |
# File 'lib/metanorma/ietf/converter.rb', line 156 def inline_indexterm1(has_primary, terms, xml) xml.index **attr_code(primary: has_primary) do |i| i.primary { |x| x << terms[0] } a = terms[1] and i.secondary { |x| x << a } a = terms[2] and i.tertiary { |x| x << a } end end |
#inline_quoted(node) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/metanorma/ietf/converter.rb', line 44 def inline_quoted(node) noko do |xml| case node.type when :emphasis then xml.em { |s| s << node.text } when :strong then xml.strong { |s| s << node.text } when :monospaced then xml.tt { |s| s << node.text } when :double then xml << "\"#{node.text}\"" when :single then xml << "'#{node.text}'" when :superscript then xml.sup { |s| s << node.text } when :subscript then xml.sub { |s| s << node.text } when :asciimath then stem_parse(node.text, xml, :asciimath, node) when :latexmath then stem_parse(node.text, xml, :latexmath, node) else case node.role when "bcp14" then bcp14(node, xml) else xml << node.text end end end end |
#introduction_parse(attrs, xml, node) ⇒ Object
140 141 142 |
# File 'lib/metanorma/ietf/converter.rb', line 140 def introduction_parse(attrs, xml, node) clause_parse(attrs, xml, node) end |
#isodoc(lang, script, locale, i18nyaml = nil) ⇒ Object
172 173 174 175 176 177 |
# File 'lib/metanorma/ietf/converter.rb', line 172 def isodoc(lang, script, locale, i18nyaml = nil) conv = rfc_converter(EmptyAttr.new) i18n = conv.i18n_init(lang, script, locale, i18nyaml) conv.(lang, script, locale, i18n) conv end |
#listing_attrs(node) ⇒ Object
79 80 81 82 |
# File 'lib/metanorma/ietf/blocks.rb', line 79 def listing_attrs(node) super.merge(attr_code(markers: node.attr("markers"), src: node.attr("src"))) end |
#literal(node) ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'lib/metanorma/ietf/blocks.rb', line 65 def literal(node) noko do |xml| xml.figure **literal_attrs(node) do |f| block_title(node, f) f.pre node.lines.join("\n"), **attr_code(align: node.attr("align"), alt: node.attr("alt")) end end end |
#makexml(node) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/metanorma/ietf/converter.rb', line 27 def makexml(node) @workgroups = cache_workgroup(node) @bcp_bold = !node.attr?("no-rfc-bold-bcp14") @xinclude = node.attr?("use-xinclude") super end |
#metadata_author(node, xml) ⇒ Object
8 9 10 11 |
# File 'lib/metanorma/ietf/front.rb', line 8 def (node, xml) (node, xml) committee_contributors(node, xml, default_publisher, {}) end |
#metadata_committee(node, xml) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/metanorma/ietf/front.rb', line 54 def (node, xml) node.attr("workgroup") or return xml.editorialgroup do |a| committee_component("workgroup", node, a) end end |
#metadata_committee_types(_node) ⇒ Object
19 20 21 |
# File 'lib/metanorma/ietf/front.rb', line 19 def (_node) %w(workgroup) end |
#metadata_ext(node, xml) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/metanorma/ietf/front.rb', line 61 def (node, xml) super x = node.attr("area") and x.split(/,\s*/).each do |a| xml.area a end xml.ipr (node.attr("ipr") || "trust200902") x = node.attr("consensus") and xml.consensus (x != "false") x = node.attr("index-include") and xml.indexInclude (x != "false") x = node.attr("ipr-extract") and xml.iprExtract x x = node.attr("sort-refs") and xml.sortRefs (x != "false") x = node.attr("sym-refs") and xml.symRefs (x != "false") x = node.attr("toc-include") and xml.tocInclude (x != "false") x = node.attr("toc-depth") and xml.tocDepth x x = node.attr("show-on-front-page") and xml.showOnFrontPage (x != "false") xml.pi { |pi| set_pi(node, pi) } end |
#metadata_series(node, xml) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/metanorma/ietf/front.rb', line 27 def (node, xml) xml.series **{ type: "stream" } do |s| s.title (node.attr("submission-type") || "IETF") end a = node.attr("intended-series") and xml.series **{ type: "intended" } do |s| parts = a.split(/ /) s.title parts[0] s.number parts[1..-1].join(" ") if parts.size > 1 end end |
#norm_ref_preface(sect) ⇒ Object
124 |
# File 'lib/metanorma/ietf/converter.rb', line 124 def norm_ref_preface(sect); end |
#note(node) ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/metanorma/ietf/blocks.rb', line 54 def note(node) noko do |xml| xml.note **attr_code(id_attr(node).merge( removeInRFC: node.attr("remove-in-rfc"), )) do |c| block_title(node, c) wrap_in_para(node, c) end end end |
#note_cleanup(xmldoc) ⇒ Object
106 |
# File 'lib/metanorma/ietf/cleanup.rb', line 106 def note_cleanup(xmldoc); end |
#ns(path) ⇒ Object
14 15 16 |
# File 'lib/metanorma/ietf/validate.rb', line 14 def ns(path) ::Metanorma::Utils::ns(path) end |
#ol_attrs(node) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/metanorma/ietf/blocks.rb', line 23 def ol_attrs(node) attr_code(id_attr(node).merge( type: node.attr("format") || olist_style(node.style), group: node.attr("group"), spacing: node.attr("spacing"), indent: node.attr("indent"), start: node.attr("start"), )) end |
#org_abbrev ⇒ Object
23 24 25 |
# File 'lib/metanorma/ietf/front.rb', line 23 def org_abbrev { "Internet Engineering Task Force" => "IETF" } end |
#org_author(node, xml) ⇒ Object
13 |
# File 'lib/metanorma/ietf/front.rb', line 13 def (node, xml); end |
#outputs(node, ret) ⇒ Object
34 35 36 37 |
# File 'lib/metanorma/ietf/converter.rb', line 34 def outputs(node, ret) File.open("#{@filename}.xml", "w:UTF-8") { |f| f.write(ret) } rfc_converter(node).convert("#{@filename}.xml") end |
#para_attrs(node) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/metanorma/ietf/blocks.rb', line 4 def para_attrs(node) attr_code(id_attr(node).merge( "keep-with-next": node.attr("keepWithNext") || node.attr("keep-with-next"), "keep-with-previous": node.attr("keepWithPrevious") || node.attr("keep-with-previous"), indent: node.attr("indent"), )) end |
#pi_code(rfc_pis, processing_instruction) ⇒ Object
119 120 121 122 123 124 |
# File 'lib/metanorma/ietf/front.rb', line 119 def pi_code(rfc_pis, processing_instruction) rfc_pis.each_pair do |k, v| v.nil? and next processing_instruction.send k.to_s, v end end |
#quotesource_cleanup(xmldoc) ⇒ Object
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/metanorma/ietf/cleanup.rb', line 93 def quotesource_cleanup(xmldoc) xmldoc.xpath("//quote/source | //terms/source").each do |x| if x["target"]&.match?(URI::DEFAULT_PARSER.make_regexp) x["uri"] = x["target"] x.delete("target") else xref_to_eref(x, "source") end end end |
#relaton_relations ⇒ Object
4 5 6 |
# File 'lib/metanorma/ietf/front.rb', line 4 def relaton_relations %w(included-in described-by derived-from instance-of obsoletes updates) end |
#rfc_converter(node) ⇒ Object
168 169 170 |
# File 'lib/metanorma/ietf/converter.rb', line 168 def rfc_converter(node) IsoDoc::Ietf::RfcConvert.new(html_extract_attributes(node)) end |
#schema_file ⇒ Object
46 47 48 |
# File 'lib/metanorma/ietf/validate.rb', line 46 def schema_file "ietf.rng" end |
#section_names_refs_cleanup(xml) ⇒ Object
104 |
# File 'lib/metanorma/ietf/cleanup.rb', line 104 def section_names_refs_cleanup(xml); end |
#set_pi(node, pi) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/metanorma/ietf/front.rb', line 78 def set_pi(node, pi) rfc_pis = { artworkdelimiter: node.attr("artworkdelimiter"), artworklines: node.attr("artworklines"), authorship: node.attr("authorship"), autobreaks: node.attr("autobreaks"), background: node.attr("background"), colonspace: node.attr("colonspace"), comments: node.attr("comments"), docmapping: node.attr("docmapping"), editing: node.attr("editing"), emoticonic: node.attr("emoticonic"), footer: node.attr("footer"), header: node.attr("header"), inline: node.attr("inline"), iprnotified: node.attr("iprnotified"), linkmailto: node.attr("linkmailto"), linefile: node.attr("linefile"), notedraftinprogress: node.attr("notedraftinprogress"), private: node.attr("private"), refparent: node.attr("refparent"), rfcedstyle: node.attr("rfcedstyle"), slides: node.attr("slides"), "text-list-symbols": node.attr("text-list-symbols"), tocappendix: node.attr("tocappendix"), tocindent: node.attr("tocindent"), tocnarrow: node.attr("tocnarrow"), tocompact: node.attr("tocompact"), topblock: node.attr("topblock"), useobject: node.attr("useobject"), strict: node.attr("strict"), compact: node.attr("compact"), subcompact: node.attr("subcompact"), tocinclude: node.attr("toc-include") == "false" ? "no" : "yes", tocdepth: node.attr("toc-depth"), symrefs: node.attr("sym-refs"), sortrefs: node.attr("sort-refs"), } pi_code(rfc_pis, pi) end |
#sidebar(node) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/metanorma/ietf/blocks.rb', line 45 def (node) noko do |xml| xml.annotation **(node) do |r| block_title(node, r) wrap_in_para(node, r) end end end |
#sidebar_attrs(node) ⇒ Object
41 42 43 |
# File 'lib/metanorma/ietf/blocks.rb', line 41 def (node) super.merge(attr_code(display: node.attr("display"))) end |
#smartquotes_cleanup(xmldoc) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/metanorma/ietf/cleanup.rb', line 64 def smartquotes_cleanup(xmldoc) xmldoc.traverse do |n| n.text? or next n.replace(HTMLEntities.new.encode( n.text.gsub(/\u2019|\u2018|\u201a|\u201b/, "'") .gsub(/\u201c|\u201d|\u201e|\u201f/, '"') .gsub(/[\u2010-\u2015]/, "-") .gsub(/\u2026/, "...") .gsub(/[\u200b-\u200c]/, "") .gsub(/[\u2000-\u200a]|\u202f|\u205f/, " "), :basic, )) end xmldoc end |
#submission_validate(doc) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/metanorma/ietf/validate.rb', line 18 def submission_validate(doc) stream = doc.at("//bibdata/series[@type = 'stream']/title")&.text status = doc.at("//bibdata/status/stage")&.text stream == "editorial" && status != "informational" and @log.add("Document Attributes", nil, "Editorial stream must have Informational status") end |
#table_attrs(node) ⇒ Object
84 85 86 |
# File 'lib/metanorma/ietf/converter.rb', line 84 def table_attrs(node) super.merge(align: node.attr("align")) end |
#title(node, xml) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/metanorma/ietf/front.rb', line 39 def title(node, xml) ["en"].each do |lang| at = { language: lang, format: "text/plain" } xml.title **attr_code(at.merge(type: "main")) do |t| t << (::Metanorma::Utils::asciidoc_sub(node.attr("title")) || ::Metanorma::Utils::asciidoc_sub(node.attr("title-en")) || ::Metanorma::Utils::asciidoc_sub(node.attr("doctitle"))) end a = node.attr("abbrev") and xml.title a, **attr_code(at.merge(type: "abbrev")) a = node.attr("asciititle") and xml.title a, **attr_code(at.merge(type: "ascii")) end end |
#ul_attrs(node) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/metanorma/ietf/blocks.rb', line 14 def ul_attrs(node) attr_code(id_attr(node).merge( nobullet: node.attr("nobullet") || node.attr("empty"), indent: node.attr("indent"), bare: node.attr("bare"), spacing: node.attr("spacing"), )) end |
#workgroup_validate(doc) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/metanorma/ietf/validate.rb', line 34 def workgroup_validate(doc) @workgroups.empty? and return doc.xpath("//bibdata/contributor[role/description = 'committee']/" \ "organization/subdivision[@type = 'Workgroup']/name").each do |wg| wg_norm = wg.text.sub(/ (Working|Research) Group$/, "") @workgroups.include?(wg_norm) and next @log.add("Document Attributes", nil, "IETF: unrecognised working group #{wg.text}", severity: 1) end end |
#xref_cleanup(xmldoc) ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/metanorma/ietf/cleanup.rb', line 85 def xref_cleanup(xmldoc) super xmldoc.xpath("//xref").each do |x| x.delete("displayFormat") x.delete("relative") end end |
#xref_rel(node) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/metanorma/ietf/converter.rb', line 112 def xref_rel(node) matched = /^([^#]+)#(.+)$/.match node.target if matched.nil? t = node.target.sub(/^#/, "") rel = nil else t = matched[1].sub(/\.(xml|adoc)$/, "") rel = matched[2] end [t, rel] end |
#xref_text(node) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/metanorma/ietf/converter.rb', line 100 def xref_text(node) matched = /^format=(counter|title|none|default)(:.*+)?$/.match node.text if matched.nil? f = nil c = node&.text&.sub(/^fn: /, "") else f = matched[1] c = matched[2]&.sub(/^:/, "") end [f, c] end |
#xref_to_eref(xref, name) ⇒ Object
80 81 82 83 |
# File 'lib/metanorma/ietf/cleanup.rb', line 80 def xref_to_eref(xref, name) super xref.delete("format") end |