aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MANUAL.txt8
-rw-r--r--pandoc.hs27
2 files changed, 16 insertions, 19 deletions
diff --git a/MANUAL.txt b/MANUAL.txt
index 379c61ca5..0a6362e2e 100644
--- a/MANUAL.txt
+++ b/MANUAL.txt
@@ -426,7 +426,7 @@ Reader options
footnotes and links will not work across files. Reading binary
files (docx, odt, epub) implies `--file-scope`.
-`--filter=`*EXECUTABLE*
+`--filter=`*PROGRAM*
: Specify an executable to be used as a filter transforming the
pandoc AST after the input is parsed and before the output is
@@ -450,12 +450,6 @@ Reader options
pandoc filter libraries in [PHP], [perl], and
[javascript/node.js].
- If no directory is provided pandoc will look for executable or
- non-executable filters in the director `$DATADIR/filters`, and
- then for executable filters in the user's `PATH`. If you want to
- run a script in the working directory, preface the filename with
- `./`.
-
In order of preference, pandoc will look for filters in
1. a specified full or relative path (executable or
diff --git a/pandoc.hs b/pandoc.hs
index 80128586a..983089515 100644
--- a/pandoc.hs
+++ b/pandoc.hs
@@ -1111,19 +1111,22 @@ adjustMetadata metadata d = return $ M.foldWithKey setMeta d metadata
applyTransforms :: [Transform] -> Pandoc -> IO Pandoc
applyTransforms transforms d = return $ foldr ($) d transforms
- -- First we check to see if a filter is a path. If it isn't, we
- -- check to see whether it's in `userdir/filters`. If not, we leave
- -- it unchanged.
+ -- First we check to see if a filter is found. If not, and if it's
+ -- not an absolute path, we check to see whether it's in `userdir/filters`.
+ -- If not, we leave it unchanged.
expandFilterPath :: Maybe FilePath -> FilePath -> IO FilePath
-expandFilterPath mbDatadir fp
- | '/' `elem` fp = return fp
- | Just datadir <- mbDatadir = do
- let filterPath = (datadir </> "filters" </> fp)
- filterPathExists <- doesFileExist filterPath
- if filterPathExists
- then return filterPath
- else return fp
- | otherwise = return fp
+expandFilterPath mbDatadir fp = do
+ fpExists <- doesFileExist fp
+ if fpExists
+ then return fp
+ else case mbDatadir of
+ Just datadir | isRelative fp -> do
+ let filterPath = (datadir </> "filters" </> fp)
+ filterPathExists <- doesFileExist filterPath
+ if filterPathExists
+ then return filterPath
+ else return fp
+ _ -> return fp
applyFilters :: Maybe FilePath -> [FilePath] -> [String] -> Pandoc -> IO Pandoc
applyFilters mbDatadir filters args d = do