By default, a Glyph project can be “compiled” into an HTML document. Additionally, Glyph can also be used to produce documents in the following formats:
- PDF (generated from HTML using a third-party generator like Prince or wkhtmltopdf)
- Web (i.e. multiple HTML files)
- Web5 (i.e. multiple HTML5 files)
To compile a Glyph project to an HTML document, use the
compile command within your Glyph project folder. Glyph parses the
document.glyph file (and all included files and snippets); if no errors are found, Glyph creates an HTML document in the
The name of the HTML file can be set in the configuration (
To create an HTML5 file instead, you must specify it explicitly like this:
glyph compile -f html5
To generate a PDF document, you must specify
glyph compile -f pdf
The command above will attempt to compile the project into an HTML document and then call a third-party PDF generator to convert it into a PDF file.
Currently, Glyph supports:
- Prince (version 7.0 or higher) — a commercial generator that can be used freely for personal use. Prince produces high-quality PDF files and implement most of the new features introduced in CSS3, used heavily in Glyph’s
- wkhtmltopdf (version 1.0 beta4 or higher) — an open source generator that uses the WebKit rendering engine to transform HTML files into PDF. Although not as advanced as Prince, it produces very satisfactory results.
By default, Glyph attempts to use wkhtmltopdf. To change this, set the
output_pdf_generator setting to
To generate .epub or .mobi e-books, you must specify
mobi as format, like this:
glyph compile -f mobi
glyph compile -f epub
This option requires that you have Calibre and its command-line tools installed. Glyph assumes the ebook-convert command is installed in /usr/bin. If this is not so, you can set the
options.ebook.converter option to the path to the ebook-convert command.
If you have cover art for your e-book, put it in the
images folder, and specify the name of the file in the
document.cover configuration option.
You can also specify the output profile used by the
ebook-convert command by setting the
output.mobi.profile options. If these are not specified, the conversion will use the
kindle output profile for mobi files, and the
nook output profile for epub files. See the documentation for Calibre for a list of available output profiles.
Basically, here’s what happens when you compile your project in web or web5 format:
- The document code is parsed as normal
- Separate topic files are generated according to the
@srcattributes of your sections
document.glyph(or whatever file you’re using as document source) is not rendered. Instead, an
index.htmlfile will be created in the output folder based on the contents of your index layout.
You can also call the
compile command with a
--auto switch. If you do so, your project will be recompiled automatically every time any source file is changed.