git.iko.soy/typeable/pandoc
on master help sign in
Lua: make fetch return mime type first and then content.
9451d83John MacFarlane
doc/lua-filters.md+9
@@ -1135,6 +1135,10 @@ storage. The "media bag" is used when pandoc is called with the
1135: Returns a filename with a basename based on the SHA1 has of the
1135: Returns a filename with a basename based on the SHA1 has of the
1136 contents and an extension based on the mime type.
1136 contents and an extension based on the mime type.
1137
1137
1138+ Returns:
1139+
1140+ - Filename based on SHA1 hash.
1141+
1138 Usage:
1142 Usage:
1139
1143
1140 local fp = pandoc.mediabag.hashname("plain/text", "foobar")
1144 local fp = pandoc.mediabag.hashname("plain/text", "foobar")
@@ -1145,6 +1149,11 @@ storage. The "media bag" is used when pandoc is called with the
1145 Returns two values: the contents of the file and the mime
1149 Returns two values: the contents of the file and the mime
1146 type (or an empty string).
1150 type (or an empty string).
1147
1151
1152+ Returns:
1153+
1154+ - the entries MIME type, or nil if the file was not found.
1155+ - contents of the file, or nil if the file was not found.
1156+
1148 Usage:
1157 Usage:
1149
1158
1150 local diagram_url = "https://pandoc.org/diagram.jpg"
1159 local diagram_url = "https://pandoc.org/diagram.jpg"
src/Text/Pandoc/Lua/PandocModule.hs+1−1
@@ -163,8 +163,8 @@ fetch commonState mbRef src = do
163 putCommonState commonState
163 putCommonState commonState
164 setMediaBag mediaBag
164 setMediaBag mediaBag
165 fetchItem src
165 fetchItem src
166− Lua.push bs
167 Lua.push $ fromMaybe "" mimeType
166 Lua.push $ fromMaybe "" mimeType
167+ Lua.push bs
168 return 2 -- returns 2 values: contents, mimetype
168 return 2 -- returns 2 values: contents, mimetype
169
169
170--
170--