aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-09-30 23:00:14 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2017-09-30 23:00:14 -0700
commit9451d83058fa0b237514e618ebe6140a69fe13db (patch)
tree9fbd3eca8201a052191af814a2464f7637bb2861
parent17583cd99d0ea2cb4a5dcb3eecf2735395ebc3d6 (diff)
downloadpandoc-9451d83058fa0b237514e618ebe6140a69fe13db.tar.gz
Lua: make fetch return mime type first and then content.
-rw-r--r--doc/lua-filters.md9
-rw-r--r--src/Text/Pandoc/Lua/PandocModule.hs2
2 files changed, 10 insertions, 1 deletions
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
--