Class: IsoDoc::Iso::WordConvert
- Inherits:
-
WordConvert
- Object
- WordConvert
- IsoDoc::Iso::WordConvert
- Defined in:
- lib/isodoc/iso/word_convert.rb
Instance Method Summary collapse
- #annex_names(clause, num) ⇒ Object
- #annex_names1(clause, num, level) ⇒ Object
- #appendix_names(clause, num) ⇒ Object
- #colophon(body, docxml) ⇒ Object
- #default_fonts(options) ⇒ Object
-
#error_parse(node, out) ⇒ Object
terms not defined in standoc.
- #foreword(isoxml, out) ⇒ Object
- #html_doc_path(file) ⇒ Object
- #implicit_reference(b) ⇒ Object
- #initial_anchor_names(d) ⇒ Object
-
#initialize(options) ⇒ WordConvert
constructor
A new instance of WordConvert.
- #introduction(isoxml, out) ⇒ Object
-
#introduction_names(clause) ⇒ Object
we can reference 0-number clauses in introduction.
- #make_body(xml, docxml) ⇒ Object
- #metadata_init(lang, script, labels) ⇒ Object
- #section_names1(clause, num, level) ⇒ Object
Constructor Details
#initialize(options) ⇒ WordConvert
Returns a new instance of WordConvert.
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/isodoc/iso/word_convert.rb', line 23 def initialize() super @wordstylesheet = generate_css(html_doc_path("wordstyle.scss"), false, default_fonts()) @standardstylesheet = generate_css(html_doc_path("isodoc.scss"), false, default_fonts()) @header = html_doc_path("header.html") @wordcoverpage = html_doc_path("word_iso_titlepage.html") @wordintropage = html_doc_path("word_iso_intro.html") @ulstyle = "l3" @olstyle = "l2" end |
Instance Method Details
#annex_names(clause, num) ⇒ Object
108 109 110 111 |
# File 'lib/isodoc/iso/word_convert.rb', line 108 def annex_names(clause, num) appendix_names(clause, num) super end |
#annex_names1(clause, num, level) ⇒ Object
131 132 133 134 135 136 |
# File 'lib/isodoc/iso/word_convert.rb', line 131 def annex_names1(clause, num, level) @anchors[clause["id"]] = { label: num, xref: num, level: level } clause.xpath(ns(".//clause")).each_with_index do |c, i| annex_names1(c, "#{num}.#{i + 1}", level + 1) end end |
#appendix_names(clause, num) ⇒ Object
113 114 115 116 117 118 119 |
# File 'lib/isodoc/iso/word_convert.rb', line 113 def appendix_names(clause, num) clause.xpath(ns("./appendix")).each_with_index do |c, i| @anchors[c["id"]] = anchor_struct(i + 1, nil, @appendix_lbl) @anchors[c["id"]][:level] = 2 @anchors[c["id"]][:container] = clause["id"] end end |
#colophon(body, docxml) ⇒ Object
53 54 55 56 57 |
# File 'lib/isodoc/iso/word_convert.rb', line 53 def colophon(body, docxml) body.br **{ clear: "all", style: "page-break-before:left;mso-break-type:section-break" } body.div **{ class: "colophon" } do |div| end end |
#default_fonts(options) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/isodoc/iso/word_convert.rb', line 8 def default_fonts() b = [:bodyfont] || ([:script] == "Hans" ? '"SimSun",serif' : '"Cambria",serif') h = [:headerfont] || ([:script] == "Hans" ? '"SimHei",sans-serif' : '"Cambria",serif') m = [:monospacefont] || '"Courier New",monospace' "$bodyfont: #{b};\n$headerfont: #{h};\n$monospacefont: #{m};\n" end |
#error_parse(node, out) ⇒ Object
terms not defined in standoc
100 101 102 103 104 105 106 |
# File 'lib/isodoc/iso/word_convert.rb', line 100 def error_parse(node, out) case node.name when "appendix" then clause_parse(node, out) else super end end |
#foreword(isoxml, out) ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/isodoc/iso/word_convert.rb', line 77 def foreword(isoxml, out) f = isoxml.at(ns("//foreword")) || return page_break(out) out.div **attr_code(id: f["id"]) do |s| s.h1(**{ class: "ForewordTitle" }) { |h1| h1 << @foreword_lbl } f.elements.each { |e| parse(e, s) unless e.name == "title" } end end |
#html_doc_path(file) ⇒ Object
19 20 21 |
# File 'lib/isodoc/iso/word_convert.rb', line 19 def html_doc_path(file) File.join(File.dirname(__FILE__), File.join("html", file)) end |
#implicit_reference(b) ⇒ Object
38 39 40 41 |
# File 'lib/isodoc/iso/word_convert.rb', line 38 def implicit_reference(b) isocode = b.at(ns("./docidentifier")).text isocode == "IEV" end |
#initial_anchor_names(d) ⇒ Object
86 87 88 89 |
# File 'lib/isodoc/iso/word_convert.rb', line 86 def initial_anchor_names(d) super introduction_names(d.at(ns("//introduction"))) end |
#introduction(isoxml, out) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/isodoc/iso/word_convert.rb', line 59 def introduction(isoxml, out) f = isoxml.at(ns("//introduction")) || return num = f.at(ns(".//clause")) ? "0" : nil title_attr = { class: "IntroTitle" } page_break(out) out.div **{ class: "Section3", id: f["id"] } do |div| # div.h1 "Introduction", **attr_code(title_attr) clause_name(num, @introduction_lbl, div, title_attr) f.elements.each do |e| if e.name == "patent-notice" e.elements.each { |e1| parse(e1, div) } else parse(e, div) unless e.name == "title" end end end end |
#introduction_names(clause) ⇒ Object
we can reference 0-number clauses in introduction
92 93 94 95 96 97 |
# File 'lib/isodoc/iso/word_convert.rb', line 92 def introduction_names(clause) return if clause.nil? clause.xpath(ns("./clause")).each_with_index do |c, i| section_names1(c, "0.#{i + 1}", 2) end end |
#make_body(xml, docxml) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/isodoc/iso/word_convert.rb', line 43 def make_body(xml, docxml) body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72" } xml.body **body_attr do |body| make_body1(body, docxml) make_body2(body, docxml) make_body3(body, docxml) colophon(body, docxml) end end |
#metadata_init(lang, script, labels) ⇒ Object
34 35 36 |
# File 'lib/isodoc/iso/word_convert.rb', line 34 def (lang, script, labels) @meta = Metadata.new(lang, script, labels) end |
#section_names1(clause, num, level) ⇒ Object
121 122 123 124 125 126 127 128 129 |
# File 'lib/isodoc/iso/word_convert.rb', line 121 def section_names1(clause, num, level) @anchors[clause["id"]] = { label: num, level: level, xref: num } # subclauses are not prefixed with "Clause" clause.xpath(ns("./clause | ./terms | ./term | ./definitions")). each_with_index do |c, i| section_names1(c, "#{num}.#{i + 1}", level + 1) end end |