Pandoc plugin
This page was written in LibreOffice Writer and saved in ODT format. šµāš« Sounds like a 1st April joke, but itās just to demonstrate possibilities of Pandoc plugin for Luasmith!
How to use
Use the module:
pandoc = require("pandoc")
And then add a node to your pipeline:
pandoc.processPandoc(pattern, options, contentSource)
All arguments are optional.
- pattern is a filter that defines what files will be processed (default: %.md$);
- options is a string with additional arguments that will be passed to Pandoc command-line (you donāt need to specify -t html here, this will be passed anyway);
- contentSource is your content directory (if not provided, the plugin will fall back to source global variable or args[3] global variable if available, otherwise it will fall back to "content" directory)
A formatting that will be exported to HTML completely depends on how Pandoc parses your document, so refer to Pandoc documentation (this page in particular has a very limited formatting because I didnāt bother to write custom filters or find another way, if it exists, to enrich ODT export; yet relative links work as expected).
Since itās possible to add arguments to command-line, you can also use Lua filters for Pandoc (or simply modify luasmith-pandoc-filter.lua that comes along with the plugin and gets passed to Pandoc automatically).
Take a note that calling Pandoc as an external program for each page leads to a SEVERE increase of build time for your site compared to using built-in Markdown parser of Luasmith; itās not the best idea to pass all your Markdown content to Pandoc if it can be processed using the built-in parser. For example, compiling Jared Krinkeās blog with built-in blog theme takes less than 500ms, but when using modified theme with Pandoc processing ā almost 15 seconds!
For documents that canāt have metadata in a front-matter (like .odt files), you can write a separate metadata file and it will be automatically passed to Pandoc. This file must have the same name as your document but with .yaml extension (for example, this page is generated from pandoc.odt and pandoc.yaml with metadata next to it). If metadata file is not found, the plugin will try to read metadata from the document. In both cases metadata will be parsed by built-in Luasmith front-matter parser that has limited YAML support for now. Used metadata files will automatically be removed from Luasmith items list, so they wonāt appear in your website.