git.iko.soy/typeable/pandoc
on master help sign in
Lua: move sha1 from pandoc.mediabag to pandoc.
4c3b3bfJohn MacFarlane
doc/lua-filters.md+13−12
@@ -1063,6 +1063,19 @@ Lua functions for pandoc scripts.
1063 -- the above is equivallent to
1063 -- the above is equivallent to
1064 -- return {{Str = Str}}
1064 -- return {{Str = Str}}
1065
1065
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+
1066# Submodule mediabag
1079# Submodule mediabag
1067
1080
1068The submodule `mediabag` allows accessing pandoc's media
1081The submodule `mediabag` allows accessing pandoc's media
@@ -1130,18 +1143,6 @@ storage. The "media bag" is used when pandoc is called with the
1130 local filename = "media/diagram.png"
1143 local filename = "media/diagram.png"
1131 local mt, contents = pandoc.mediabag.lookup(filename)
1144 local mt, contents = pandoc.mediabag.lookup(filename)
1132
1145
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−
1145[`fetch (source, base_url)`]{#mediabag-fetch}
1146[`fetch (source, base_url)`]{#mediabag-fetch}
1146
1147
1147: Fetches the given source from a URL or local file.
1148: 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
63 Lua.push "__read"
63 Lua.push "__read"
64 Lua.pushHaskellFunction readDoc
64 Lua.pushHaskellFunction readDoc
65 Lua.rawset (-3)
65 Lua.rawset (-3)
66+ Lua.push "sha1"
67+ Lua.pushHaskellFunction sha1HashFn
68+ Lua.rawset (-3)
66
69
67-- | Get the string representation of the pandoc module
70-- | Get the string representation of the pandoc module
68pandocModuleScript :: Maybe FilePath -> IO String
71pandocModuleScript :: Maybe FilePath -> IO String
@@ -93,7 +96,6 @@ pushMediaBagModule commonState mediaBagRef = do
93 addFunction "lookup" (lookupMediaFn mediaBagRef)
96 addFunction "lookup" (lookupMediaFn mediaBagRef)
94 addFunction "list" (mediaDirectoryFn mediaBagRef)
97 addFunction "list" (mediaDirectoryFn mediaBagRef)
95 addFunction "fetch" (fetch commonState mediaBagRef)
98 addFunction "fetch" (fetch commonState mediaBagRef)
96− addFunction "sha1" sha1HashFn
97 return ()
99 return ()
98 where
100 where
99 addFunction name fn = do
101 addFunction name fn = do