@@ -1111,19 +1111,22 @@ adjustMetadata metadata d = return $ M.foldWithKey setMeta d metadata
11111111applyTransforms :: [Transform] -> Pandoc -> IO Pandoc
11121112applyTransforms transforms d = return $ foldr ($) d transforms
11131113
1114− -- First we check to see if a filter is a path. If it isn't, we
1115− -- check to see whether it's in `userdir/filters`. If not, we leave
1116− -- it unchanged.
1114+ -- First we check to see if a filter is found. If not, and if it's
1115+ -- not an absolute path, we check to see whether it's in `userdir/filters`.
1116+ -- If not, we leave it unchanged.
11171117expandFilterPath :: Maybe FilePath -> FilePath -> IO FilePath
1118−expandFilterPath mbDatadir fp
1119− | '/' `elem` fp = return fp
1120− | Just datadir <- mbDatadir = do
1121− let filterPath = (datadir </> "filters" </> fp)
1122− filterPathExists <- doesFileExist filterPath
1123− if filterPathExists
1124− then return filterPath
1125− else return fp
1126− | otherwise = return fp
1118+expandFilterPath mbDatadir fp = do
1119+ fpExists <- doesFileExist fp
1120+ if fpExists
1121+ then return fp
1122+ else case mbDatadir of
1123+ Just datadir | isRelative fp -> do
1124+ let filterPath = (datadir </> "filters" </> fp)
1125+ filterPathExists <- doesFileExist filterPath
1126+ if filterPathExists
1127+ then return filterPath
1128+ else return fp
1129+ _ -> return fp
11271130
11281131applyFilters :: Maybe FilePath -> [FilePath] -> [String] -> Pandoc -> IO Pandoc
11291132applyFilters mbDatadir filters args d = do