git.iko.soy/typeable/pandoc
on master help sign in
doc/filters.md: describe technical details of filter invocations (#6815)
commit0ed3436588951d457eefb11351f72d3560bdc544 authorAlbert Krewinkel <albert@zeitkraut.de> dateSat 7 Nov 2020, 00:37 (6 years ago) parent22e5efe
2 files changed+81
doc/filters.md+79 src/Text/Pandoc/Options.hs+2
doc/filters.md+79
@@ -425,3 +425,82 @@ the Japanese characters (e.g. "Noto Sans CJK TC"), and add
4254255. Find all code blocks with class `python` and run them
426426 using the python interpreter, printing the results to the console.
427427
428+# Technical details of JSON filters
429+
430+A JSON filter is any program which can consume and produce a
431+valid pandoc JSON document representation. This section describes
432+the technical details surrounding the invocation of filters.
433+
434+## Arguments
435+
436+The program will always be called with the target format as the
437+only argument. A pandoc invocation like
438+
439+ pandoc --filter demo --to=html
440+
441+will cause pandoc to call the program `demo` with argument `html`.
442+
443+## Environment variables
444+
445+Pandoc sets additional environment variables before calling a
446+filter.
447+
448+`PANDOC_VERSION`
449+: The version of the pandoc binary used to process the document.
450+ Example: `2.11.1`.
451+
452+`PANDOC_READER_OPTIONS`
453+: JSON object representation of the options passed to the input
454+ parser.
455+
456+ Object fields:
457+
458+ `readerAbbreviations`
459+ : set of known abbreviations (array of strings).
460+
461+ `readerColumns`
462+ : number of columns in terminal; an integer.
463+
464+ `readerDefaultImageExtension`
465+ : default extension for images; a string.
466+
467+ `readerExtensions`
468+ : integer representation of the syntax extensions bit
469+ field.
470+
471+ `readerIndentedCodeClasses`
472+ : default classes for indented code blocks; array of
473+ strings.
474+
475+ `readerStandalone`
476+ : whether the input was a standalone document with header;
477+ either `true` or `false`.
478+
479+ `readerStripComments`
480+ : HTML comments are stripped instead of parsed as raw HTML;
481+ either `true` or `false`.
482+
483+ `readerTabStop`
484+ : width (i.e. equivalent number of spaces) of tab stops;
485+ integer.
486+
487+ `readerTrackChanges`
488+ : track changes setting for docx; one of
489+ `"accept-changes"`, `"reject-changes"`, and
490+ `"all-changes"`.
491+
492+## Supported interpreters
493+
494+Files passed to the `--filter`/`-F` parameter are expected to be
495+executable. However, if the executable bit is not set, then
496+pandoc tries to guess a suitable interpreter from the file
497+extension.
498+
499+ file extension interpreter
500+ ---------------- --------------
501+ .py `python`
502+ .hs `runhaskell`
503+ .pl `ruby`
504+ .php `php`
505+ .js `node`
506+ .r `Rscript`
src/Text/Pandoc/Options.hs+2
@@ -314,6 +314,7 @@ defaultMathJaxURL = "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.j
314314defaultKaTeXURL :: Text
315315defaultKaTeXURL = "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.11.1/"
316316
317+-- Update documentation in doc/filters.md if this is changed.
317318$(deriveJSON defaultOptions ''ReaderOptions)
318319
319320$(deriveJSON defaultOptions{
@@ -337,6 +338,7 @@ $(deriveJSON defaultOptions{ constructorTagModifier =
337338
338339$(deriveJSON defaultOptions ''HTMLSlideVariant)
339340
341+-- Update documentation in doc/filters.md if this is changed.
340342$(deriveJSON defaultOptions{ constructorTagModifier =
341343 camelCaseStrToHyphenated
342344 } ''TrackChanges)