Class: IsoDoc::Iso::HtmlConvert
- Inherits:
-
HtmlConvert
- Object
- HtmlConvert
- IsoDoc::Iso::HtmlConvert
- Defined in:
- lib/isodoc/iso/html_convert.rb
Instance Method Summary collapse
- #alt_fonts(options) ⇒ Object
- #annex_names(clause, num) ⇒ Object
- #annex_names1(clause, num, level) ⇒ Object
- #appendix_names(clause, num) ⇒ 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) ⇒ HtmlConvert
constructor
A new instance of HtmlConvert.
- #introduction(isoxml, out) ⇒ Object
-
#introduction_names(clause) ⇒ Object
we can reference 0-number clauses in introduction.
- #metadata_init(lang, script, labels) ⇒ Object
- #section_names1(clause, num, level) ⇒ Object
Constructor Details
#initialize(options) ⇒ HtmlConvert
Returns a new instance of HtmlConvert.
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/isodoc/iso/html_convert.rb', line 38 def initialize() super if [:alt] css = generate_css(html_doc_path("style-human.scss"), true, alt_fonts()) else css = generate_css(html_doc_path("style-iso.scss"), true, default_fonts()) end @htmlstylesheet = css @htmlcoverpage = html_doc_path("html_iso_titlepage.html") @htmlintropage = html_doc_path("html_iso_intro.html") @scripts = html_doc_path("scripts.html") end |
Instance Method Details
#alt_fonts(options) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/isodoc/iso/html_convert.rb', line 19 def alt_fonts() b = [:bodyfont] || ([:script] == "Hans" ? '"SimSun",serif' : '"Lato",sans-serif') h = [:headerfont] || ([:script] == "Hans" ? '"SimHei",sans-serif' : '"Lato",sans-serif') m = [:monospacefont] || '"Space Mono",monospace' "$bodyfont: #{b};\n$headerfont: #{h};\n$monospacefont: #{m};\n" end |
#annex_names(clause, num) ⇒ Object
105 106 107 108 |
# File 'lib/isodoc/iso/html_convert.rb', line 105 def annex_names(clause, num) appendix_names(clause, num) super end |
#annex_names1(clause, num, level) ⇒ Object
128 129 130 131 132 133 |
# File 'lib/isodoc/iso/html_convert.rb', line 128 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
110 111 112 113 114 115 116 |
# File 'lib/isodoc/iso/html_convert.rb', line 110 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 |
#default_fonts(options) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/isodoc/iso/html_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
97 98 99 100 101 102 103 |
# File 'lib/isodoc/iso/html_convert.rb', line 97 def error_parse(node, out) case node.name when "appendix" then clause_parse(node, out) else super end end |
#foreword(isoxml, out) ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/isodoc/iso/html_convert.rb', line 74 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
30 31 32 |
# File 'lib/isodoc/iso/html_convert.rb', line 30 def html_doc_path(file) File.join(File.dirname(__FILE__), File.join("html", file)) end |
#implicit_reference(b) ⇒ Object
51 52 53 54 |
# File 'lib/isodoc/iso/html_convert.rb', line 51 def implicit_reference(b) isocode = b.at(ns("./docidentifier")).text isocode == "IEV" end |
#initial_anchor_names(d) ⇒ Object
83 84 85 86 |
# File 'lib/isodoc/iso/html_convert.rb', line 83 def initial_anchor_names(d) super introduction_names(d.at(ns("//introduction"))) end |
#introduction(isoxml, out) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/isodoc/iso/html_convert.rb', line 56 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
89 90 91 92 93 94 |
# File 'lib/isodoc/iso/html_convert.rb', line 89 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 |
#metadata_init(lang, script, labels) ⇒ Object
34 35 36 |
# File 'lib/isodoc/iso/html_convert.rb', line 34 def (lang, script, labels) = Metadata.new(lang, script, labels) end |
#section_names1(clause, num, level) ⇒ Object
118 119 120 121 122 123 124 125 126 |
# File 'lib/isodoc/iso/html_convert.rb', line 118 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 |