diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2022-11-09 17:36:23 -0800 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2022-12-20 20:58:44 -0800 |
| commit | 063480accd3421bfc77478b8dbddc1985553ed75 (patch) | |
| tree | 4ef6d846f17085cbc2f7410123d7698c4196b069 /pandoc-lua-engine/src/Text/Pandoc/Lua.hs | |
| parent | 8553459f61eb2290008fafedcfbb1df0bb1fe1b4 (diff) | |
T.P.Scripting: Refactor the scripting engine.
The new type CustomComponents is exported from T.P.Scripting, and the
ScriptEngine fields are changed. Instead of separate fields for custom
readers and writers, we now have a single function that loads any number
of "components" from a script: these may be custom readers, custom
writers, templates for writers, or extension configs. (Note: it's
possible to have a custom reader and a custom writer for a format
together in the same file.)
Pandoc now checks the folder `custom` in the user's data directory for a
matching script if it can't find one in the local directory. Previously,
the `readers` and `writers` data directories were search for custom
readers and writers, respectively. Scripts in those directories must be
moved to the `custom` folder.
Custom readers used to implement a fallback behavior that allowed to
consume just a string value as input to the `Reader` function. This has
been removed, the first argument is now always a list of sources. Use
`tostring` on that argument to get a string.
Closes #8417.
Signed-off-by: Albert Krewinkel <albert@zeitkraut.de>
Diffstat (limited to 'pandoc-lua-engine/src/Text/Pandoc/Lua.hs')
| -rw-r--r-- | pandoc-lua-engine/src/Text/Pandoc/Lua.hs | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/pandoc-lua-engine/src/Text/Pandoc/Lua.hs b/pandoc-lua-engine/src/Text/Pandoc/Lua.hs index 8ff9a7c64..a42107082 100644 --- a/pandoc-lua-engine/src/Text/Pandoc/Lua.hs +++ b/pandoc-lua-engine/src/Text/Pandoc/Lua.hs @@ -13,8 +13,7 @@ Running pandoc Lua filters. module Text.Pandoc.Lua ( -- * High-level functions applyFilter - , readCustom - , writeCustom + , loadCustom -- * Low-level functions , Global(..) , setGlobals @@ -30,8 +29,7 @@ import Text.Pandoc.Error (PandocError) import Text.Pandoc.Lua.Filter (applyFilter) import Text.Pandoc.Lua.Global (Global (..), setGlobals) import Text.Pandoc.Lua.Init (runLua, runLuaNoEnv) -import Text.Pandoc.Lua.Reader (readCustom) -import Text.Pandoc.Lua.Writer (writeCustom) +import Text.Pandoc.Lua.Custom (loadCustom) import Text.Pandoc.Lua.Orphans () import Text.Pandoc.Scripting (ScriptingEngine (..)) import qualified Text.Pandoc.UTF8 as UTF8 @@ -46,6 +44,5 @@ getEngine = do pure $ ScriptingEngine { engineName = maybe "Lua (unknown version)" UTF8.toText versionName , engineApplyFilter = applyFilter - , engineReadCustom = readCustom - , engineWriteCustom = writeCustom + , engineLoadCustom = loadCustom } |
