mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-24 09:16:43 +00:00
T.P.Filter: allow shorter YAML representation of Citeproc
The map-based YAML representation of filters expects `type` and `path` fields. The path field had to be present for all filter types, but is not used for citeproc filters. The field can now be omitted when type is "citeproc", as described in the MANUAL.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user