Styling HTML output
Tip
|
Summary
|
Styling of output is intended to be configurable:
-
HTML stylesheets are expressed in SCSS, with their fonts populated through the
default_fonts()
method in theIsoDoc::…::HtmlConvert
class. -
Frontispiece content is templated, populated from the metadata parsed in the
IsoDoc::…::Metadata
class, via Liquid templates. -
The default stylesheets and HTML templates themselves are nominated in the
default_file_locations()
method in theIsoDoc::…::HtmlConvert
class.
That means you can change the styling of output documents readily, so long as you are aware of the functionality of the stylesheet.
-
Styling information is stored in the
…/lib/isodoc/html
folder of the gem, and applies to both Word and HTML content. For HTML content, the relevant files arehtml_…titlepage.html
(title page HTML template),html…_intro.html
(introductory HTML template, typically restricted to Table of Contents),scripts.html
(Javascript scripts), andhtmlstyle.css
(the HTML stylesheet). -
The styling files to be loaded in are set in the
default_file_locations()
method ofIsoDoc::…::HtmlConvert
. The files can be overridden through document variables in the AsciiDoc document. -
Additional files (e.g. logos) can be loaded in the
initialize()
method ofIsoDoc::…::HtmlConvert
; for them to be access during document generation, they need to be copied to the working directory. (They can be removed subsequently by adding them to the@files_to_delete
array. All image files are copied into an_html
subdirectory.) -
The HTML templates are populated through Liquid Templates: variables in
{{…}}
correspond to the hash keys for metadata extracted inIsoDoc::…::Metadata
, and its superclassIsoDoc::Metadata
in theisodoc
gem. See Metadata and Predefined text for more information. -
The SCSS stylesheets treat fonts as variables. Those variables are set in
default_fonts()
, which generates variable assignments for SCSS. Stylesheets normally recognize three fonts:$bodyfont
for body text,$headerfont
for headers and captions (which may be the same font as$bodyfont
), and$monospacefont
for monospace text. Note thatdefault_fonts()
takes the options passed to initialiseHtmlConvert
as a parameter; the document language and script can be used to make different font choices for different document scripts. (The existing gems refer toLatn
, Latin script, andHans
, Simplified Chinese script.) -
Usually for HTML the fonts used are Web fonts. The HTML specifying the Web fonts used is set in
googlefonts
. -
Javascript scripts are populated in
scripts.html
; the scripts already in place in any gem you modify are in live use, and you should work out what they do before removing them. The AnchorJS script, for example, is used to generate navigable anchors in the document. (PDF is generated from HTML in Metanorma, but a distinct PDF-specific set of Javascript scripts can be specified asscripts-pdf.html
.) -
The Javascript defining which headings to include in the HTML Table of Contents is defined in
toclevel
. -
Additional scripts and fonts may be loaded in the document head through the
html_head()
method ofIsoDoc::…::HtmlConvert
. The existing gems use the document head to load jQuery, the Table of Contents generation script, any web fonts, and Font Awesome. -
The classes in the SCSS stylesheet correspond to static HTML content in the HTML templates, and dynamic HTML content in the
IsoDoc::…::HtmlConvert
class, and its superclassesIsoDoc::HtmlConvert
andIsoDoc::Common
in theisodoc
gem.
An HTML document is populated as follows:
-
HTML Head wrapper (in
IsoDoc::HtmlConvert
)-
html_head()
content -
@htmlstylesheet
CSS stylesheet (expected to be in SCSS, generated from SCSS in thegenerate_css()
method ofIsodoc::HtmlConvert
).
-
-
HTML Body
-
@htmlcoverpage
HTML template (optional, corresponds tohtml_…_titlepage.html
) -
@htmlintropage
HTML template (optional, corresponds tohtml_…_intro.html
) -
Document proper (converted from Metanorma XML)
-
MathJax script, for rendering MathML (all math syntaxes are converted into MathML),
-
and Google Code Prettify, for highlighting sourcecode.
-
@scripts
Javascript Scripts (optional, corresponds toscripts.html
)