git.iko.soy/typeable/pandoc
on master help sign in
Lua: move sha1 from pandoc.mediabag to pandoc.
commit4c3b3bf65a769eaec4b8382d8ada4f28a3b91e04 authorJohn MacFarlane <jgm@berkeley.edu> dateSun 1 Oct 2017, 00:33 (9 years ago) parent8768f7e
2 files changed+16−13
doc/lua-filters.md+13−12 src/Text/Pandoc/Lua/PandocModule.hs+3−1
doc/lua-filters.md+13−12
@@ -1063,6 +1063,19 @@ Lua functions for pandoc scripts.
10631063 -- the above is equivallent to
10641064 -- return {{Str = Str}}
10651065
1066+[`sha1 (contents)`]{#mediabag-sha1}
1067+
1068+: Returns the SHA1 has of the contents.
1069+
1070+ Returns:
1071+
1072+ - SHA1 hash of the contents.
1073+
1074+ Usage:
1075+
1076+ local fp = pandoc.mediabag.sha1("foobar")
1077+
1078+
10661079# Submodule mediabag
10671080
10681081The submodule `mediabag` allows accessing pandoc's media
@@ -1130,18 +1143,6 @@ storage. The "media bag" is used when pandoc is called with the
11301143 local filename = "media/diagram.png"
11311144 local mt, contents = pandoc.mediabag.lookup(filename)
11321145
1133−[`sha1 (contents)`]{#mediabag-sha1}
1134−
1135−: Returns the SHA1 has of the contents.
1136−
1137− Returns:
1138−
1139− - SHA1 hash of the contents.
1140−
1141− Usage:
1142−
1143− local fp = pandoc.mediabag.sha1("foobar")
1144−
11451146[`fetch (source, base_url)`]{#mediabag-fetch}
11461147
11471148: Fetches the given source from a URL or local file.
src/Text/Pandoc/Lua/PandocModule.hs+3−1
@@ -63,6 +63,9 @@ pushPandocModule datadir = do
6363 Lua.push "__read"
6464 Lua.pushHaskellFunction readDoc
6565 Lua.rawset (-3)
66+ Lua.push "sha1"
67+ Lua.pushHaskellFunction sha1HashFn
68+ Lua.rawset (-3)
6669
6770-- | Get the string representation of the pandoc module
6871pandocModuleScript :: Maybe FilePath -> IO String
@@ -93,7 +96,6 @@ pushMediaBagModule commonState mediaBagRef = do
9396 addFunction "lookup" (lookupMediaFn mediaBagRef)
9497 addFunction "list" (mediaDirectoryFn mediaBagRef)
9598 addFunction "fetch" (fetch commonState mediaBagRef)
96− addFunction "sha1" sha1HashFn
9799 return ()
98100 where
99101 addFunction name fn = do