diff options
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Filter.hs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Filter.hs b/src/Text/Pandoc/Filter.hs index f5c1a4f76..6d4846f98 100644 --- a/src/Text/Pandoc/Filter.hs +++ b/src/Text/Pandoc/Filter.hs @@ -47,11 +47,13 @@ instance FromYAML Filter where parseYAML node = (withMap "Filter" $ \m -> do ty <- m .: "type" - fp <- m .: "path" + fp <- m .:? "path" + let missingPath = fail $ "Expected 'path' for filter of type " ++ show ty + let filterWithPath constr = maybe missingPath (return . constr . T.unpack) case ty of "citeproc" -> return CiteprocFilter - "lua" -> return $ LuaFilter $ T.unpack fp - "json" -> return $ JSONFilter $ T.unpack fp + "lua" -> filterWithPath LuaFilter fp + "json" -> filterWithPath JSONFilter fp _ -> fail $ "Unknown filter type " ++ show (ty :: T.Text)) node <|> (withStr "Filter" $ \t -> do |