class IsoDoc::NIST::HtmlConvert
A {Converter} implementation that generates HTML output, and a document schema encapsulation of the document for validation
Public Class Methods
new(options)
click to toggle source
Calls superclass method
# File lib/isodoc/nist/html_convert.rb, line 12 def initialize(options) @libdir = File.dirname(__FILE__) super end
Public Instance Methods
cleanup(docxml)
click to toggle source
Calls superclass method
# File lib/isodoc/nist/html_convert.rb, line 110 def cleanup(docxml) super term_cleanup(docxml) requirement_cleanup(docxml) docxml end
convert1(docxml, filename, dir)
click to toggle source
Calls superclass method
# File lib/isodoc/nist/html_convert.rb, line 17 def convert1(docxml, filename, dir) @bibliographycount = docxml.xpath(ns("//references")).size super end
default_file_locations(_options)
click to toggle source
# File lib/isodoc/nist/html_convert.rb, line 33 def default_file_locations(_options) { htmlstylesheet: html_doc_path("htmlstyle.scss"), htmlcoverpage: html_doc_path("html_nist_titlepage.html"), htmlintropage: html_doc_path("html_nist_intro.html"), } end
default_fonts(options)
click to toggle source
# File lib/isodoc/nist/html_convert.rb, line 22 def default_fonts(options) { bodyfont: '"Libre Baskerville",serif', headerfont: '"Libre Baskerville",serif', monospacefont: '"Space Mono",monospace', normalfontsize: "14px", footnotefontsize: "0.9em", monospacefontsize: "0.8em", } end
googlefonts()
click to toggle source
# File lib/isodoc/nist/html_convert.rb, line 41 def googlefonts <<~HEAD.freeze <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,600,600i" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i|Space+Mono:400,700" rel="stylesheet" /> <link href="https://fonts.googleapis.com/css?family=Libre+Baskerville:400,400i,700,700i" rel="stylesheet"> HEAD end
html_head()
click to toggle source
Calls superclass method
# File lib/isodoc/nist/html_convert.rb, line 49 def html_head() super + <<~HEAD.freeze <link rel="stylesheet" href="https://pages.nist.gov/nist-header-footer/css/nist-combined.css"> <script src="https://pages.nist.gov/nist-header-footer/js/jquery-1.9.0.min.js" type="text/javascript" defer="defer"></script> <script src="https://pages.nist.gov/nist-header-footer/js/nist-header-footer.js" type="text/javascript" defer="defer"></script> HEAD end
html_toc(docxml)
click to toggle source
# File lib/isodoc/nist/html_convert.rb, line 67 def html_toc(docxml) idx = docxml.at("//div[@id = 'toc']") or return docxml toc = "<ul>" path = toclevel_classes.map do |l| "//main//#{l}[not(@class = 'TermNum')][not(@class = 'noTOC')]"\ "[text()][not(@class = 'AbstractTitle')]"\ "[not(@class = 'IntroTitle')][not(@class = 'ForewordTitle')]" end docxml.xpath(path.join(" | ")).each_with_index do |h, tocidx| h["id"] ||= "toc#{tocidx}" toc += html_toc_entry(h.name, h) end idx.children = "#{toc}</ul>" docxml end
make_body(xml, docxml)
click to toggle source
# File lib/isodoc/nist/html_convert.rb, line 83 def make_body(xml, docxml) body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72", "xml:lang": "EN-US", class: "container" } xml.body **body_attr do |body| make_body1(body, docxml) make_body2(body, docxml) make_body3(body, docxml) end end
make_body3(body, docxml)
click to toggle source
# File lib/isodoc/nist/html_convert.rb, line 117 def make_body3(body, docxml) body.div **{ class: "main-section" } do |div3| foreword docxml, div3 preface_block docxml, div3 abstract docxml, div3 keywords docxml, div3 boilerplate docxml, div3 preface docxml, div3 middle docxml, div3 footnotes div3 comments div3 end end
termdef_parse(node, out)
click to toggle source
# File lib/isodoc/nist/html_convert.rb, line 131 def termdef_parse(node, out) out.dl **{ class: "terms_dl" } do |dl| dl.dt do |dt| term_and_termref_parse(node, dt) end dl.dd do |dd| term_rest_parse(node, dd) end end end
toclevel()
click to toggle source
# File lib/isodoc/nist/html_convert.rb, line 57 def toclevel ret = toclevel_classes.map do |l| "#{l}:not(:empty):not(.TermNum):not(.noTOC):not(.AbstractTitle):"\ "not(.IntroTitle):not(.ForewordTitle)" end <<~HEAD.freeze function toclevel() { return "#{ret.join(',')}";} HEAD end