diff options
author | Albert Krewinkel <albert+github@zeitkraut.de> | 2018-10-26 07:12:14 +0200 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-10-25 22:12:14 -0700 |
commit | 096cbe698746d621bfee9607b1ab826240082a10 (patch) | |
tree | 15421f7681998d0de0de828341ac9cb17fcaef99 /test | |
parent | 8f9ab3db256f6acace90864a9ed569675ede9def (diff) | |
download | pandoc-096cbe698746d621bfee9607b1ab826240082a10.tar.gz |
Lua: allow access to pandoc state (#5015)
* Lua: allow access to pandoc state
Lua filters and custom writers now have read-only access to most fields
of pandoc's internal state via the global variable `PANDOC_STATE`.
* Lua: allow iterating through fields of PANDOC_STATE
* Lua filters doc: describe CommonState
* Lua filters doc: mention global variable PANDOC_STATE
* Lua: add access to logs
Log messages can currently only be printed, but not decomposed.
Diffstat (limited to 'test')
-rw-r--r-- | test/command/lua-pandoc-state.lua | 11 | ||||
-rw-r--r-- | test/command/lua-pandoc-state.md | 14 |
2 files changed, 25 insertions, 0 deletions
diff --git a/test/command/lua-pandoc-state.lua b/test/command/lua-pandoc-state.lua new file mode 100644 index 000000000..5282a4c29 --- /dev/null +++ b/test/command/lua-pandoc-state.lua @@ -0,0 +1,11 @@ +function report (what, value) + print(string.format('%16s: %s', what, value)) +end +report('# input files', #PANDOC_STATE.input_files) +report('output file', PANDOC_STATE.output_file) +report('# request header', #PANDOC_STATE.request_headers) +report('resource path', table.concat(PANDOC_STATE.resource_path, ', ')) +report('source URL', PANDOC_STATE.source_url) +report('user data dir', PANDOC_STATE.user_data_dir and 'defined' or 'unset') +report('trace', PANDOC_STATE.trace) +report('verbosity', PANDOC_STATE.verbosity) diff --git a/test/command/lua-pandoc-state.md b/test/command/lua-pandoc-state.md new file mode 100644 index 000000000..33045f64a --- /dev/null +++ b/test/command/lua-pandoc-state.md @@ -0,0 +1,14 @@ +``` +% pandoc --lua-filter=command/lua-pandoc-state.lua +Hello +^D + # input files: 0 + output file: nil +# request header: 0 + resource path: . + source URL: nil + user data dir: defined + trace: false + verbosity: WARNING +<p>Hello</p> +``` |