Class: IsoDoc::Iso::HtmlConvert
- Inherits:
-
HtmlConvert
- Object
- HtmlConvert
- IsoDoc::Iso::HtmlConvert
- Defined in:
- lib/isodoc/iso/html_convert.rb
Instance Method Summary collapse
- #annex_names(clause, num) ⇒ Object
- #annex_names1(clause, num, level) ⇒ Object
- #appendix_names(clause, num) ⇒ Object
- #default_file_locations(options) ⇒ Object
- #default_fonts(options) ⇒ 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) ⇒ 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.
11 12 13 14 |
# File 'lib/isodoc/iso/html_convert.rb', line 11 def initialize() @libdir = File.dirname(__FILE__) super end |
Instance Method Details
#annex_names(clause, num) ⇒ Object
87 88 89 90 |
# File 'lib/isodoc/iso/html_convert.rb', line 87 def annex_names(clause, num) appendix_names(clause, num) super end |
#annex_names1(clause, num, level) ⇒ Object
110 111 112 113 114 115 |
# File 'lib/isodoc/iso/html_convert.rb', line 110 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
92 93 94 95 96 97 98 |
# File 'lib/isodoc/iso/html_convert.rb', line 92 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_file_locations(options) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/isodoc/iso/html_convert.rb', line 24 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"), } end |
#default_fonts(options) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/isodoc/iso/html_convert.rb', line 16 def default_fonts() { bodyfont: ([:script] == "Hans" ? '"SimSun",serif' : [:alt] ? '"Lato",sans-serif' : '"Cambria",serif'), headerfont: ([:script] == "Hans" ? '"SimHei",sans-serif' : [:alt] ? '"Lato",sans-serif' : '"Cambria",serif'), monospacefont: ([:alt] ? '"Space Mono",monospace' : '"Courier New",monospace'), } end |
#error_parse(node, out) ⇒ Object
terms not defined in standoc
79 80 81 82 83 84 85 |
# File 'lib/isodoc/iso/html_convert.rb', line 79 def error_parse(node, out) case node.name when "appendix" then clause_parse(node, out) else super end end |
#foreword(isoxml, out) ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/isodoc/iso/html_convert.rb', line 56 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
33 34 35 36 |
# File 'lib/isodoc/iso/html_convert.rb', line 33 def implicit_reference(b) isocode = b.at(ns("./docidentifier")).text isocode == "IEV" end |
#initial_anchor_names(d) ⇒ Object
65 66 67 68 |
# File 'lib/isodoc/iso/html_convert.rb', line 65 def initial_anchor_names(d) super introduction_names(d.at(ns("//introduction"))) end |
#introduction(isoxml, out) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/isodoc/iso/html_convert.rb', line 38 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
71 72 73 74 75 76 |
# File 'lib/isodoc/iso/html_convert.rb', line 71 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
7 8 9 |
# File 'lib/isodoc/iso/html_convert.rb', line 7 def (lang, script, labels) @meta = Metadata.new(lang, script, labels) end |
#section_names1(clause, num, level) ⇒ Object
100 101 102 103 104 105 106 107 108 |
# File 'lib/isodoc/iso/html_convert.rb', line 100 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 |