path: root/doc
diff options
authorJohn MacFarlane <>2017-09-30 22:54:12 -0700
committerJohn MacFarlane <>2017-09-30 22:54:12 -0700
commit17583cd99d0ea2cb4a5dcb3eecf2735395ebc3d6 (patch)
tree123a0a72e96554e7def0b973b23588889ca44610 /doc
parent73c47a44d86f5075e3635e90574de12ac5f0b2eb (diff)
Lua: simply mediabag module.
Now 'fetch' simply fetches content and mime type. A new 'hashname' function is provided to get a filename based on the sha1 hash of the contents and the mime type.
Diffstat (limited to 'doc')
1 files changed, 12 insertions, 4 deletions
diff --git a/doc/ b/doc/
index e1007f452..3a6695f9f 100644
--- a/doc/
+++ b/doc/
@@ -1130,14 +1130,22 @@ storage. The "media bag" is used when pandoc is called with the
local filename = "media/diagram.png"
local mt, contents = pandoc.mediabag.lookup(filename)
+[`hashname (mime_type, contents)`]{#mediabag-hashname}
+: Returns a filename with a basename based on the SHA1 has of the
+ contents and an extension based on the mime type.
+ Usage:
+ local fp = pandoc.mediabag.hashname("plain/text", "foobar")
[`fetch (source, base_url)`]{#mediabag-fetch}
-: Fetches the given source and inserts it into the media bag
- using a SHA1 hash of the content as filename. Returns two
- values: the filename (based on SHA1 hash) and the mime
+: Fetches the given source from a URL or local file.
+ Returns two values: the contents of the file and the mime
type (or an empty string).
local diagram_url = ""
- pandoc.mediabag.fetch(diagram_url, ".")
+ local contents = pandoc.mediabag.fetch(diagram_url, ".")