From 9451d83058fa0b237514e618ebe6140a69fe13db Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 30 Sep 2017 23:00:14 -0700 Subject: Lua: make fetch return mime type first and then content. --- doc/lua-filters.md | 9 +++++++++ src/Text/Pandoc/Lua/PandocModule.hs | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/lua-filters.md b/doc/lua-filters.md index 3a6695f9f..c6e1814b4 100644 --- a/doc/lua-filters.md +++ b/doc/lua-filters.md @@ -1135,6 +1135,10 @@ storage. The "media bag" is used when pandoc is called with the : Returns a filename with a basename based on the SHA1 has of the contents and an extension based on the mime type. + Returns: + + - Filename based on SHA1 hash. + Usage: local fp = pandoc.mediabag.hashname("plain/text", "foobar") @@ -1145,6 +1149,11 @@ storage. The "media bag" is used when pandoc is called with the Returns two values: the contents of the file and the mime type (or an empty string). + Returns: + + - the entries MIME type, or nil if the file was not found. + - contents of the file, or nil if the file was not found. + Usage: local diagram_url = "https://pandoc.org/diagram.jpg" diff --git a/src/Text/Pandoc/Lua/PandocModule.hs b/src/Text/Pandoc/Lua/PandocModule.hs index f27d6f45e..a54e54c09 100644 --- a/src/Text/Pandoc/Lua/PandocModule.hs +++ b/src/Text/Pandoc/Lua/PandocModule.hs @@ -163,8 +163,8 @@ fetch commonState mbRef src = do putCommonState commonState setMediaBag mediaBag fetchItem src - Lua.push bs Lua.push $ fromMaybe "" mimeType + Lua.push bs return 2 -- returns 2 values: contents, mimetype -- -- cgit v1.2.3