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(node, out) ⇒ Object
- #clause_etc1(clause, out, num) ⇒ Object
- #cleanup(docxml) ⇒ Object
- #convert1(docxml, filename, dir) ⇒ Object
- #convert_i18n_init(docxml) ⇒ 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
- #figure_parse1(node, out) ⇒ Object
- #foreword(clause, out) ⇒ Object
- #implicit_reference(bib) ⇒ Object
- #measurement_units(node, out) ⇒ Object
- #node_begins_with_para(node) ⇒ Object
- #ol_attrs(node) ⇒ Object
- #render_identifier(ident) ⇒ Object
- #table_cleanup(docxml) ⇒ Object
- #table_parse(node, out) ⇒ Object
- #table_parse_tail(node, out) ⇒ Object
- #table_th_center(docxml) ⇒ Object
- #top_element_render(elem, out) ⇒ Object
Instance Method Details
#admonition_class(node) ⇒ Object
98 99 100 101 102 |
# File 'lib/isodoc/iso/base_convert.rb', line 98 def admonition_class(node) if node["type"] == "editorial" then "zzHelp" else super end end |
#admonition_name_parse(_node, div, name) ⇒ Object
119 120 121 122 |
# File 'lib/isodoc/iso/base_convert.rb', line 119 def admonition_name_parse(_node, div, name) name.children.each { |n| parse(n, div) } div << " — " end |
#admonition_p_parse(node, div, name) ⇒ Object
111 112 113 114 115 116 117 |
# File 'lib/isodoc/iso/base_convert.rb', line 111 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
86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/isodoc/iso/base_convert.rb', line 86 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
104 105 106 107 108 109 |
# File 'lib/isodoc/iso/base_convert.rb', line 104 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(node, out) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/isodoc/iso/sections.rb', line 4 def annex(node, out) amd?(node.document) and @suppressheadingnumbers = @oldsuppressheadingnumbers super amd?(node.document) and @suppressheadingnumbers = true end |
#clause_etc1(clause, out, num) ⇒ Object
140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/isodoc/iso/base_convert.rb', line 140 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(clause, 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
73 74 75 76 77 |
# File 'lib/isodoc/iso/base_convert.rb', line 73 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 |
#convert_i18n_init(docxml) ⇒ Object
213 214 215 216 |
# File 'lib/isodoc/iso/base_convert.rb', line 213 def convert_i18n_init(docxml) super update_i18n(docxml) end |
#error_parse(node, out) ⇒ Object
terms not defined in standoc
22 23 24 25 26 27 28 |
# File 'lib/isodoc/iso/base_convert.rb', line 22 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
37 38 39 40 41 42 43 44 |
# File 'lib/isodoc/iso/base_convert.rb', line 37 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
63 64 65 66 67 68 69 70 71 |
# File 'lib/isodoc/iso/base_convert.rb', line 63 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
46 47 48 49 50 51 52 |
# File 'lib/isodoc/iso/base_convert.rb', line 46 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
30 31 32 33 34 35 |
# File 'lib/isodoc/iso/base_convert.rb', line 30 def example_span_label(_node, div, name) name.nil? and return div.span class: "example_label" do |p| name.children.each { |n| parse(n, p) } end end |
#figure_name_parse(_node, div, name) ⇒ Object
124 125 126 127 128 129 |
# File 'lib/isodoc/iso/base_convert.rb', line 124 def figure_name_parse(_node, div, name) name.nil? and return div.p class: "FigureTitle", style: "text-align:center;" do |p| name.children.each { |n| parse(n, p) } end end |
#figure_parse1(node, out) ⇒ Object
182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/isodoc/iso/base_convert.rb', line 182 def figure_parse1(node, out) measurement_units(node, out) out.div **figure_attrs(node) do |div| node.children.each do |n| figure_key(out) if n.name == "dl" n.name == "note" && n["type"] == "units" and next parse(n, div) unless n.name == "name" end figure_name_parse(node, div, node.at(ns("./name"))) end end |
#foreword(clause, out) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/isodoc/iso/sections.rb', line 11 def foreword(clause, out) @foreword = true page_break(out) out.div **attr_code(id: clause["id"]) do |s| clause_name(nil, clause.at(ns("./title")) || @i18n.foreword, s, { class: "ForewordTitle" }) clause.elements.each { |e| parse(e, s) unless e.name == "title" } end @foreword = false end |
#implicit_reference(bib) ⇒ Object
16 17 18 19 |
# File 'lib/isodoc/iso/base_convert.rb', line 16 def implicit_reference(bib) bib.at(ns("./docidentifier"))&.text == "IEV" and return true super end |
#measurement_units(node, out) ⇒ Object
194 195 196 197 198 199 200 201 202 |
# File 'lib/isodoc/iso/base_convert.rb', line 194 def measurement_units(node, out) node.xpath(ns("./note[@type = 'units']")).each do |n| out.div align: "right" do |p| p.b do |b| n.children.each { |e| parse(e, b) } end end end end |
#node_begins_with_para(node) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/isodoc/iso/base_convert.rb', line 54 def node_begins_with_para(node) node.elements.each do |e| e.name == "name" and next e.name == "p" and return true return false end false end |
#ol_attrs(node) ⇒ Object
153 154 155 |
# File 'lib/isodoc/iso/base_convert.rb', line 153 def ol_attrs(node) super.merge(start: node["start"]).compact end |
#render_identifier(ident) ⇒ Object
157 158 159 160 161 |
# File 'lib/isodoc/iso/base_convert.rb', line 157 def render_identifier(ident) ret = super ret[:sdo] = std_docid_semantic(ret[:sdo]) ret end |
#table_cleanup(docxml) ⇒ Object
204 205 206 207 208 209 210 211 |
# File 'lib/isodoc/iso/base_convert.rb', line 204 def table_cleanup(docxml) super docxml.xpath("//tfoot/div[@class = 'figdl']/p[@class = 'ListTitle']") .each do |p| p["align"] = "left" end docxml end |
#table_parse(node, out) ⇒ Object
163 164 165 166 167 168 169 170 171 172 |
# File 'lib/isodoc/iso/base_convert.rb', line 163 def table_parse(node, out) @in_table = true table_title_parse(node, out) measurement_units(node, out) out.table **table_attrs(node) do |t| table_parse_core(node, t) table_parse_tail(node, t) end @in_table = false end |
#table_parse_tail(node, out) ⇒ Object
174 175 176 177 178 179 180 |
# File 'lib/isodoc/iso/base_convert.rb', line 174 def table_parse_tail(node, out) (dl = node.at(ns("./dl"))) && parse(dl, out) node.xpath(ns("./source")).each { |n| parse(n, out) } node.xpath(ns("./note[not(@type = 'units')]")).each do |n| parse(n, out) end end |
#table_th_center(docxml) ⇒ Object
79 80 81 82 83 84 |
# File 'lib/isodoc/iso/base_convert.rb', line 79 def table_th_center(docxml) docxml.xpath("//thead//th | //thead//td").each do |th| th["align"] = "center" th["valign"] = "middle" end end |
#top_element_render(elem, out) ⇒ Object
131 132 133 134 135 136 137 138 |
# File 'lib/isodoc/iso/base_convert.rb', line 131 def top_element_render(elem, out) if %w(clause terms definitions).include?(elem.name) && elem.parent.name == "sections" && elem["type"] != "scope" clause_etc1(elem, out, 0) else super end end |