aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlbert Krewinkel <[email protected]>2022-10-12 11:48:21 +0200
committerAlbert Krewinkel <[email protected]>2022-10-12 11:58:18 +0200
commit253d2e768a43c8ab3ad8e1c46b2bc4a02acec946 (patch)
tree591d2f32798cdcd5d6b841b162bbd6aa654ce4bb /src
parent543cb5d45d3ebc4c5a504be42efd6febb3a9ceaa (diff)
Lua: support extensions in custom readers.
Like custom readers, like writers, can define the set of supported extensions by setting a global. E.g.: ``` lua reader_extensions = { smart = true, citations = false, } ```
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/App.hs6
-rw-r--r--src/Text/Pandoc/Scripting.hs2
2 files changed, 6 insertions, 2 deletions
diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs
index b4a9454e5..1290fc1c5 100644
--- a/src/Text/Pandoc/App.hs
+++ b/src/Text/Pandoc/App.hs
@@ -165,7 +165,11 @@ convertWithOpts' scriptingEngine istty datadir opts = do
(reader, readerExts) <-
if ".lua" `T.isSuffixOf` readerName
- then (,mempty) <$> engineReadCustom scriptingEngine (T.unpack readerName)
+ then do
+ let scriptPath = T.unpack readerNameBase
+ (r, extsConf) <- engineReadCustom scriptingEngine scriptPath
+ rexts <- Format.applyExtensionsDiff extsConf flvrd
+ return (r, rexts)
else if optSandbox opts
then case runPure (getReader flvrd) of
Left e -> throwError e
diff --git a/src/Text/Pandoc/Scripting.hs b/src/Text/Pandoc/Scripting.hs
index 0defa2f77..d4be7e377 100644
--- a/src/Text/Pandoc/Scripting.hs
+++ b/src/Text/Pandoc/Scripting.hs
@@ -36,7 +36,7 @@ data ScriptingEngine = ScriptingEngine
-- ^ Use the scripting engine to run a filter.
, engineReadCustom :: forall m. (PandocMonad m, MonadIO m)
- => FilePath -> m (Reader m)
+ => FilePath -> m (Reader m, ExtensionsConfig)
-- ^ Function to parse input into a 'Pandoc' document.
, engineWriteCustom :: forall m. (PandocMonad m, MonadIO m)