pandoc/test/command/lua-pandoc-state.lua
Albert Krewinkel 096cbe6987 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.
2018-10-25 22:12:14 -07:00

11 lines
514 B
Lua

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)