aboutsummaryrefslogtreecommitdiff
path: root/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Format.hs
diff options
context:
space:
mode:
authorAlbert Krewinkel <[email protected]>2023-01-18 12:19:49 +0100
committerJohn MacFarlane <[email protected]>2023-01-18 08:59:53 -0800
commit3a0fc17880b286d5116e335ade986de91089b3da (patch)
tree5f65bff411fb55e17119c50d0911d6d454d8d0a1 /pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Format.hs
parent671cfcd86916518ead37c868c039638e53c1239a (diff)
Lua: add function pandoc.format.extensions.
This simplifies the creation of custom readers and writers that are based on built-in formats.
Diffstat (limited to 'pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Format.hs')
-rw-r--r--pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Format.hs18
1 files changed, 17 insertions, 1 deletions
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."
+ ]
]