LEFT TEXT
_library/index-include.md.cms
_library/sitemap-include.md.cms
If you need to render a format not already handled by pandoc, or you want to change how pandoc renders a format, you can create a custom writer using the Lua language. Pandoc has a built-in Lua interpreter, so you needn’t install any additional software to do this.
A custom writer is a Lua file that defines how to render the document. Two styles of custom writers are supported: classic custom writers must define rendering functions for each AST element. New style writers, available since pandoc 2.17.2, must define just a single function Writer
, which gets passed the document and writer options, and then does all rendering.
A writer using the classic style defines rendering functions for each element of the pandoc AST.
For example,
The best way to go about creating a classic custom writer is to modify the example that comes with pandoc. To get the example, you can do
pandoc --print-default-data-file sample.lua > sample.lua
[…]
If you need to parse a format not already handled by pandoc, you can create a custom reader using the Lua language. Pandoc has a built-in Lua interpreter, so you needn’t install any additional software to do this.
A custom reader is a Lua file that defines a function called Reader
, which takes two arguments:
{ columns = 62, standalone = true }
.The Reader
function should return a Pandoc
AST. This can be created using functions in the pandoc
module, which is automatically in scope. (Indeed, all of the utility functions that are available for Lua filters are available in custom readers, too.)
Each source item corresponds to a file or stream passed to pandoc containing its text and name. E.g., if a single file input.txt
is passed to pandoc, then the list of sources will contain just a single element s
, where s.name == 'input.txt'
and s.text
contains the file contents as a string.
[…]
Pandoc has long supported filters, which allow the pandoc abstract syntax tree (AST) to be manipulated between the parsing and the writing phase. Traditional pandoc filters accept a JSON representation of the pandoc AST and produce an altered JSON representation of the AST. They may be written in any programming language, and invoked from pandoc using the --filter
option.
Although traditional filters are very flexible, they have a couple of disadvantages. First, there is some overhead in writing JSON to stdout and reading it from stdin (twice, once on each side of the filter). Second, whether a filter will work will depend on details of the user’s environment. A filter may require an interpreter for a certain programming language to be available, as well as a library for manipulating the pandoc AST in JSON form. One cannot simply provide a filter that can be used by anyone who has a certain version of the pandoc executable.
Starting with version 2.0, pandoc makes it possible to write filters in Lua without any external dependencies at all. A Lua interpreter (version 5.3) and a Lua library for creating pandoc filters is built into the pandoc executable. Pandoc data types are marshaled to Lua directly, avoiding the overhead of writing JSON to stdout and reading it from stdin.
[…]
pandoc
[options] [input-file]…
Pandoc is a Haskell library for converting from one markup format to another, and a command-line tool that uses this library.
Pandoc can convert between numerous markup and word processing formats, including, but not limited to, various flavors of Markdown, HTML, LaTeX and Word docx. For the full lists of input and output formats, see the --from
and --to
options below. Pandoc can also produce PDF output: see creating a PDF, below.
Pandoc’s enhanced version of Markdown includes syntax for tables, definition lists, metadata blocks, footnotes, citations, math, and much more. See below under Pandoc’s Markdown.
[…]
#WORK # introduction
Top Bar | brand (homepage ) |
nav-top |
info-top / search.* |
Main Page | nav-left |
c_list |
nav-right |
Bottom Bar | copyright |
nav-bottom |
info-bottom / (composer ) |
The entire list of pages in this test site can be found in the main sitemap. To understand how the site is configured, and to see demonstrations of all the features, visit the following pages. This list can be found in the PAGES
menu on the top bar throughout the site.
site-config | defaults |
---|---|
brand null | |
homepage null | |
search :: name null | |
search :: site null | |
search :: call null | |
search :: form null | |
copyright null | |
composer 1 |
|
header null |
|
footer null |
|
css_overlay dark |
|
copy_protect null |
|
cols_break lg |
|
cols_scroll 1 |
|
cols_order [ 1, 2, 3 ] |
|
cols_reorder [ 1, 3, 2 ] |
|
cols_size [ 3, 7, 2 ] |
|
cols_resize `[ 6, 12, 6 ] | ` |
metainfo ` |
itle><|> – <author|; >` |
metainfo_null *(none)* |
|
metalist :: author title: `Aut | hor
{=html} *display:* Authors: <|>, <|>` |
metalist :: tags title: `Tag |
{=html} *display:* Tags: <|>, <|>` |
readtime `*Reading tim | e: |
readtime_wpm 220 |
[…]
This is a default page, where all menus and settings are empty. All aspects of c_site
pages are configurable using .composer.yml
files.
Top Bar | brand (homepage ) |
nav-top |
info-top / search.* |
Main Page | nav-left |
c_list |
nav-right |
Bottom Bar | copyright |
nav-bottom |
info-bottom / (composer ) |
In the layout, this page column is c_list
, and the default cols_size
for the center column is 7
and cols_resize
for the mobile view is 12
. Since nav-left
and nav-right
are both empty, this column is positioned at the left edge.
In the absence of the PAGES
menu, use the list below to navigate to the other example pages.
[…]
#WORK
<!-- composer >> metainfo -->
site-config | defaults | values |
---|---|---|
brand null | null | |
homepage null | null | |
search :: name null | null | |
search :: site null | null | |
search :: call null | null | |
search :: form null | null | |
copyright null | null | |
composer 1 |
1 |
|
header null |
`../config/_h | eader.md.cms` |
footer null |
`../config/_f | ooter.md.cms` |
css_overlay dark |
null |
|
copy_protect null |
1 |
|
cols_break lg |
md |
|
cols_scroll 1 |
null |
|
cols_order [ 1, 2, 3 ] |
[ 1, 3, 2 ] |
|
cols_reorder [ 1, 3, 2 ] |
[ 2, 3, 1 ] |
|
cols_size [ 3, 7, 2 ] |
`[ 12, 9, 3 ] | ` |
cols_resize `[ 6, 12, 6 ] | [ 12, 12, 0 |
]` |
metainfo ` |
itle><|> – <author|; >
|
; ( – <author| – > . <tags| . >` |
metainfo_null *(none)* |
null |
|
metalist :: author title: `Aut | hor
{=html} *display:* Authors: <|>, <|>title: Creat |
or
{=html} display: |
metalist :: tags title: `Tag |
{=html} *display:* Tags: <|>, <|>title: Mark` |
display: <ul><li><|></li><li><|></li></ul> |
readtime `*Reading tim | e: |
d> / Minutes: |
readtime_wpm 220 |
200 |
[…]