Class: IsoDoc::NIST::HtmlConvert
- Inherits:
-
HtmlConvert
- Object
- HtmlConvert
- IsoDoc::NIST::HtmlConvert
show all
- Includes:
- BaseConvert, Init
- Defined in:
- lib/isodoc/nist/html_convert.rb
Overview
A Converter implementation that generates HTML output, and a document schema encapsulation of the document for validation
Constant Summary
Constants included
from BaseConvert
BaseConvert::FRONT_CLAUSE, BaseConvert::NIST_PUBLISHER_XPATH
Instance Method Summary
collapse
Methods included from Init
#fileloc, #i18n_init, #metadata_init, #suppress_biblio_title, #xref_init
#abstract, #bibliography, #bibliography_parse, #boilerplate, #bracket_if_num, #children_parse, #dl_parse, #errata_body, #errata_head, #errata_parse, #error_parse, #foreword, #glossary_parse, #info, #is_clause?, #keywords, #middle, #middle_clause, #modification_parse, #nistvariable_parse, #nonstd_bibitem, #ol_depth, #omit_docid_prefix, #preface, #preface1, #reference_format, #reference_format1, #requirement_cleanup, #skip_render, #std_bibitem_entry, #term_and_termref_parse, #term_cleanup, #term_rest_parse, #termref_parse, #terms_parse
Constructor Details
#initialize(options) ⇒ HtmlConvert
Returns a new instance of HtmlConvert.
12
13
14
15
|
# File 'lib/isodoc/nist/html_convert.rb', line 12
def initialize(options)
@libdir = File.dirname(__FILE__)
super
end
|
Instance Method Details
#authority_cleanup(docxml) ⇒ Object
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/isodoc/nist/html_convert.rb', line 94
def authority_cleanup(docxml)
dest = docxml.at("//div[@id = 'authority']") || return
auth = docxml.at("//div[@class = 'authority']") || return
auth.xpath(".//h1 | .//h2").each { |h| h["class"] = "IntroTitle" }
dest1 = docxml.xpath("//div[@class = 'authority6']")
auth1 = docxml&.at("//div[@id = 'authority6']")&.remove
dest1 and auth1 and dest1.each { |d| d.replace(auth1) }
dest.replace(auth.remove)
a = docxml.at("//div[@id = 'authority1']") and a["class"] = "authority1"
a = docxml.at("//div[@id = 'authority2']") and a["class"] = "authority2"
a = docxml.at("//div[@id = 'authority3']") and a["class"] = "authority3"
a = docxml.at("//div[@id = 'authority3a']") and a["class"] = "authority3"
a = docxml.at("//div[@id = 'authority4']") and a["class"] = "authority4"
a = docxml.at("//div[@id = 'authority5']") and a["class"] = "authority5"
a = docxml.at("//div[@id = 'authority6']") and a["class"] = "authority6"
end
|
#cleanup(docxml) ⇒ Object
111
112
113
114
115
116
|
# File 'lib/isodoc/nist/html_convert.rb', line 111
def cleanup(docxml)
super
term_cleanup(docxml)
requirement_cleanup(docxml)
docxml
end
|
#convert1(docxml, filename, dir) ⇒ Object
17
18
19
20
|
# 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) ⇒ Object
33
34
35
36
37
38
39
40
|
# 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"),
scripts: html_doc_path("scripts.html"),
}
end
|
#default_fonts(options) ⇒ Object
22
23
24
25
26
27
28
29
30
31
|
# 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 ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/isodoc/nist/html_convert.rb', line 42
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 ⇒ Object
50
51
52
53
54
55
56
|
# File 'lib/isodoc/nist/html_convert.rb', line 50
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) ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/isodoc/nist/html_convert.rb', line 68
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) ⇒ Object
84
85
86
87
88
89
90
91
92
|
# File 'lib/isodoc/nist/html_convert.rb', line 84
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) ⇒ Object
118
119
120
121
122
123
124
125
126
127
128
129
130
|
# File 'lib/isodoc/nist/html_convert.rb', line 118
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
div3
div3
end
end
|
#termdef_parse(node, out) ⇒ Object
132
133
134
135
136
137
138
139
140
141
|
# File 'lib/isodoc/nist/html_convert.rb', line 132
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 ⇒ Object
58
59
60
61
62
63
64
65
66
|
# File 'lib/isodoc/nist/html_convert.rb', line 58
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
|