From 3a0fc17880b286d5116e335ade986de91089b3da Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Wed, 18 Jan 2023 12:19:49 +0100 Subject: Lua: add function pandoc.format.extensions. This simplifies the creation of custom readers and writers that are based on built-in formats. --- pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Format.hs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'pandoc-lua-engine/src/Text/Pandoc/Lua/Module') diff --git a/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Format.hs b/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Format.hs index 8707acbf9..63753532a 100644 --- a/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Format.hs +++ b/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Format.hs @@ -14,7 +14,8 @@ module Text.Pandoc.Lua.Module.Format import HsLua import Text.Pandoc.Error (PandocError) import Text.Pandoc.Extensions (getAllExtensions, getDefaultExtensions) -import Text.Pandoc.Lua.Marshal.Format (pushExtensions) +import Text.Pandoc.Format (getExtensionsConfig) +import Text.Pandoc.Lua.Marshal.Format (pushExtensions, pushExtensionsConfig) import Text.Pandoc.Lua.PandocLua () import qualified Data.Text as T @@ -56,4 +57,19 @@ functions = , "can have an effect when reading a format but not when" , "writing it, or *vice versa*." ] + + , defun "extensions" + ### liftPure getExtensionsConfig + <#> textParam "format" "format identifier" + =#> functionResult pushExtensionsConfig "table" "extensions config" + #? T.unlines + [ "Returns the extension configuration for the given format." + , "The configuration is represented as a table with all supported" + , "extensions as keys and their default status as value, with" + , "`true` indicating that the extension is enabled by default," + , "while `false` marks a supported extension that's disabled." + , "" + , "This function can be used to assign a value to the `Extensions`" + , "global in custom readers and writers." + ] ] -- cgit v1.2.3