Module: IsoDoc::Iso::BaseConvert
- Included in:
- HtmlConvert, WordConvert
- Defined in:
- lib/isodoc/iso/sections.rb,
lib/isodoc/iso/base_convert.rb
Instance Method Summary collapse
- #admonition_class(node) ⇒ Object
- #admonition_name_parse(_node, div, name) ⇒ Object
- #admonition_p_parse(node, div, name) ⇒ Object
- #admonition_parse(node, out) ⇒ Object
- #admonition_parse1(node, div, name) ⇒ Object
- #annex(isoxml, out) ⇒ Object
- #clause_etc(isoxml, out, num) ⇒ Object
- #clause_etc1(clause, out, num) ⇒ Object
- #cleanup(docxml) ⇒ Object
- #convert1(docxml, filename, dir) ⇒ Object
-
#error_parse(node, out) ⇒ Object
terms not defined in standoc.
- #example_p_parse(node, div) ⇒ Object
- #example_parse(node, out) ⇒ Object
- #example_parse1(node, div) ⇒ Object
- #example_span_label(_node, div, name) ⇒ Object
- #figure_name_parse(_node, div, name) ⇒ Object
- #foreword(isoxml, out) ⇒ Object
- #formula_where(dlist, out) ⇒ Object
- #implicit_reference(bib) ⇒ Object
- #indexsect(isoxml, out) ⇒ Object
- #introduction(isoxml, out) ⇒ Object
- #middle(isoxml, out) ⇒ Object
- #middle_title(_isoxml, out) ⇒ Object
- #middle_title_amd(out) ⇒ Object
- #middle_title_main(out) ⇒ Object
- #node_begins_with_para(node) ⇒ Object
- #ol_attrs(node) ⇒ Object
- #table_th_center(docxml) ⇒ Object
Instance Method Details
#admonition_class(node) ⇒ Object
115 116 117 118 119 |
# File 'lib/isodoc/iso/base_convert.rb', line 115 def admonition_class(node) if node["type"] == "editorial" then "zzHelp" else super end end |
#admonition_name_parse(_node, div, name) ⇒ Object
136 137 138 139 |
# File 'lib/isodoc/iso/base_convert.rb', line 136 def admonition_name_parse(_node, div, name) name.children.each { |n| parse(n, div) } div << " — " end |
#admonition_p_parse(node, div, name) ⇒ Object
128 129 130 131 132 133 134 |
# File 'lib/isodoc/iso/base_convert.rb', line 128 def admonition_p_parse(node, div, name) div.p do |p| admonition_name_parse(node, p, name) if name node.first_element_child.children.each { |n| parse(n, p) } end node.element_children[1..-1].each { |n| parse(n, div) } end |
#admonition_parse(node, out) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/isodoc/iso/base_convert.rb', line 103 def admonition_parse(node, out) type = node["type"] name = admonition_name(node, type) out.div **{ id: node["id"], class: admonition_class(node) } do |div| if node.first_element_child.name == "p" admonition_p_parse(node, div, name) else admonition_parse1(node, div, name) end end end |
#admonition_parse1(node, div, name) ⇒ Object
121 122 123 124 125 126 |
# File 'lib/isodoc/iso/base_convert.rb', line 121 def admonition_parse1(node, div, name) div.p do |p| admonition_name_parse(node, p, name) if name end node.children.each { |n| parse(n, div) unless n.name == "name" } end |
#annex(isoxml, out) ⇒ Object
32 33 34 35 36 |
# File 'lib/isodoc/iso/sections.rb', line 32 def annex(isoxml, out) amd(isoxml) and @suppressheadingnumbers = @oldsuppressheadingnumbers super amd(isoxml) and @suppressheadingnumbers = true end |
#clause_etc(isoxml, out, num) ⇒ Object
160 161 162 163 164 165 166 |
# File 'lib/isodoc/iso/base_convert.rb', line 160 def clause_etc(isoxml, out, num) isoxml.xpath(ns("//sections/clause[not(@type = 'scope')] | "\ "//sections/terms | //sections/definitions")) .each do |f| clause_etc1(f, out, num) end end |
#clause_etc1(clause, out, num) ⇒ Object
168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/isodoc/iso/base_convert.rb', line 168 def clause_etc1(clause, out, num) out.div **attr_code( id: clause["id"], class: clause.name == "definitions" ? "Symbols" : nil, ) do |div| num = num + 1 clause_name(num, clause&.at(ns("./title")), div, nil) clause.elements.each do |e| parse(e, div) unless %w{title source}.include? e.name end end end |
#cleanup(docxml) ⇒ Object
76 77 78 79 80 |
# File 'lib/isodoc/iso/base_convert.rb', line 76 def cleanup(docxml) super table_th_center(docxml) docxml end |
#convert1(docxml, filename, dir) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/isodoc/iso/base_convert.rb', line 8 def convert1(docxml, filename, dir) if amd(docxml) @oldsuppressheadingnumbers = @suppressheadingnumbers @suppressheadingnumbers = true end super end |
#error_parse(node, out) ⇒ Object
terms not defined in standoc
23 24 25 26 27 28 29 |
# File 'lib/isodoc/iso/base_convert.rb', line 23 def error_parse(node, out) case node.name when "appendix" then clause_parse(node, out) else super end end |
#example_p_parse(node, div) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/isodoc/iso/base_convert.rb', line 39 def example_p_parse(node, div) div.p do |p| example_span_label(node, p, node&.at(ns("./name"))&.remove) insert_tab(p, 1) node.first_element_child.children.each { |n| parse(n, p) } end node.element_children[1..-1].each { |n| parse(n, div) } end |
#example_parse(node, out) ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/isodoc/iso/base_convert.rb', line 66 def example_parse(node, out) out.div **{ id: node["id"], class: "example" } do |div| if node_begins_with_para(node) example_p_parse(node, div) else example_parse1(node, div) end end end |
#example_parse1(node, div) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/isodoc/iso/base_convert.rb', line 48 def example_parse1(node, div) div.p do |p| example_span_label(node, p, node.at(ns("./name"))) insert_tab(p, 1) end node.children.each { |n| parse(n, div) unless n.name == "name" } end |
#example_span_label(_node, div, name) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/isodoc/iso/base_convert.rb', line 31 def example_span_label(_node, div, name) return if name.nil? div.span **{ class: "example_label" } do |p| name.children.each { |n| parse(n, p) } end end |
#figure_name_parse(_node, div, name) ⇒ Object
141 142 143 144 145 |
# File 'lib/isodoc/iso/base_convert.rb', line 141 def figure_name_parse(_node, div, name) div.p **{ class: "FigureTitle", style: "text-align:center;" } do |p| name&.children&.each { |n| parse(n, p) } end end |
#foreword(isoxml, out) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/isodoc/iso/sections.rb', line 50 def foreword(isoxml, out) f = isoxml.at(ns("//foreword")) || return @foreword = true page_break(out) out.div **attr_code(id: f["id"]) do |s| clause_name(nil, f.at(ns("./title")) || @i18n.foreword, s, { class: "ForewordTitle" }) f.elements.each { |e| parse(e, s) unless e.name == "title" } end @foreword = false end |
#formula_where(dlist, out) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/isodoc/iso/base_convert.rb', line 89 def formula_where(dlist, out) return if dlist.nil? return super unless dlist&.xpath(ns("./dt"))&.size == 1 && dlist&.at(ns("./dd"))&.elements&.size == 1 && dlist&.at(ns("./dd/p")) out.span **{ class: "zzMoveToFollowing" } do |s| s << "#{@i18n.where} " dlist.at(ns("./dt")).children.each { |n| parse(n, s) } s << " " end parse(dlist.at(ns("./dd/p")), out) end |
#implicit_reference(bib) ⇒ Object
16 17 18 19 20 |
# File 'lib/isodoc/iso/base_convert.rb', line 16 def implicit_reference(bib) return true if bib&.at(ns("./docidentifier"))&.text == "IEV" super end |
#indexsect(isoxml, out) ⇒ Object
181 182 183 184 185 |
# File 'lib/isodoc/iso/base_convert.rb', line 181 def indexsect(isoxml, out) isoxml.xpath(ns("//indexsect")).each do |i| clause_parse(i, out) end end |
#introduction(isoxml, out) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/isodoc/iso/sections.rb', line 38 def introduction(isoxml, out) f = isoxml.at(ns("//introduction")) || return title_attr = { class: "IntroTitle" } page_break(out) out.div **{ class: "Section3", id: f["id"] } do |div| clause_name(nil, f.at(ns("./title")), div, title_attr) f.elements.each do |e| parse(e, div) unless e.name == "title" end end end |
#middle(isoxml, out) ⇒ Object
147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/isodoc/iso/base_convert.rb', line 147 def middle(isoxml, out) middle_title(isoxml, out) middle_admonitions(isoxml, out) i = scope isoxml, out, 0 i = norm_ref isoxml, out, i # i = terms_defs isoxml, out, i # symbols_abbrevs isoxml, out, i clause_etc isoxml, out, i annex isoxml, out bibliography isoxml, out indexsect isoxml, out end |
#middle_title(_isoxml, out) ⇒ Object
4 5 6 7 |
# File 'lib/isodoc/iso/sections.rb', line 4 def middle_title(_isoxml, out) middle_title_main(out) middle_title_amd(out) end |
#middle_title_amd(out) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/isodoc/iso/sections.rb', line 22 def middle_title_amd(out) a = @meta.get[:doctitleamdlabel] and out.p(**{ class: "zzSTDTitle2" }) do |p| p << a a = @meta.get[:doctitleamd] and p << ": #{a}" end a = @meta.get[:doctitlecorrlabel] and out.p(**{ class: "zzSTDTitle2" }) do |p| p << a end end |
#middle_title_main(out) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/isodoc/iso/sections.rb', line 9 def middle_title_main(out) out.p(**{ class: "zzSTDTitle1" }) do |p| p << @meta.get[:doctitleintro] p << " — " if @meta.get[:doctitleintro] && @meta.get[:doctitlemain] p << @meta.get[:doctitlemain] p << " — " if @meta.get[:doctitlemain] && @meta.get[:doctitlepart] end a = @meta.get[:doctitlepart] and out.p(**{ class: "zzSTDTitle2" }) do |p| b = @meta.get[:doctitlepartlabel] and p << "#{b}: " p << "<br/><b>#{a}</b>" end end |
#node_begins_with_para(node) ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/isodoc/iso/base_convert.rb', line 56 def node_begins_with_para(node) node.elements.each do |e| next if e.name == "name" return true if e.name == "p" return false end false end |
#ol_attrs(node) ⇒ Object
187 188 189 |
# File 'lib/isodoc/iso/base_convert.rb', line 187 def ol_attrs(node) super.merge(start: node["start"]).compact end |
#table_th_center(docxml) ⇒ Object
82 83 84 85 86 87 |
# File 'lib/isodoc/iso/base_convert.rb', line 82 def table_th_center(docxml) docxml.xpath("//thead//th | //thead//td").each do |th| th["align"] = "center" th["valign"] = "middle" end end |