git.iko.soy/typeable/pandoc
on master help sign in
Lua module: add example for usage of `read`
01e8df2Albert Krewinkel
data/pandoc.lua+11−1
@@ -797,9 +797,19 @@ M.UpperAlpha = "UpperAlpha"
797-- @section helpers
797-- @section helpers
798
798
799--- Parse the given string into a Pandoc document.
799--- Parse the given string into a Pandoc document.
800+-- The method used to interpret input is specified by *format*. Acceptable
801+-- values for this parameter are equal to those that can be given to the
802+-- `--from` command line option.
800−-- @tparam string markup the markup to be parsed
803+-- @tparam string markup the markup to be parsed
801-- @tparam[opt] string format format specification, defaults to "markdown".
804-- @tparam[opt] string format format specification, defaults to "markdown".
802-- @return Doc pandoc document
805-- @return Doc pandoc document
806+-- @usage
807+-- local org_markup = "/emphasis/" -- Input to be read
808+-- local document = pandoc.read(org_markup, "org")
809+-- -- Get the first block of the document
810+-- local block = document.blocks[1]
811+-- -- The inline element in that block is an `Emph`
812+-- assert(block.content[1].t == "Emph")
803function M.read(markup, format)
813function M.read(markup, format)
804 format = format or "markdown"
814 format = format or "markdown"
805 local pd = pandoc.__read(format, markup)
815 local pd = pandoc.__read(format, markup)