@@ -44,7 +44,7 @@ import Text.Pandoc.SelfContained ( makeSelfContained )
44import Text.Pandoc.Process (pipeProcess)
44import Text.Pandoc.Process (pipeProcess)
45import Text.Highlighting.Kate ( languages, Style, tango, pygments,
45import Text.Highlighting.Kate ( languages, Style, tango, pygments,
46 espresso, zenburn, kate, haddock, monochrome )
46 espresso, zenburn, kate, haddock, monochrome )
47−import System.Environment ( getArgs, getProgName, getEnvironment )
47+import System.Environment ( getArgs, getProgName )
48import System.Exit ( exitWith, ExitCode (..) )
48import System.Exit ( exitWith, ExitCode (..) )
49import System.FilePath
49import System.FilePath
50import System.Console.GetOpt
50import System.Console.GetOpt
@@ -113,12 +113,15 @@ isTextFormat s = takeWhile (`notElem` "+-") s `notElem` binaries
114externalFilter :: FilePath -> [String] -> Pandoc -> IO Pandoc
114externalFilter :: FilePath -> [String] -> Pandoc -> IO Pandoc
115externalFilter f args' d = do
115externalFilter f args' d = do
116− mbPath <- lookup "PATH" <$> getEnvironment
117− mbexe <- if '/' `elem` f || mbPath == Nothing
116+ mbexe <- if '/' `elem` f
118− -- don't check PATH if filter name has a path, or
117+ -- don't check PATH if filter name has a path
119− -- if the PATH is not set
120 then return Nothing
118 then return Nothing
119+ -- we catch isDoesNotExistError because this will
120+ -- be triggered if PATH not set:
121− else findExecutable f
121+ else E.catch (findExecutable f)
122+ (\e -> if isDoesNotExistError e
122 (f', args'') <- case mbexe of
125 (f', args'') <- case mbexe of
123 Just x -> return (x, args')
126 Just x -> return (x, args')
124 Nothing -> do
127 Nothing -> do