Class: IsoDoc::Iso::HtmlConvert
- Inherits:
-
HtmlConvert
- Object
- HtmlConvert
- IsoDoc::Iso::HtmlConvert
show all
- Includes:
- BaseConvert, Init
- Defined in:
- lib/isodoc/iso/html_convert.rb
Instance Method Summary
collapse
Methods included from Init
#amd?, #bibrenderer, #clausedelim, #i18n_conditional_set, #i18n_init, #metadata_init, #requirements_processor, #std_docid_semantic, #std_docid_semantic1, #std_docid_semantic_full, #update_i18n, #xref_init
#admonition_class, #admonition_name_parse, #admonition_p_parse, #admonition_parse, #admonition_parse1, #annex, #clause_etc1, #cleanup, #convert1, #convert_i18n_init, #error_parse, #example_p_parse, #example_parse, #example_parse1, #example_span_label, #figure_name_parse, #figure_parse1, #foreword, #implicit_reference, #measurement_units, #node_begins_with_para, #render_identifier, #table_cleanup, #table_parse, #table_parse_tail, #top_element_render
Constructor Details
#initialize(options) ⇒ HtmlConvert
Returns a new instance of HtmlConvert.
8
9
10
11
|
# File 'lib/isodoc/iso/html_convert.rb', line 8
def initialize(options)
@libdir = File.dirname(__FILE__)
super
end
|
Instance Method Details
#default_file_locations(options) ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/isodoc/iso/html_convert.rb', line 44
def default_file_locations(options)
{
htmlstylesheet: (if options[:alt]
html_doc_path("style-human.scss")
else
html_doc_path("style-iso.scss")
end),
htmlcoverpage: html_doc_path("html_iso_titlepage.html"),
htmlintropage: html_doc_path("html_iso_intro.html"),
}
end
|
#default_fonts(options) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/isodoc/iso/html_convert.rb', line 20
def default_fonts(options)
{
bodyfont: (if options[:script] == "Hans"
'"Source Han Sans",serif'
else
options[:alt] ? '"Lato",sans-serif' : '"Cambria",serif'
end),
headerfont: (if options[:script] == "Hans"
'"Source Han Sans",sans-serif'
else
options[:alt] ? '"Lato",sans-serif' : '"Cambria",serif'
end),
monospacefont: (if options[:alt]
'"Space Mono",monospace'
else
'"Courier New",monospace'
end),
normalfontsize: "1.0em",
smallerfontsize: "0.9em",
footnotefontsize: "0.9em",
monospacefontsize: "0.8em",
}
end
|
56
57
58
|
# File 'lib/isodoc/iso/html_convert.rb', line 56
def (link)
link.content += ")"
end
|
#googlefonts ⇒ Object
13
14
15
16
17
18
|
# File 'lib/isodoc/iso/html_convert.rb', line 13
def googlefonts
<<~HEAD.freeze
<link href="https://fonts.googleapis.com/css?family=Space+Mono:400,400i,700,700i&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Lato:400,400i,700,900" rel="stylesheet">
HEAD
end
|
#html_toc(docxml) ⇒ Object
76
77
78
79
80
81
82
|
# File 'lib/isodoc/iso/html_convert.rb', line 76
def html_toc(docxml)
super
docxml.xpath("//div[@id = 'toc']/ul[li[@class = 'h2']]").each do |u|
html_toc1(u)
end
docxml
end
|
#html_toc1(ulist) ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/isodoc/iso/html_convert.rb', line 84
def html_toc1(ulist)
u2 = nil
ulist.xpath("./li").each do |l|
if l["class"] != "h2"
u2 = nil
elsif u2 then u2.add_child(l.remove)
else
u2 = l.replace("<ul class='content collapse'>#{l}</ul>").first
p = u2.previous_element and p << u2
end
end
end
|
#html_toc_entry(level, header) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/isodoc/iso/html_convert.rb', line 60
def html_toc_entry(level, )
content = .at("./following-sibling::p" \
"[@class = 'variant-title-toc']") ||
if level == "h1" &&
.parent.name != "main" &&
.parent.at(".//h2#{toc_exclude_class}")
<<~HDR
<li class="#{level}"><div class="collapse-group"><a href="##{['id']}">#{(content)}</a>
<div class="collapse-button"></div></div></li>
HDR
else
%(<li class="#{level}"><a href="##{['id']}">\
#{(content)}</a></li>)
end
end
|
#inject_script(doc) ⇒ Object
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/isodoc/iso/html_convert.rb', line 97
def inject_script(doc)
scr = <<~HEAD.freeze
<script>
$(".collapse-button").click(function () {
$(this).toggleClass('expand'); // expand: the class to change the collapse button shape
// collapse: the class to collapse/expand the li elements with the h2 class
$(this).closest('li').children(".content").toggleClass('collapse');})
</script>
HEAD
a = super.split(%r{</body>})
"#{a[0]}#{scr}</body>#{a[1]}"
end
|
#ol_attrs(node) ⇒ Object
116
117
118
119
|
# File 'lib/isodoc/iso/html_convert.rb', line 116
def ol_attrs(node)
ret = super
ret.merge(class: OL_STYLE.invert[ret[:type]])
end
|
#table_th_center(docxml) ⇒ Object
110
111
112
113
114
|
# File 'lib/isodoc/iso/html_convert.rb', line 110
def table_th_center(docxml)
docxml.xpath("//thead//th | //thead//td").each do |th|
th["style"] += ";text-align:center;vertical-align:middle;"
end
end
|