Module: Asciidoctor::ISO::Section
- Included in:
- Converter
- Defined in:
- lib/asciidoctor/iso/section.rb
Instance Method Summary collapse
- #annex_parse(attrs, xml, node) ⇒ Object
- #appendix_parse(attrs, xml, node) ⇒ Object
- #bibliography_parse(attrs, xml, node) ⇒ Object
-
#clause_parse(attrs, xml, node) ⇒ Object
Not testing max depth of sections: Asciidoctor already limits it to 5 levels of nesting.
- #in_biblio? ⇒ Boolean
- #in_norm_ref? ⇒ Boolean
- #in_terms? ⇒ Boolean
- #introduction_parse(attrs, xml, node) ⇒ Object
- #norm_ref_parse(attrs, xml, node) ⇒ Object
- #patent_notice_parse(xml, node) ⇒ Object
- #scope_parse(attrs, xml, node) ⇒ Object
- #section(node) ⇒ Object
- #sectiontype(node) ⇒ Object
- #set_obligation(attrs, node) ⇒ Object
- #symbols_parse(attrs, xml, node) ⇒ Object
- #term_def_parse(attrs, xml, node, toplevel) ⇒ Object
-
#term_def_subclause_parse(attrs, xml, node) ⇒ Object
subclause contains subclauses.
- #term_def_title(toplevel, node) ⇒ Object
Instance Method Details
#annex_parse(attrs, xml, node) ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'lib/asciidoctor/iso/section.rb', line 83 def annex_parse(attrs, xml, node) attrs["inline-header".to_sym] = node.option? "inline-header" set_obligation(attrs, node) xml.annex **attr_code(attrs) do |xml_section| xml_section.title { |name| name << node.title } xml_section << node.content end end |
#appendix_parse(attrs, xml, node) ⇒ Object
92 93 94 95 96 97 98 99 |
# File 'lib/asciidoctor/iso/section.rb', line 92 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 |
#bibliography_parse(attrs, xml, node) ⇒ Object
101 102 103 104 105 106 107 108 109 |
# File 'lib/asciidoctor/iso/section.rb', line 101 def bibliography_parse(attrs, xml, node) @biblio = true xml.references **attr_code(attrs) do |xml_section| title = node.level == 1 ? "Bibliography" : node.title xml_section.title { |t| t << title } xml_section << node.content end @biblio = true end |
#clause_parse(attrs, xml, node) ⇒ Object
Not testing max depth of sections: Asciidoctor already limits it to 5 levels of nesting
73 74 75 76 77 78 79 80 81 |
# File 'lib/asciidoctor/iso/section.rb', line 73 def clause_parse(attrs, xml, node) attrs["inline-header".to_sym] = node.option? "inline-header" set_obligation(attrs, node) sect = node.level == 1 ? "clause" : "clause" xml.send sect, **attr_code(attrs) do |xml_section| xml_section.title { |n| n << node.title } unless node.title.nil? xml_section << node.content end end |
#in_biblio? ⇒ Boolean
11 12 13 |
# File 'lib/asciidoctor/iso/section.rb', line 11 def in_biblio? @biblio end |
#in_norm_ref? ⇒ Boolean
19 20 21 |
# File 'lib/asciidoctor/iso/section.rb', line 19 def in_norm_ref? @norm_ref end |
#in_terms? ⇒ Boolean
15 16 17 |
# File 'lib/asciidoctor/iso/section.rb', line 15 def in_terms? @term_def end |
#introduction_parse(attrs, xml, node) ⇒ Object
157 158 159 160 161 162 163 |
# File 'lib/asciidoctor/iso/section.rb', line 157 def introduction_parse(attrs, xml, node) xml.introduction **attr_code(attrs) do |xml_section| xml_section.title = "Introduction" content = node.content xml_section << content end end |
#norm_ref_parse(attrs, xml, node) ⇒ Object
148 149 150 151 152 153 154 155 |
# File 'lib/asciidoctor/iso/section.rb', line 148 def norm_ref_parse(attrs, xml, node) @norm_ref = true xml.references **attr_code(attrs) do |xml_section| xml_section.title { |t| t << "Normative References" } xml_section << node.content end @norm_ref = false end |
#patent_notice_parse(xml, node) ⇒ Object
165 166 167 168 169 170 |
# File 'lib/asciidoctor/iso/section.rb', line 165 def patent_notice_parse(xml, node) # xml.patent_notice do |xml_section| # xml_section << node.content # end xml << node.content end |
#scope_parse(attrs, xml, node) ⇒ Object
172 173 174 175 176 177 178 |
# File 'lib/asciidoctor/iso/section.rb', line 172 def scope_parse(attrs, xml, node) xml.clause **attr_code(attrs) do |xml_section| xml_section.title { |t| t << "Scope" } content = node.content xml_section << content end end |
#section(node) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/asciidoctor/iso/section.rb', line 27 def section(node) a = { id: Utils::anchor_or_uuid(node) } noko do |xml| case sectiontype(node) when "introduction" then if node.level == 1 then introduction_parse(a, xml, node) else clause_parse(a, xml, node) end when "patent notice" then patent_notice_parse(xml, node) when "scope" then scope_parse(a, xml, node) when "normative references" then norm_ref_parse(a, xml, node) when "terms and definitions", "terms, definitions, symbols and abbreviated terms" @term_def = true term_def_parse(a, xml, node, true) @term_def = false when "symbols and abbreviated terms" symbols_parse(a, xml, node) when "bibliography" then bibliography_parse(a, xml, node) else if @term_def then term_def_subclause_parse(a, xml, node) elsif @biblio then bibliography_parse(a, xml, node) elsif node.attr("style") == "appendix" && node.level == 1 annex_parse(a, xml, node) elsif node.option? "appendix" appendix_parse(a, xml, node) else clause_parse(a, xml, node) end end end.join("\n") end |
#sectiontype(node) ⇒ Object
23 24 25 |
# File 'lib/asciidoctor/iso/section.rb', line 23 def sectiontype(node) node&.attr("heading")&.downcase || node.title.downcase end |
#set_obligation(attrs, node) ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/asciidoctor/iso/section.rb', line 61 def set_obligation(attrs, node) attrs[:obligation] = if node.attributes.has_key?("obligation") node.attr("obligation") elsif node.parent.attributes.has_key?("obligation") node.parent.attr("obligation") else "normative" end end |
#symbols_parse(attrs, xml, node) ⇒ Object
111 112 113 114 115 |
# File 'lib/asciidoctor/iso/section.rb', line 111 def symbols_parse(attrs, xml, node) xml.definitions **attr_code(attrs) do |xml_section| xml_section << node.content end end |
#term_def_parse(attrs, xml, node, toplevel) ⇒ Object
138 139 140 141 142 143 144 145 146 |
# File 'lib/asciidoctor/iso/section.rb', line 138 def term_def_parse(attrs, xml, node, toplevel) xml.terms **attr_code(attrs) do |section| section.title { |t| t << term_def_title(toplevel, node) } (s = node.attr("source")) && s.split(/,/).each do |s1| section.termdocsource(nil, **attr_code(target: s1, type: "inline")) end section << node.content end end |
#term_def_subclause_parse(attrs, xml, node) ⇒ Object
subclause contains subclauses
118 119 120 121 122 123 124 125 126 127 |
# File 'lib/asciidoctor/iso/section.rb', line 118 def term_def_subclause_parse(attrs, xml, node) sub = node.find_by(context: :section) { |s| s.level == node.level + 1 } sub.empty? || (return term_def_parse(attrs, xml, node, false)) node.title.casecmp("symbols and abbreviated terms").zero? && (return symbols_parse(attrs, xml, node)) xml.term **attr_code(attrs) do |xml_section| xml_section.preferred { |name| name << node.title } xml_section << node.content end end |
#term_def_title(toplevel, node) ⇒ Object
129 130 131 132 133 134 135 136 |
# File 'lib/asciidoctor/iso/section.rb', line 129 def term_def_title(toplevel, node) return node.title unless toplevel sub = node.find_by(context: :section) do |s| s.title.casecmp("symbols and abbreviated terms").zero? end return "Terms and Definitions" if sub.empty? "Terms, Definitions, Symbols and Abbreviated Terms" end |