Operation Configuration Attributes Layout selection Translations Content Attributes Menus Page Excerpt Page Type News Example: Git log Redirect Templates Variables Installation

Templates

The pages are exported from Zim to a temporary location with the default Markdown template. After the Markdown files are preporcessed in the temporary location, they are converted to HTML with Pandoc.

Pandoc template selection

The exporter uses Pandoc to convert Markdown files to HTML5. The exporter expects the templates in the selected layout to have the extension '.html5'. A Pandoc template can be selected for each page. The exporter first checks if a specific template for a page exists. The name of the specific template is obtained from the template attribute. If a type attribute is defined for the page, the exporter checks if a template for the page type exists. The name of the page-type specific template is obtained by adding '@' to the beginning and the end of the type name, eg. '@news@.html5'. If no specific templates are found, the template 'default.html5' is used.

Pandoc template preprocessing

Template fragment inclusion

When multiple templates are defined in a layout, some parts of the templates repeat in many templates. To simplify the maintenance of templates, these can be combined from multiple files. The preprocessor replaces the directive [@include <filename>@] with the contents of the file . The included files usually have the extension '.htmli'. The templates are processed in arbitrary order and in-place so multi-level inclusion is not supported.

Translations of template texts

Templates can include static text that can be translated to different languages. The preprocesor replaces the directive [@tr variable Default-Text @] with the pandoc placeholder $sx.tr.variable$ and registeres a translation variable. The variable will hold the translated value for each page based on the page's language or the default text if a translation is not available for a language.

Custom template resources

Templates can include custom resurces defined for each page. The preprocesor replaces the directive [@res variable Default-Filename @] with the pandoc placeholder $sx.res.variable$ and registeres a translation variable. If the resource is an attachment of the active layout page, the relative path from the page to the resource file will be stored in the variable. The resource can be changed for each page by setting the value of variable in YAML attributes. See the Resource Example.