diff options
| author | Albert Krewinkel <[email protected]> | 2022-10-07 21:37:57 +0200 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2022-10-10 09:39:18 -0700 |
| commit | a088cbf5637596a461ba9f99b49210235d6c0a68 (patch) | |
| tree | d4703d158cf07e4dd45b96fff16166d5ea9abf31 /src | |
| parent | e1e07cce65a0bb007da934245e74be1b1c8a0f6e (diff) | |
Lua: support extensions in custom writers
Custom writers can define the extensions that they support via the
global `writer_extensions`. The variable's value must be a table with
all supported extensions as keys, and their default status as values.
E.g., the below specifies that the writer support the extensions `smart`
and `sourcepos`, but only the `smart` extension is enabled by default:
writer_extensions = {
smart = true,
sourcepos = false,
}
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/App/OutputSettings.hs | 4 | ||||
| -rw-r--r-- | src/Text/Pandoc/Scripting.hs | 5 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/Text/Pandoc/App/OutputSettings.hs b/src/Text/Pandoc/App/OutputSettings.hs index 20321f52a..ab224cd7f 100644 --- a/src/Text/Pandoc/App/OutputSettings.hs +++ b/src/Text/Pandoc/App/OutputSettings.hs @@ -107,7 +107,9 @@ optToOutputSettings scriptingEngine opts = do (writer, writerExts) <- if "lua" `T.isSuffixOf` format then do - (, mempty) <$> engineWriteCustom scriptingEngine (T.unpack format) + (w, extsConf) <- engineWriteCustom scriptingEngine (T.unpack format) + wexts <- Format.applyExtensionsDiff extsConf flvrd + return (w, wexts) else do if optSandbox opts then case runPure (getWriter flvrd) of diff --git a/src/Text/Pandoc/Scripting.hs b/src/Text/Pandoc/Scripting.hs index 09b19f12e..0defa2f77 100644 --- a/src/Text/Pandoc/Scripting.hs +++ b/src/Text/Pandoc/Scripting.hs @@ -18,10 +18,11 @@ where import Control.Monad.Except (throwError) import Control.Monad.IO.Class (MonadIO) import Data.Text (Text) -import Text.Pandoc.Definition (Pandoc) import Text.Pandoc.Class.PandocMonad (PandocMonad) +import Text.Pandoc.Definition (Pandoc) import Text.Pandoc.Error (PandocError (PandocNoScriptingEngine)) import Text.Pandoc.Filter.Environment (Environment) +import Text.Pandoc.Format (ExtensionsConfig) import Text.Pandoc.Readers (Reader) import Text.Pandoc.Writers (Writer) @@ -39,7 +40,7 @@ data ScriptingEngine = ScriptingEngine -- ^ Function to parse input into a 'Pandoc' document. , engineWriteCustom :: forall m. (PandocMonad m, MonadIO m) - => FilePath -> m (Writer m) + => FilePath -> m (Writer m, ExtensionsConfig) -- ^ Invoke the given script file to convert to any custom format. } |
