aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2016-12-08 11:09:40 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2016-12-08 11:09:40 +0100
commit1fde7a340b25ce16c5197ec690885ad15d91daa8 (patch)
treef24f0d6593d604a41311af0935b870d68b2c26cd
parent6708c6a7fcdb531fbb1848c3e4dd3e9a1a1609d1 (diff)
downloadpandoc-1fde7a340b25ce16c5197ec690885ad15d91daa8.tar.gz
Set PANDOC_VERSION environment variable for filters.
Closes #2640.
-rw-r--r--pandoc.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/pandoc.hs b/pandoc.hs
index 89681258f..a0899adb6 100644
--- a/pandoc.hs
+++ b/pandoc.hs
@@ -44,7 +44,7 @@ import Text.Pandoc.SelfContained ( makeSelfContained )
import Text.Pandoc.Process (pipeProcess)
import Text.Highlighting.Kate ( languages, Style, tango, pygments,
espresso, zenburn, kate, haddock, monochrome )
-import System.Environment ( getArgs, getProgName )
+import System.Environment ( getArgs, getProgName, getEnvironment )
import System.Exit ( ExitCode (..), exitSuccess )
import System.FilePath
import System.Console.GetOpt
@@ -135,8 +135,10 @@ externalFilter f args' d = do
when (isNothing mbExe) $
err 83 $ "Error running filter " ++ f ++ ":\n" ++
"Could not find executable '" ++ f' ++ "'."
+ env <- getEnvironment
+ let env' = Just $ ("PANDOC_VERSION", pandocVersion) : env
(exitcode, outbs, errbs) <- E.handle filterException $
- pipeProcess Nothing f' args'' $ encode d
+ pipeProcess env' f' args'' $ encode d
unless (B.null errbs) $ B.hPutStr stderr errbs
case exitcode of
ExitSuccess -> return $ either error id $ eitherDecode' outbs