git.iko.soy/typeable/pandoc
on master help sign in
add docs about customizing pandoc (#4972)
a5fc46cMauro Bieg
doc/customizing-pandoc.mdnew file+64
@@ -0,0 +1,64 @@
1+This document provides a quick overview over the various ways to
2+customize pandoc's output. Follow the links to learn how to use each
3+approach.
4+
5+[Templates](/MANUAL.html#templates)
6+
7+: Pandoc comes with a template for (almost) every output format. A
8+ template is a plain text file, that contains for example the line
9+ `$body$`. That variable is replaced by the document's body text on
10+ output.
11+
12+ There are many other variables, like `title`, `header-includes`,
13+ etc. that are either set automatically, or that you can set using
14+ [YAML metadata blocks](/MANUAL.html#extension-yaml_metadata_block),
15+ [`--metadata`](/MANUAL.html#option--metadata) (which properly escape
16+ things), or `--variable` (which does no escaping). You can also
17+ generate your own template (e.g. `pandoc -D html > myletter.html`)
18+ and customize that file, for example by introducing new variables.
19+
20+[reference.docx/pptx/odt](/MANUAL.html#option--reference-doc)
21+
22+: To output a `docx`, `pptx` or `odt` document, which is a ZIP of
23+ several files, things are a bit more complicated. Instead of a
24+ single template file, you need to provide a customized
25+ `reference.docx/pptx/odt`.
26+
27+[Lua filters](lua-filters.html) and [filters](filters.html)
28+
29+: Templates are very powerful, but they are only a sort of scaffold to
30+ place your document's body text in. You cannot directly change the
31+ body text using the template (beyond e.g. adding CSS for HTML
32+ output, or `\renewcommand` for LaTeX output).
33+
34+ If you need to affect the output of the actual body text, you
35+ probably need a pandoc filter. A filter is a small program, that
36+ transforms the document, between the parsing and the writing phase,
37+ while it is still in pandoc's native format -- an abstract syntax
38+ tree (AST), not unlike the HTML DOM. As can be seen in the [AST
39+ definition](https://hackage.haskell.org/package/pandoc-types/docs/Text-Pandoc-Definition.html)
40+ `Pandoc Meta [Block]`, a pandoc document is a chunk of metadata and
41+ a list of `Block`s.
42+
43+ - There's a [list of third party filters on the
44+ wiki](https://github.com/jgm/pandoc/wiki/Pandoc-Filters).
45+ - Unless you have a good reason not to, it's best to write your
46+ own filter in the Lua scripting language. Since pandoc ships
47+ with a Lua interpreter, Lua filters are very portable and
48+ efficient. See [Lua filters](lua-filters.html).
49+ - For a gentle introduction into filters and writing them in any
50+ programming language, see [filters](filters.html).
51+
52+Furthecustomizations
53+
54+: - [Custom Styles in Docx](/MANUAL.html#custom-styles-in-docx)
55+ - If you're converting from Markdown, see
56+ - [Generic raw attributes](/MANUAL.html#generic-raw-attribute):
57+ to include raw snippets
58+ - [Divs and Spans](/MANUAL.html#divs-and-spans): generic blocks
59+ that can be transformed with filters
60+ - [Custom syntax highlighting](/MANUAL.html#syntax-highlighting),
61+ provided by the [skylighting
62+ library](https://github.com/jgm/skylighting)
63+ - [Custom writers](/MANUAL.html#custom-writers)
64+ - [Pandoc Extras wiki page](https://github.com/jgm/pandoc/wiki/Pandoc-Extras)
doc/filters.md+2−2
@@ -12,8 +12,8 @@ reader into pandoc’s intermediate representation of the
12document---an "abstract syntax tree" or AST---which is then
12document---an "abstract syntax tree" or AST---which is then
13converted by the writer into the target format.
13converted by the writer into the target format.
14The pandoc AST format is defined in the module
14The pandoc AST format is defined in the module
15−`Text.Pandoc.Definition` in
15+[`Text.Pandoc.Definition` in the `pandoc-types` package
16−[pandoc-types](https://hackage.haskell.org/package/pandoc-types).
16+](https://hackage.haskell.org/package/pandoc-types/docs/Text-Pandoc-Definition.html).
17
17
18A "filter" is a program that modifies the AST, between the
18A "filter" is a program that modifies the AST, between the
19reader and the writer:
19reader and the writer: