Module: IsoDoc::Ogc::BaseConvert
- Included in:
- HtmlConvert, WordConvert
- Defined in:
- lib/isodoc/ogc/sections.rb,
lib/isodoc/ogc/base_convert.rb
Instance Method Summary collapse
- #abstract(clause, out) ⇒ Object
- #acknowledgements(clause, out) ⇒ Object
- #cleanup(docxml) ⇒ Object
- #error_parse(node, out) ⇒ Object
- #example_label(node, div, name) ⇒ Object
- #example_name_parse(_node, div, name) ⇒ Object
- #example_parse(node, out) ⇒ Object
- #foreword(clause, out) ⇒ Object
- #hi_parse(node, out) ⇒ Object
- #intro_clause(elem, out) ⇒ Object
- #is_clause?(name) ⇒ Boolean
- #make_tr_attr(cell, row, totalrows, header, bordered) ⇒ Object
- #middle_clause(_docxml) ⇒ Object
- #ol_depth(node) ⇒ Object
- #para_class(node) ⇒ Object
- #preface(clause, out) ⇒ Object
- #table_attrs(node) ⇒ Object
- #term_cleanup(docxml) ⇒ Object
- #term_cleanup_merge_admitted(term) ⇒ Object
- #term_cleanup_merge_termnum(term) ⇒ Object
- #top_element_render(node, out) ⇒ Object
Instance Method Details
#abstract(clause, out) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/isodoc/ogc/sections.rb', line 30 def abstract(clause, out) page_break(out) out.div **attr_code(id: clause["id"]) do |s| clause_name(clause, clause.at(ns("./title")), s, class: "AbstractTitle") clause.elements.each do |e| parse(e, s) unless e.name == "title" end end end |
#acknowledgements(clause, out) ⇒ Object
52 53 54 |
# File 'lib/isodoc/ogc/sections.rb', line 52 def acknowledgements(clause, out) intro_clause(clause, out) end |
#cleanup(docxml) ⇒ Object
22 23 24 25 |
# File 'lib/isodoc/ogc/base_convert.rb', line 22 def cleanup(docxml) super term_cleanup(docxml) end |
#error_parse(node, out) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/isodoc/ogc/base_convert.rb', line 8 def error_parse(node, out) case node.name when "hi" then hi_parse(node, out) else super end end |
#example_label(node, div, name) ⇒ Object
58 |
# File 'lib/isodoc/ogc/base_convert.rb', line 58 def example_label(node, div, name); end |
#example_name_parse(_node, div, name) ⇒ Object
60 61 62 63 64 |
# File 'lib/isodoc/ogc/base_convert.rb', line 60 def example_name_parse(_node, div, name) div.p class: "SourceTitle", style: "text-align:center;" do |p| name&.children&.each { |n| parse(n, p) } end end |
#example_parse(node, out) ⇒ Object
52 53 54 55 56 |
# File 'lib/isodoc/ogc/base_convert.rb', line 52 def example_parse(node, out) name = node.at(ns("./name")) example_name_parse(node, out, name) # if name super end |
#foreword(clause, out) ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/isodoc/ogc/sections.rb', line 41 def foreword(clause, out) page_break(out) out.div **attr_code(id: clause["id"]) do |s| clause_name(clause, clause&.at(ns("./title")), s, class: "ForewordTitle") clause.elements.each do |e| parse(e, s) unless e.name == "title" end end end |
#hi_parse(node, out) ⇒ Object
16 17 18 19 20 |
# File 'lib/isodoc/ogc/base_convert.rb', line 16 def hi_parse(node, out) out.span class: "hi" do |e| node.children.each { |n| parse(n, e) } end end |
#intro_clause(elem, out) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/isodoc/ogc/sections.rb', line 20 def intro_clause(elem, out) out.div class: "Section3", id: elem["id"] do |div| clause_name(elem, elem&.at(ns("./title")), div, class: "IntroTitle") elem.elements.each do |e| parse(e, div) unless e.name == "title" end end end |
#is_clause?(name) ⇒ Boolean
72 73 74 75 76 |
# File 'lib/isodoc/ogc/base_convert.rb', line 72 def is_clause?(name) return true if name == "submitters" super end |
#make_tr_attr(cell, row, totalrows, header, bordered) ⇒ Object
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/isodoc/ogc/base_convert.rb', line 87 def make_tr_attr(cell, row, totalrows, header, bordered) ret = super if cell.at("./ancestor::xmlns:table[@class = 'recommendation'] | " \ "./ancestor::xmlns:table[@class = 'requirement'] | " \ "./ancestor::xmlns:table[@class = 'permission']") ret[:style] = "vertical-align:top;" ret[:class] = "recommend" end ret end |
#middle_clause(_docxml) ⇒ Object
66 67 68 69 70 |
# File 'lib/isodoc/ogc/base_convert.rb', line 66 def middle_clause(_docxml) "//clause[parent::sections][not(@type = 'scope' or " \ "@type = 'conformance')][not(descendant::terms)]" \ "[not(descendant::references)]" end |
#ol_depth(node) ⇒ Object
108 109 110 111 112 113 114 115 |
# File 'lib/isodoc/ogc/base_convert.rb', line 108 def ol_depth(node) return super unless (node["class"] == "steps") || node.at(".//ancestor::xmlns:ol[@class = 'steps']") idx = node.xpath("./ancestor-or-self::xmlns:ol[@class = 'steps']").size styles = %i(arabic alphabet roman alphabet_upper roman_upper) ol_style(styles[(idx - 1) % 5]) end |
#para_class(node) ⇒ Object
98 99 100 101 102 103 104 105 106 |
# File 'lib/isodoc/ogc/base_convert.rb', line 98 def para_class(node) if node["class"] == "RecommendationLabel" node["class"] = nil ret = super node["class"] = "RecommendationLabel" ret else super end end |
#preface(clause, out) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/isodoc/ogc/sections.rb', line 11 def preface(clause, out) case clause["type"] when "toc" table_of_contents(clause, out) else intro_clause(clause, out) end end |
#table_attrs(node) ⇒ Object
78 79 80 81 82 83 84 85 |
# File 'lib/isodoc/ogc/base_convert.rb', line 78 def table_attrs(node) ret = super %w(recommendation requirement permission).include?(node["class"]) and ret = ret.merge(class: node["type"], style: "border-collapse:collapse;border-spacing:0;" \ "#{keep_style(node)}") ret end |
#term_cleanup(docxml) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/isodoc/ogc/base_convert.rb', line 27 def term_cleanup(docxml) docxml.xpath("//p[@class = 'Terms']").each do |d| term_cleanup_merge_termnum(d) # term_cleanup_merge_admitted(d) end docxml end |
#term_cleanup_merge_admitted(term) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/isodoc/ogc/base_convert.rb', line 43 def term_cleanup_merge_admitted(term) term.xpath("./following-sibling::p[@class = 'AltTerms' or " \ "@class = 'DeprecatedTerms']").each do |a| term << " " term << a.children a.remove end end |
#term_cleanup_merge_termnum(term) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/isodoc/ogc/base_convert.rb', line 35 def term_cleanup_merge_termnum(term) h2 = term.at("./preceding-sibling::*[@class = 'TermNum'][1]") term["class"] = h2["class"] term["id"] = h2["id"] term.add_first_child " " term.add_first_child h2.remove.children end |
#top_element_render(node, out) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/isodoc/ogc/sections.rb', line 4 def top_element_render(node, out) case node.name when "submitters" then intro_clause node, out else super end end |