aboutsummaryrefslogtreecommitdiff
path: root/pandoc-lua-engine/src/Text/Pandoc/Lua/Module
diff options
context:
space:
mode:
authorAlbert Krewinkel <[email protected]>2025-07-23 18:57:21 +0200
committerAlbert Krewinkel <[email protected]>2025-07-23 19:31:03 +0200
commit01a305af58b2b91179266e3463e07db94fcc11f0 (patch)
tree5dbf33ad51cf1864709152bdc526e3d129a718b1 /pandoc-lua-engine/src/Text/Pandoc/Lua/Module
parentb6837264478b264d9883097856fb68047e2ccb8f (diff)
Lua: add function `pandoc.path.exists`.
The functions allows to check the existence of file-system objects.
Diffstat (limited to 'pandoc-lua-engine/src/Text/Pandoc/Lua/Module')
-rw-r--r--pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Path.hs50
1 files changed, 50 insertions, 0 deletions
diff --git a/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Path.hs b/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Path.hs
new file mode 100644
index 000000000..1d2169976
--- /dev/null
+++ b/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Path.hs
@@ -0,0 +1,50 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE TypeApplications #-}
+{- |
+ Module : Text.Pandoc.Lua.Module.Path
+ Copyright : © 2019-2024 Albert Krewinkel
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Albert Krewinkel <[email protected]>
+ Stability : alpha
+
+Pandoc's system Lua module.
+-}
+module Text.Pandoc.Lua.Module.Path
+ ( documentedModule
+ ) where
+
+import Data.Version (makeVersion)
+import HsLua
+import qualified HsLua.Module.Path as MPath
+import qualified HsLua.Module.System as MSystem
+
+-- | Push the pandoc.system module on the Lua stack.
+documentedModule :: forall e. LuaError e => Module e
+documentedModule = Module
+ { moduleName = "pandoc.path"
+ , moduleDescription = moduleDescription @e MPath.documentedModule
+ , moduleFields =
+ [ MPath.separator
+ , MPath.search_path_separator
+ ]
+ , moduleFunctions =
+ [ MPath.directory `since` v[2,12]
+ , MSystem.exists `since` v[3,7,1]
+ , MPath.filename `since` v[2,12]
+ , MPath.is_absolute `since` v[2,12]
+ , MPath.is_relative `since` v[2,12]
+ , MPath.join `since` v[2,12]
+ , MPath.make_relative `since` v[2,12]
+ , MPath.normalize `since` v[2,12]
+ , MPath.split `since` v[2,12]
+ , MPath.split_extension `since` v[2,12]
+ , MPath.split_search_path `since` v[2,12]
+ , MPath.treat_strings_as_paths `since` v[2,12]
+ ]
+ , moduleOperations = []
+ , moduleTypeInitializers = []
+ }
+ where
+ v = makeVersion