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
- #example_label(node, div, name) ⇒ Object
- #example_name_parse(_node, div, name) ⇒ Object
- #example_parse(node, out) ⇒ Object
- #foreword(clause, out) ⇒ Object
- #intro_clause(elem, out) ⇒ Object
- #make_tr_attr(cell, row, totalrows, header, bordered) ⇒ Object
- #middle_clause(_docxml) ⇒ 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
Instance Method Details
#abstract(clause, out) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/isodoc/ogc/sections.rb', line 23 def abstract(clause, out) page_break(out) out.div **attr_code(id: clause["id"]) do |s| clause_name(clause, clause.at(ns("./fmt-title")), s, class: "AbstractTitle") clause.elements.each do |e| parse(e, s) unless e.name == "fmt-title" end end end |
#acknowledgements(clause, out) ⇒ Object
45 46 47 |
# File 'lib/isodoc/ogc/sections.rb', line 45 def acknowledgements(clause, out) intro_clause(clause, out) end |
#cleanup(docxml) ⇒ Object
8 9 10 11 |
# File 'lib/isodoc/ogc/base_convert.rb', line 8 def cleanup(docxml) super term_cleanup(docxml) end |
#example_label(node, div, name) ⇒ Object
45 |
# File 'lib/isodoc/ogc/base_convert.rb', line 45 def example_label(node, div, name); end |
#example_name_parse(_node, div, name) ⇒ Object
47 48 49 50 51 |
# File 'lib/isodoc/ogc/base_convert.rb', line 47 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
39 40 41 42 43 |
# File 'lib/isodoc/ogc/base_convert.rb', line 39 def example_parse(node, out) name = node.at(ns("./fmt-name")) example_name_parse(node, out, name) # if name super end |
#foreword(clause, out) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/isodoc/ogc/sections.rb', line 34 def foreword(clause, out) page_break(out) out.div **attr_code(id: clause["id"]) do |s| clause_name(clause, clause&.at(ns("./fmt-title")), s, class: "ForewordTitle") clause.elements.each do |e| parse(e, s) unless e.name == "fmt-title" end end end |
#intro_clause(elem, out) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/isodoc/ogc/sections.rb', line 13 def intro_clause(elem, out) out.div class: "Section3", id: elem["id"] do |div| clause_name(elem, elem&.at(ns("./fmt-title")), div, class: "IntroTitle") elem.elements.each do |e| parse(e, div) unless e.name == "fmt-title" end end end |
#make_tr_attr(cell, row, totalrows, header, bordered) ⇒ Object
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/isodoc/ogc/base_convert.rb', line 67 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['style']}" ret[:class] = "recommend" end ret end |
#middle_clause(_docxml) ⇒ Object
53 54 55 56 57 |
# File 'lib/isodoc/ogc/base_convert.rb', line 53 def middle_clause(_docxml) "//clause[parent::sections][not(@type = 'scope' or " \ "@type = 'conformance')][not(descendant::terms)]" \ "[not(descendant::references)]" end |
#para_class(node) ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'lib/isodoc/ogc/base_convert.rb', line 78 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
4 5 6 7 8 9 10 11 |
# File 'lib/isodoc/ogc/sections.rb', line 4 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
59 60 61 62 63 64 65 |
# File 'lib/isodoc/ogc/base_convert.rb', line 59 def table_attrs(node) ret = super style = node["style"] || "border-collapse:collapse;border-spacing:0;" %w(recommendation requirement permission).include?(node["class"]) and ret = ret.merge(class: node["type"], style: style) ret end |
#term_cleanup(docxml) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/isodoc/ogc/base_convert.rb', line 13 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
30 31 32 33 34 35 36 37 |
# File 'lib/isodoc/ogc/base_convert.rb', line 30 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
21 22 23 24 25 26 27 28 |
# File 'lib/isodoc/ogc/base_convert.rb', line 21 def term_cleanup_merge_termnum(term) h2 = term.at("./preceding-sibling::*[@class = 'TermNum'][1]") term["class"] = h2["class"] term["id"] = h2["id"] # TODO to PresentationXML term.add_first_child " " term.add_first_child h2.remove.children end |