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_file_locations(options) ⇒ Object
- #default_fonts(options) ⇒ Object
- #eref_localities1(target, type, from, to, lang = "en") ⇒ Object
- #eref_localities1_zh(target, type, from, to) ⇒ Object
-
#error_parse(node, out) ⇒ Object
terms not defined in standoc.
- #foreword(isoxml, out) ⇒ 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
- #prefix_container(container, linkend, target) ⇒ Object
- #section_names1(clause, num, level) ⇒ Object
Constructor Details
#initialize(options) ⇒ WordConvert
Returns a new instance of WordConvert.
7 8 9 10 |
# File 'lib/isodoc/iso/word_convert.rb', line 7 def initialize() @libdir = File.dirname(__FILE__) super end |
Instance Method Details
#annex_names(clause, num) ⇒ Object
110 111 112 113 |
# File 'lib/isodoc/iso/word_convert.rb', line 110 def annex_names(clause, num) appendix_names(clause, num) super end |
#annex_names1(clause, num, level) ⇒ Object
133 134 135 136 137 138 |
# File 'lib/isodoc/iso/word_convert.rb', line 133 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
115 116 117 118 119 120 121 |
# File 'lib/isodoc/iso/word_convert.rb', line 115 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, "clause") @anchors[c["id"]][:level] = 2 @anchors[c["id"]][:container] = clause["id"] end end |
#colophon(body, docxml) ⇒ Object
55 56 57 58 59 |
# File 'lib/isodoc/iso/word_convert.rb', line 55 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_file_locations(options) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/isodoc/iso/word_convert.rb', line 20 def default_file_locations() { htmlstylesheet: [:alt] ? html_doc_path("style-human.scss") : html_doc_path("style-iso.scss"), htmlcoverpage: html_doc_path("html_iso_titlepage.html"), htmlintropage: html_doc_path("html_iso_intro.html"), scripts: html_doc_path("scripts.html"), wordstylesheet: html_doc_path("wordstyle.scss"), standardstylesheet: html_doc_path("isodoc.scss"), 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 |
#default_fonts(options) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/isodoc/iso/word_convert.rb', line 12 def default_fonts() { bodyfont: ([:script] == "Hans" ? '"SimSun",serif' : '"Cambria",serif'), headerfont: ([:script] == "Hans" ? '"SimHei",sans-serif' : '"Cambria",serif'), monospacefont: '"Courier New",monospace', } end |
#eref_localities1(target, type, from, to, lang = "en") ⇒ Object
151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/isodoc/iso/word_convert.rb', line 151 def eref_localities1(target, type, from, to, lang = "en") subsection = from&.text&.match(/\./) return l10n(eref_localities1_zh(target, type, from, to)) if lang == "zh" ret = type == "list" ? "" : "," loc = @locality[type] || type.sub(/^locality:/, "").capitalize ret += " #{loc}" unless subsection && type == "clause" || type == "list" || target.match(/^IEV$/) ret += " #{from.text}" if from ret += "–#{to.text}" if to ret += ")" if type == "list" l10n(ret) end |
#eref_localities1_zh(target, type, from, to) ⇒ Object
140 141 142 143 144 145 146 147 148 149 |
# File 'lib/isodoc/iso/word_convert.rb', line 140 def eref_localities1_zh(target, type, from, to) subsection = from&.text&.match(/\./) ret = type == "list" ? "" : "," ret += " 第#{from.text}" if from ret += "–#{to}" if to loc = (@locality[type] || type.sub(/^locality:/, "").capitalize ) ret += " #{loc}" unless subsection && type == "clause" || type == "list" || target.match(/^IEV$/) ret += ")" if type == "list" ret end |
#error_parse(node, out) ⇒ Object
terms not defined in standoc
102 103 104 105 106 107 108 |
# File 'lib/isodoc/iso/word_convert.rb', line 102 def error_parse(node, out) case node.name when "appendix" then clause_parse(node, out) else super end end |
#foreword(isoxml, out) ⇒ Object
79 80 81 82 83 84 85 86 |
# File 'lib/isodoc/iso/word_convert.rb', line 79 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 |
#implicit_reference(b) ⇒ Object
40 41 42 43 |
# File 'lib/isodoc/iso/word_convert.rb', line 40 def implicit_reference(b) isocode = b.at(ns("./docidentifier")).text isocode == "IEV" end |
#initial_anchor_names(d) ⇒ Object
88 89 90 91 |
# File 'lib/isodoc/iso/word_convert.rb', line 88 def initial_anchor_names(d) super introduction_names(d.at(ns("//introduction"))) end |
#introduction(isoxml, out) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/isodoc/iso/word_convert.rb', line 61 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
94 95 96 97 98 99 |
# File 'lib/isodoc/iso/word_convert.rb', line 94 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
45 46 47 48 49 50 51 52 53 |
# File 'lib/isodoc/iso/word_convert.rb', line 45 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
36 37 38 |
# File 'lib/isodoc/iso/word_convert.rb', line 36 def (lang, script, labels) @meta = Metadata.new(lang, script, labels) end |
#prefix_container(container, linkend, target) ⇒ Object
163 164 165 166 |
# File 'lib/isodoc/iso/word_convert.rb', line 163 def prefix_container(container, linkend, target) delim = get_anchors[target][:type] == "listitem" ? " " : ", " l10n(get_anchors[container][:xref] + delim + linkend) end |
#section_names1(clause, num, level) ⇒ Object
123 124 125 126 127 128 129 130 131 |
# File 'lib/isodoc/iso/word_convert.rb', line 123 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 |