From d47c0f89bff967170e4e85e855392c069946d6e9 Mon Sep 17 00:00:00 2001 From: Steve Donovan Date: Mon, 27 Jun 2016 16:44:18 +0200 Subject: [PATCH] Debian lua-discount package is _yet another Lua binding_ to libmarkdown2 --- ldoc/markup.lua | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/ldoc/markup.lua b/ldoc/markup.lua index 1b25ef2..e34286d 100644 --- a/ldoc/markup.lua +++ b/ldoc/markup.lua @@ -239,13 +239,23 @@ local formatters = if ok then if 'function' == type(markdown) then -- lua-discount by A.S. Bradbury, https://luarocks.org/modules/luarocks/lua-discount - elseif 'table' == type(markdown) and 'function' == type(markdown.compile) then + elseif 'table' == type(markdown) and ('function' == type(markdown.compile) or 'function' == type(markdown.to_html)) then -- discount by Craig Barnes, https://luarocks.org/modules/craigb/discount - markdown = markdown.compile + -- result of apt-get install lua-discount (links against libmarkdown2) + local mysterious_debian_variant = markdown.to_html ~= nil + markdown = markdown.compile or markdown.to_html return function(text) local result, errmsg = markdown(text) - assert(nil ~= result and result.body, errmsg) - return result.body + if result then + if mysterious_debian_variant then + return result + else + return result.body + end + else + io.stderr:write('LDoc discount failed with error ',errmsg) + io.exit(1) + end end else ok = false