diff options
author | Albert Krewinkel <albert@zeitkraut.de> | 2019-05-04 07:06:30 +0200 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-05-04 01:06:30 -0400 |
commit | 786594b23be4a757e95776f782527c8a98fbaab5 (patch) | |
tree | 6cf961b47a7d9df096be0347497a56c26b160aa8 /doc | |
parent | 4f260c96d9b84fb90d4e9b7c611556b1708b90fe (diff) | |
download | pandoc-786594b23be4a757e95776f782527c8a98fbaab5.tar.gz |
Lua: add `pandoc.system` module (#5468)
The `system` Lua module provides utility functions to interact with the
operating- and file system. E.g.
print(pandoc.system.get_current_directory())
or
pandoc.system.with_temporary_directory('tikz', function (dir)
-- write and compile a TikZ file with pdflatex
end)
Diffstat (limited to 'doc')
-rw-r--r-- | doc/lua-filters.md | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/doc/lua-filters.md b/doc/lua-filters.md index 433233ea1..3b3bb2f17 100644 --- a/doc/lua-filters.md +++ b/doc/lua-filters.md @@ -2618,3 +2618,111 @@ Parameters: Returns: a new list containing all items for which \`test\` was true. + +# Module pandoc.system + +Access to system information and functionality. + +## Static Fields {#system-fields} + +### arch {#system-arch} + +The machine architecture on which the program is running. + +### os {#system-os} + +The operating system on which the program is running. + +## Functions {#system-functions} + +### environment {#system-environment} + +`environment ()` + +Retrieve the entire environment as a string-indexed table. + +Returns: + +- A table mapping environment variables names to their string value + (table). + +### get\_working\_directory {#system-get_working_directory} + +`get_working_directory ()` + +Obtain the current working directory as an absolute path. + +Returns: + +- The current working directory (string). + +### with\_environment {#system-with_environment} + +`with_environment (environment, callback)` + +Run an action within a custom environment. Only the environment +variables given by `environment` will be set, when `callback` is +called. The original environment is restored after this function +finishes, even if an error occurs while running the callback +action. + +Parameters: + +`environment` +: Environment variables and their values to be set before + running `callback`. (table with string keys and string + values) + +`callback` +: Action to execute in the custom environment (function) + +Returns: + +- The result(s) of the call to `callback` + +### with\_temporary\_directory {#system-with_temporary_directory} + +`with_temporary_directory ([parent_dir,] templ, callback)` + +Create and use a temporary directory inside the given directory. +The directory is deleted after the callback returns. + +Parameters: + +`parent_dir` +: Parent directory to create the directory in (string). If this + parameter is omitted, the system's canonical temporary + directory is used. + +`templ` +: Directory name template (string). + +`callback` +: Function which takes the name of the temporary directory as its + first argument (function). + +Returns: + +- The result of the call to `callback`. + +### with\_working\_directory {#system-with_working_directory} + +`with_working_directory (directory, callback)` + +Run an action within a different directory. This function will +change the working directory to `directory`, execute `callback`, +then switch back to the original working directory, even if an +error occurs while running the callback action. + +Parameters: + +`directory` +: Directory in which the given `callback` should be executed + (string) + +`callback` +: Action to execute in the given directory (function) + +Returns: + +- The result(s) of the call to `callback` |