Class: IsoDoc::Ogc::HtmlConvert
- Inherits:
-
HtmlConvert
- Object
- HtmlConvert
- IsoDoc::Ogc::HtmlConvert
show all
- Includes:
- BaseConvert, Init
- Defined in:
- lib/isodoc/ogc/html_convert.rb
Instance Method Summary
collapse
Methods included from Init
#bibrenderer, #fileloc, #i18n_init, #metadata_init, #submittingorgs_path, #xref_init
#abstract, #acknowledgements, #cleanup, #error_parse, #example_label, #example_name_parse, #example_parse, #foreword, #hi_parse, #intro_clause, #is_clause?, #make_tr_attr, #middle_clause, #ol_depth, #para_class, #preface, #table_attrs, #term_cleanup, #term_cleanup_merge_admitted, #term_cleanup_merge_termnum, #top_element_render
Constructor Details
#initialize(options) ⇒ HtmlConvert
Returns a new instance of HtmlConvert.
10
11
12
13
|
# File 'lib/isodoc/ogc/html_convert.rb', line 10
def initialize(options)
@libdir = File.dirname(__FILE__)
super
end
|
Instance Method Details
#admonition_class(node) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/isodoc/ogc/html_convert.rb', line 42
def admonition_class(node)
case node["type"]
when "important" then "Admonition Important"
when "warning" then "Admonition Warning"
when "caution" then "Admonition Caution"
when "todo" then "Admonition Todo"
when "editor" then "Admonition Editor"
when "tip" then "Admonition Tip"
when "safety-precaution" then "Admonition Safety-Precaution"
else "Admonition"
end
end
|
#authority_cleanup(docxml) ⇒ Object
70
71
72
73
|
# File 'lib/isodoc/ogc/html_convert.rb', line 70
def authority_cleanup(docxml)
authority_cleanup1(docxml, "contact")
super
end
|
#collapsible(html) ⇒ Object
156
157
158
159
160
161
162
163
|
# File 'lib/isodoc/ogc/html_convert.rb', line 156
def collapsible(html)
html.xpath("//*[@class = 'sourcecode' or @class = 'figure']")
.each do |d|
d["class"] += " hidable"
d.previous = "<p class='collapsible active'> </p>"
end
html
end
|
#default_file_locations(_options) ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/isodoc/ogc/html_convert.rb', line 26
def default_file_locations(_options)
{
htmlstylesheet: html_doc_path("htmlstyle.scss"),
htmlcoverpage: html_doc_path("html_ogc_titlepage.html"),
htmlintropage: html_doc_path("html_ogc_intro.html"),
}
end
|
#default_fonts(_options) ⇒ Object
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/isodoc/ogc/html_convert.rb', line 15
def default_fonts(_options)
{
bodyfont: '"Overpass",sans-serif',
headerfont: '"Overpass",sans-serif',
monospacefont: '"Space Mono",monospace',
normalfontsize: "16px",
monospacefontsize: "0.8em",
footnotefontsize: "0.9em",
}
end
|
143
144
145
146
147
148
149
150
|
# File 'lib/isodoc/ogc/html_convert.rb', line 143
def figure_parse1(node, out)
out.div **figure_attrs(node) do |div|
node.children.each do |n|
parse(n, div) unless n.name == "fmt-name"
end
end
figure_name_parse(node, out, node.at(ns("./fmt-name")))
end
|
#googlefonts ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/isodoc/ogc/html_convert.rb', line 34
def googlefonts
<<~HEAD.freeze
<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=Overpass:300,300i,600,900" rel="stylesheet"/>
<link href="https://fonts.googleapis.com/css?family=Teko:300,400,500" rel="stylesheet"/>
HEAD
end
|
#heading_anchors(html) ⇒ Object
132
133
134
135
136
137
138
139
140
141
|
# File 'lib/isodoc/ogc/html_convert.rb', line 132
def heading_anchors(html)
super
html.xpath("//p[@class = 'RecommendationTitle'] | " \
"//p[@class = 'RecommendationTestTitle']").each do |h|
div = h.xpath("./ancestor::table[@id]")
div.empty? and next
heading_anchor(h, div[-1]["id"])
end
html
end
|
#html_cleanup(html) ⇒ Object
152
153
154
|
# File 'lib/isodoc/ogc/html_convert.rb', line 152
def html_cleanup(html)
collapsible(super)
end
|
#html_head ⇒ Object
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/isodoc/ogc/html_convert.rb', line 75
def html_head
ret = super
ret += html_head_kw
ret += html_head_abstract
ret += html_head_creator
ret += html_head_date
ret += html_head_title
ret += html_head_dc
ret
end
|
#html_head_abstract ⇒ Object
86
87
88
89
90
91
|
# File 'lib/isodoc/ogc/html_convert.rb', line 86
def html_head_abstract
k = @meta.get[:abstract] and k = @c.encode(k)&.gsub("'", "'")
(k.nil? || k.empty?) and return ""
"<meta name='description' content='#{k}'/>\n" \
"<meta name='DC.description' lang='#{@lang}' content='#{k}' />"
end
|
#html_head_creator ⇒ Object
112
113
114
115
116
117
|
# File 'lib/isodoc/ogc/html_convert.rb', line 112
def html_head_creator
k = @meta.get[:authors] and
k = @c.encode(k.join(", ")).gsub("'", "'")
(k.nil? || k.empty?) and return ""
"<meta name='DC.creator' lang='#{@lang}' content='#{k}' />"
end
|
#html_head_date ⇒ Object
119
120
121
122
123
124
|
# File 'lib/isodoc/ogc/html_convert.rb', line 119
def html_head_date
k = @meta.get[:revdate] || @meta.get[:ipublisheddate] and
k = @c.encode(k)&.gsub("'", "'")
(k.nil? || k.empty?) and return ""
"<meta name='DC.date' content='#{k}' />"
end
|
#html_head_dc ⇒ Object
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/isodoc/ogc/html_convert.rb', line 101
def html_head_dc
<<~HTML
<link rel="profile" href="http://dublincore.org/documents/2008/08/04/dc-html/" />
<link rel="schema.DC" href="http://purl.org/dc/elements/1.1/" />
<meta name="DC.language" content="#{@lang}" />
<meta name="DC.rights" lang="#{@lang}" content="CC-BY-4.0"/>
<link rel="schema.DCTERMS" href="http://purl.org/dc/terms/" />
<link rel="DCTERMS.license" href="https://www.ogc.org/license" />
HTML
end
|
#html_head_kw ⇒ Object
93
94
95
96
97
98
99
|
# File 'lib/isodoc/ogc/html_convert.rb', line 93
def html_head_kw
k = @meta.get[:keywords].join(", ") and
k = @c.encode(k).gsub("'", "'")
k.empty? and return ""
"<meta name='keywords' content='#{k}'/>" \
"<meta name='DC.subject' lang='#{@lang}' content='#{k}' />"
end
|
#html_head_title ⇒ Object
126
127
128
129
130
|
# File 'lib/isodoc/ogc/html_convert.rb', line 126
def html_head_title
k = @meta.get[:doctitle] and k = @c.encode(k)&.gsub("'", "'")
(k.nil? || k.empty?) and return ""
"<meta name='DC.title' lang='#{@lang}' content='#{k}' />"
end
|
#inject_script(doc) ⇒ Object
165
166
167
168
169
170
171
|
# File 'lib/isodoc/ogc/html_convert.rb', line 165
def inject_script(doc)
a = super.split(%{</body>})
scripts = File.read(File.join(File.dirname(__FILE__),
"html/scripts.html"),
encoding: "UTF-8")
"#{a[0]}#{scripts}#{a[1]}"
end
|
#make_body(xml, docxml) ⇒ Object
55
56
57
58
59
60
61
62
63
|
# File 'lib/isodoc/ogc/html_convert.rb', line 55
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
65
66
67
68
|
# File 'lib/isodoc/ogc/html_convert.rb', line 65
def make_body3(body, docxml)
@prefacenum = 0
super
end
|
to pass on to imported _coverpage.scss
174
175
176
177
178
179
180
181
182
183
|
# File 'lib/isodoc/ogc/html_convert.rb', line 174
def (is_html_css)
super + <<~SCSS
$color_text : #{@meta.get[:"presentation_metadata_color-text"].first};
$color_background_page : #{@meta.get[:"presentation_metadata_color-background-page"].first};
$color_background_definition_term : #{@meta.get[:"presentation_metadata_color-background-definition-term"].first};
$color_background_definition_description : #{@meta.get[:"presentation_metadata_color-background-definition-description"].first};
$color_secondary_shade_1 : #{@meta.get[:"presentation_metadata_color-secondary-shade-1"].first};
$color_background : #f6f8fa;
SCSS
end
|