Module: IsoDoc::MPFA::BaseConvert
- Included in:
- HtmlConvert, WordConvert
- Defined in:
- lib/isodoc/mpfa/base_convert.rb
Constant Summary collapse
- TERM_CLAUSE =
"//preface/terms | "\ "//preface/clause[descendant::terms]".freeze
- SECTIONS_XPATH =
"//foreword | //introduction | //preface/terms | //preface/clause | //annex | "\ "//sections/clause | //bibliography/references | //acknowledgements | "\ "//bibliography/clause".freeze
- FRONT_CLAUSE =
"//*[parent::preface]".freeze
Instance Method Summary collapse
- #clause(isoxml, out) ⇒ Object
- #clause_parse_title(node, div, c1, out, header_class = {}) ⇒ Object
- #middle(isoxml, out) ⇒ Object
- #middle_clause(_docxml) ⇒ Object
- #ol_depth(node) ⇒ Object
- #preface(isoxml, out) ⇒ Object
- #termdef_parse(node, out) ⇒ Object
- #terms_defs(isoxml, out, num) ⇒ Object
Instance Method Details
#clause(isoxml, out) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/isodoc/mpfa/base_convert.rb', line 61 def clause(isoxml, out) isoxml.xpath(ns(middle_clause(isoxml))).each do |c| out.div **attr_code(id: c["id"]) do |s| clause_name(nil, c&.at(ns("./title")), s, class: c["container"] ? "containerhdr" : nil ) c.elements.reject { |c1| c1.name == "title" }.each do |c1| parse(c1, s) end end end end |
#clause_parse_title(node, div, c1, out, header_class = {}) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/isodoc/mpfa/base_convert.rb', line 73 def clause_parse_title(node, div, c1, out, header_class = {}) attrs = {} attrs = { class: "containerhdr" } if node["container"] header_class = header_class.merge(attrs) super end |
#middle(isoxml, out) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/isodoc/mpfa/base_convert.rb', line 47 def middle(isoxml, out) middle_title(isoxml, out) middle_admonitions(isoxml, out) clause isoxml, out annex isoxml, out bibliography isoxml, out end |
#middle_clause(_docxml) ⇒ Object
43 44 45 |
# File 'lib/isodoc/mpfa/base_convert.rb', line 43 def middle_clause(_docxml) "//clause[parent::sections][not(descendant::terms)]" end |
#ol_depth(node) ⇒ Object
80 81 82 |
# File 'lib/isodoc/mpfa/base_convert.rb', line 80 def ol_depth(node) ol_style(node["type"]) end |
#preface(isoxml, out) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/isodoc/mpfa/base_convert.rb', line 28 def preface(isoxml, out) isoxml.xpath(ns(self.class::FRONT_CLAUSE)).each do |c| if c.name == "terms" || c.at(ns(".//terms")) then terms_defs isoxml, out, 0 elsif !is_clause?(c.name) then parse(c, out) else out.div **attr_code(id: c["id"]) do |s| clause_name(nil, c&.at(ns("./title")), s, nil) c.elements.reject { |c1| c1.name == "title" }.each do |c1| parse(c1, s) end end end end end |
#termdef_parse(node, out) ⇒ Object
55 56 57 58 59 |
# File 'lib/isodoc/mpfa/base_convert.rb', line 55 def termdef_parse(node, out) name = node&.at(ns("./name"))&.remove set_termdomain("") node.children.each { |n| parse(n, out) } end |
#terms_defs(isoxml, out, num) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/isodoc/mpfa/base_convert.rb', line 15 def terms_defs(isoxml, out, num) f = isoxml.at(ns(self.class::TERM_CLAUSE)) or return num out.div **attr_code(id: f["id"]) do |div| clause_name(nil, f&.at(ns("./title")), div, nil) f.elements.each do |e| parse(e, div) unless %w{title source}.include? e.name end end num end |