diff options
| author | Albert Krewinkel <[email protected]> | 2024-05-27 23:20:31 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-05-27 14:20:31 -0700 |
| commit | ad68ff34aeb78e26d98a593dfdaf6bc4933857fc (patch) | |
| tree | 956d1788c84d44d64b9b337ac2dc4d373d218fd3 /pandoc-lua-engine/src/Text/Pandoc/Lua/Module | |
| parent | 205e54c245aaaa347046afd0e0b4008c993e4889 (diff) | |
Lua: add function `pandoc.utils.run_lua_filter` (#9803)
Diffstat (limited to 'pandoc-lua-engine/src/Text/Pandoc/Lua/Module')
| -rw-r--r-- | pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Utils.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Utils.hs b/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Utils.hs index 5fddf6e8b..fb3484465 100644 --- a/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Utils.hs +++ b/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Utils.hs @@ -29,6 +29,7 @@ import Text.Pandoc.Citeproc (getReferences, processCitations) import Text.Pandoc.Definition import Text.Pandoc.Error (PandocError) import Text.Pandoc.Filter (applyJSONFilter) +import Text.Pandoc.Lua.Filter (runFilterFile) import Text.Pandoc.Lua.Marshal.AST import Text.Pandoc.Lua.Marshal.Reference import Text.Pandoc.Lua.PandocLua (PandocLua (unPandocLua)) @@ -60,6 +61,7 @@ documentedModule = Module , from_simple_table `since` v[2,11] , make_sections `since` v[2,8] , references `since` v[2,17] + , run_lua_filter `since` v[3,2,1] , run_json_filter `since` v[2,1,1] , normalize_date `since` v[2,0,6] , sha1 `since` v[2,0,6] @@ -246,6 +248,18 @@ references = defun "references" , " end" ] +-- | Run a filter from a file. +run_lua_filter :: DocumentedFunction PandocError +run_lua_filter = defun "run_filter_filter" + ### (flip runFilterFile) + <#> parameter peekPandoc "Pandoc" "doc" "the Pandoc document to filter" + <#> parameter peekString "string" "filter" "filepath of the filter to run" + =#> functionResult pushPandoc "Pandoc" "filtered document" + #? ( "Filter the given doc by passing it through a Lua filter." <> + "\n\nThe filter will be run in the current Lua process." + ) + +-- | Process the document with a JSON filter. run_json_filter :: DocumentedFunction PandocError run_json_filter = defun "run_json_filter" ### (\doc filterPath margs -> do |
