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_para_delim(para) ⇒ Object
TODO: To Presentation XML.
- #admonition_p_parse(node, div) ⇒ Object
- #annex(node, out) ⇒ Object
- #clause_etc1(clause, out, num) ⇒ Object
- #cleanup(docxml) ⇒ Object
- #convert1(docxml, filename, dir) ⇒ Object
- #convert_i18n_init(docxml) ⇒ Object
- #example_p_class ⇒ Object
- #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
- #measurement_units(node, out) ⇒ Object
- #span_parse(node, out) ⇒ 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
71 72 73 74 75 |
# File 'lib/isodoc/iso/base_convert.rb', line 71 def admonition_class(node) if node["type"] == "editorial" then "zzHelp" else super end end |
#admonition_name_para_delim(para) ⇒ Object
TODO: To Presentation XML
82 83 84 |
# File 'lib/isodoc/iso/base_convert.rb', line 82 def admonition_name_para_delim(para) para << " " end |
#admonition_p_parse(node, div) ⇒ Object
77 78 79 |
# File 'lib/isodoc/iso/base_convert.rb', line 77 def admonition_p_parse(node, div) admonition_name_in_first_para(node, div) 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
102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/isodoc/iso/base_convert.rb', line 102 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("./fmt-title")), div, nil) clause.elements.each do |e| parse(e, div) unless %w{fmt-title fmt-source}.include? e.name end end end |
#cleanup(docxml) ⇒ Object
58 59 60 61 62 |
# File 'lib/isodoc/iso/base_convert.rb', line 58 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
166 167 168 169 |
# File 'lib/isodoc/iso/base_convert.rb', line 166 def convert_i18n_init(docxml) super update_i18n(docxml) end |
#example_p_class ⇒ Object
23 24 25 |
# File 'lib/isodoc/iso/base_convert.rb', line 23 def example_p_class nil end |
#example_p_parse(node, div) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/isodoc/iso/base_convert.rb', line 27 def example_p_parse(node, div) name = node.at(ns("./fmt-name")) para = node.at(ns("./p")) div.p **attr_code(class: example_p_class) do |p| name and p.span class: "example_label" do |s| name.children.each { |n| parse(n, s) } end insert_tab(p, 1) # TODO to Presentation XML children_parse(para, p) end para.xpath("./following-sibling::*").each { |n| parse(n, div) } end |
#example_parse(node, out) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/isodoc/iso/base_convert.rb', line 48 def example_parse(node, out) out.div id: node["id"], class: "example" do |div| if starts_with_para?(node) example_p_parse(node, div) else example_parse1(node, div) end end end |
#example_parse1(node, div) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/isodoc/iso/base_convert.rb', line 40 def example_parse1(node, div) div.p do |p| example_span_label(node, p, node.at(ns("./fmt-name"))) insert_tab(p, 1) end node.children.each { |n| parse(n, div) unless n.name == "fmt-name" } end |
#example_span_label(_node, div, name) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/isodoc/iso/base_convert.rb', line 16 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
86 87 88 89 90 91 |
# File 'lib/isodoc/iso/base_convert.rb', line 86 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
136 137 138 139 140 141 142 143 144 145 |
# File 'lib/isodoc/iso/base_convert.rb', line 136 def figure_parse1(node, out) measurement_units(node, out) out.div **figure_attrs(node) do |div| node.children.each do |n| n.name == "note" && n["type"] == "units" and next parse(n, div) unless n.name == "fmt-name" end figure_name_parse(node, div, node.at(ns("./fmt-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("./fmt-title")), s, { class: "ForewordTitle" }) clause.elements.each { |e| parse(e, s) unless e.name == "fmt-title" } end @foreword = false end |
#measurement_units(node, out) ⇒ Object
147 148 149 150 151 152 153 154 155 |
# File 'lib/isodoc/iso/base_convert.rb', line 147 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 |
#span_parse(node, out) ⇒ Object
171 172 173 174 175 |
# File 'lib/isodoc/iso/base_convert.rb', line 171 def span_parse(node, out) node["class"] == "fmt-obligation" and node["class"] = "obligation" super end |
#table_cleanup(docxml) ⇒ Object
157 158 159 160 161 162 163 164 |
# File 'lib/isodoc/iso/base_convert.rb', line 157 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
115 116 117 118 119 120 121 122 123 124 |
# File 'lib/isodoc/iso/base_convert.rb', line 115 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
126 127 128 129 130 131 132 133 134 |
# File 'lib/isodoc/iso/base_convert.rb', line 126 def table_parse_tail(node, out) (dl = node.at(ns("./dl"))) && parse(dl, out) node.xpath(ns("./fmt-source")).each { |n| parse(n, out) } node.xpath(ns("./note[not(@type = 'units')]")).each do |n| parse(n, out) end node.xpath(ns("./fmt-footnote-container/fmt-fn-body")) .each { |n| parse(n, out) } end |
#table_th_center(docxml) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/isodoc/iso/base_convert.rb', line 64 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
93 94 95 96 97 98 99 100 |
# File 'lib/isodoc/iso/base_convert.rb', line 93 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 |