aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2017-04-16 21:06:50 +0200
committerAlbert Krewinkel <albert+github@zeitkraut.de>2017-04-26 23:28:40 +0200
commit9cd20c9b8b1fa3bd4581399327d61551558cf899 (patch)
treefc9c8769f453139f6d4286d84f1bb9fa7906d5b4 /src/Text/Pandoc
parent5416fb14aba9804ce4a227a4ebd8228d82aa658e (diff)
downloadpandoc-9cd20c9b8b1fa3bd4581399327d61551558cf899.tar.gz
Lua filter: allow filtering of meta data only
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Lua.hs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Lua.hs b/src/Text/Pandoc/Lua.hs
index 0d1c6cf45..ffc57c9c2 100644
--- a/src/Text/Pandoc/Lua.hs
+++ b/src/Text/Pandoc/Lua.hs
@@ -75,7 +75,8 @@ runAll (x:xs) = walkMWithLuaFilter x >=> runAll xs
walkMWithLuaFilter :: LuaFilter -> Pandoc -> IO Pandoc
walkMWithLuaFilter (LuaFilter lua fnMap) =
walkM (execInlineLuaFilter lua fnMap) >=>
- walkM (execBlockLuaFilter lua fnMap) >=>
+ walkM (execBlockLuaFilter lua fnMap) >=>
+ walkM (execMetaLuaFilter lua fnMap) >=>
walkM (execDocLuaFilter lua fnMap)
type FunctionMap = Map String LuaFilterFunction
@@ -92,6 +93,17 @@ execDocLuaFilter lua fnMap x = do
Nothing -> return x
Just fn -> runLuaFilterFunction lua fn x
+execMetaLuaFilter :: LuaState
+ -> FunctionMap
+ -> Pandoc -> IO Pandoc
+execMetaLuaFilter lua fnMap pd@(Pandoc meta blks) = do
+ let metaFnName = "Meta"
+ case Map.lookup metaFnName fnMap of
+ Nothing -> return pd
+ Just fn -> do
+ meta' <- runLuaFilterFunction lua fn meta
+ return $ Pandoc meta' blks
+
execBlockLuaFilter :: LuaState
-> FunctionMap
-> Block -> IO Block