diff options
author | Albert Krewinkel <albert@zeitkraut.de> | 2017-12-20 21:59:11 +0100 |
---|---|---|
committer | Albert Krewinkel <albert@zeitkraut.de> | 2017-12-20 22:24:41 +0100 |
commit | 5d3573e780d5056c87bb64858ea0890a27bc1686 (patch) | |
tree | ecf87706e1043d45945a8086a39b276c49ce8312 /data | |
parent | 299e452463b07f16a434a847612cae1ab7a8132f (diff) | |
download | pandoc-5d3573e780d5056c87bb64858ea0890a27bc1686.tar.gz |
Lua modules: turn pipe, read into full Haskell functions
The `pipe` and `read` utility functions are converted from hybrid
lua/haskell functions into full Haskell functions. This avoids the need
for intermediate `_pipe`/`_read` helper functions, which have dropped.
Diffstat (limited to 'data')
-rw-r--r-- | data/pandoc.lua | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/data/pandoc.lua b/data/pandoc.lua index 3be3b507a..df8aa06c4 100644 --- a/data/pandoc.lua +++ b/data/pandoc.lua @@ -874,53 +874,6 @@ M.UpperAlpha = "UpperAlpha" -- Helper Functions -- @section helpers ---- Parse the given string into a Pandoc document. --- The method used to interpret input is specified by *format*. Acceptable --- values for this parameter are equal to those that can be given to the --- `--from` command line option. --- @tparam string markup the markup to be parsed --- @tparam[opt] string format format specification, defaults to "markdown". --- @treturn Pandoc 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") -function M.read(markup, format) - format = format or "markdown" - local pd = pandoc._read(format, markup) - if type(pd) == "string" then - error(pd) - else - return pd - end -end - ---- Runs command with arguments, passing it some input, and returns the output. --- @treturn string Output of command. --- @raise A table containing the keys `command`, `error_code`, and `output` is --- thrown if the command exits with a non-zero error code. --- @usage --- local ec, output = pandoc.pipe("sed", {"-e","s/a/b/"}, "abc") -function M.pipe (command, args, input) - local ec, output = pandoc._pipe(command, args, input) - if ec ~= 0 then - err = setmetatable( - { command = command, error_code = ec, output = output}, - { __tostring = function(e) - return "Error running " .. e.command - .. " (error code " .. e.error_code .. "): " - .. e.output - end - } - ) - error(err) - end - return output -end - --- Use functions defined in the global namespace to create a pandoc filter. -- All globally defined functions which have names of pandoc elements are -- collected into a new table. |