hpygments 0.1.2 → 0.1.3
raw patch · 2 files changed
+9/−3 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- hpygments.cabal +1/−1
- src/Text/Highlighting/Pygments.hs +8/−2
hpygments.cabal view
@@ -1,5 +1,5 @@ Name: hpygments-Version: 0.1.2+Version: 0.1.3 Synopsis: Highlight source code using Pygments Description: Highlight source code using Pygments <http://pygments.org>. This package
src/Text/Highlighting/Pygments.hs view
@@ -30,7 +30,8 @@ -- $examples ) where -import System.Process (readProcess)+import System.Exit+import System.Process (readProcessWithExitCode) import Text.Highlighting.Pygments.Lexers import Text.Highlighting.Pygments.Formatters@@ -51,7 +52,12 @@ pygmentize :: LexerAlias -> FormatterAlias -> Options -> String -> IO String pygmentize lexer formatter options code = do let args = ["-l", lexer, "-f", formatter] ++ optionsToArgs options- readProcess "pygmentize" args code+ (exitCode, stdout, stderr) <- readProcessWithExitCode "pygmentize" args code+ case exitCode of+ ExitSuccess -> return stdout+ -- TODO throw a custom exception?+ e -> error $ "hpygments: `pygmentize " ++ unwords args ++ "` failed: " + ++ show e ++ if stderr /= "" then ": " ++ stderr else "" -- | The lexer/formatter option @(key, value)@ is passed to the @pygmentize@ -- script via the command-line flag @-P key=value@.