From 820ee07f729e759d0e1da160c87b527881ee00e8 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Fri, 29 Dec 2017 09:04:21 +0100 Subject: doc/lua-filters.md: re-add docs for helper functions These docs are dropped, as the functions are no longer part of data/pandoc.lua, from which this section is generated. This is only a temporary fix: a proper fix will have to re-think how this section is updated. --- doc/lua-filters.md | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/doc/lua-filters.md b/doc/lua-filters.md index 6e34acbd4..afa9b939f 100644 --- a/doc/lua-filters.md +++ b/doc/lua-filters.md @@ -1344,6 +1344,81 @@ Lua functions for pandoc scripts. -- the above is equivalent to -- return {{Str = Str}} +[`pipe (command, args, input)`]{#pipe} + +: Runs command with arguments, passing it some input, and + returns the output. + + Returns: + + - Output of command. + + Raises: + + - A table containing the keys `command`, `error_code`, and + `output` is thrown if the command exits with a non-zero + error code. + + Usage: + + local output = pandoc.pipe("sed", {"-e","s/a/b/"}, "abc") + +[`walk_block (element, filter)`]{#walk_block} + +: Apply a filter inside a block element, walking its + contents. + + Parameters: + + `element`: + : the block element + + `filter`: + : a lua filter (table of functions) to be applied + within the block element + + Returns: the transformed block element + +[`walk_inline (element, filter)`]{#walk_inline} + +: Apply a filter inside an inline element, walking its + contents. + + Parameters: + + `element`: + : the inline element + + `filter`: + : a lua filter (table of functions) to be applied + within the inline element + + Returns: the transformed inline element + +[`read (markup[, format])`]{#read} + +: Parse the given string into a Pandoc document. + + Parameters: + + `markup`: + : the markup to be parsed + + `format`: + : format specification, defaults to \"markdown\". + + Returns: pandoc document + + Usage: + + local org_markup = "/emphasis/" -- Input to be read + local document = pandoc.read(org_markup, "org") + -- Get the first block of the document + local block = document.blocks[1] + -- The inline element in that block is an `Emph` + assert(block.content[1].t == "Emph") + + # Module pandoc.utils This module exposes internal pandoc functions and utility -- cgit v1.2.3