path: root/data
diff options
authorAlbert Krewinkel <>2017-04-17 11:54:42 +0200
committerAlbert Krewinkel <>2017-04-26 23:28:40 +0200
commit24ef67213213b621a6c0f340e7bfdf68d2d40ac1 (patch)
tree982f02fac63ed5ba2b3a7500bdd54fbd848d2ada /data
parentc2567b2bd03f6dadd971cf8bc81cd93a0dde623e (diff)
Lua module: provide simple `read` format parser
A single `read` function parsing pandoc-supported formats is added to the module. This is simpler and more convenient than the previous method of exposing all reader functions individually.
Diffstat (limited to 'data')
1 files changed, 14 insertions, 0 deletions
diff --git a/data/pandoc.lua b/data/pandoc.lua
index dfa67cdcc..46155a575 100644
--- a/data/pandoc.lua
+++ b/data/pandoc.lua
@@ -796,6 +796,20 @@ M.UpperAlpha = "UpperAlpha"
-- Helper Functions
-- @section helpers
+--- Parse the given string into a Pandoc document.
+-- @tparam string markup the markup to be parsed
+-- @tparam[opt] string format format specification, defaults to "markdown".
+-- @return Doc pandoc document
+function, format)
+ format = format or "markdown"
+ local pd = pandoc.__read(format, markup)
+ if type(pd) == "string" then
+ error(pd)
+ else
+ return pd
+ end
--- Use functions defined in the global namespace to create a pandoc filter.
-- All globally defined functions which have names of pandoc elements are
-- collected into a new table.