aboutsummaryrefslogtreecommitdiff
path: root/doc/lua-filters.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/lua-filters.md')
-rw-r--r--doc/lua-filters.md30
1 files changed, 29 insertions, 1 deletions
diff --git a/doc/lua-filters.md b/doc/lua-filters.md
index 11643da84..9beeda185 100644
--- a/doc/lua-filters.md
+++ b/doc/lua-filters.md
@@ -3,7 +3,7 @@ title: Pandoc Lua Filters
author:
- Albert Krewinkel
- John MacFarlane
-date: 'November 20, 2017'
+date: 'December 6, 2017'
---
# Introduction
@@ -176,6 +176,34 @@ Some pandoc functions have been made available in lua:
which stores binary content such as images that may be
included in the final document.
+# Lua interpreter initialization
+
+The way the Lua interpreter is set-up can be controlled by
+placing a file `init.lua` in pandoc's data directory. The
+default init file loads the `pandoc` and `pandoc.mediabag`
+modules:
+
+``` lua
+pandoc = require 'pandoc'
+pandoc.mediabag = require 'pandoc.mediabag'
+```
+
+A common use-case would be to add code to load additional
+modules or to alter default modules. E.g., the following snippet
+adds all unicode-aware functions defined in the [`text`
+module](#module-text) to the default `string` module, prefixed
+with the string `uc_`.
+
+```lua
+for name, fn in pairs(require 'text') do
+ string['uc_' .. name] = fn
+end
+```
+
+This makes it possible to apply these functions on strings using
+colon syntax (`mystring:uc_upper()`).
+
+
# Examples
## Macro substitution.