@@ -33,7 +33,8 @@ import Text.Pandoc
3333import Text.Pandoc.Shared ( tabFilter, ObfuscationMethod (..), readDataFile,
3434 headerShift, findDataFile, normalize )
3535import Text.Pandoc.SelfContained ( makeSelfContained )
36−import Text.Pandoc.Highlighting ( languages )
36+import Text.Pandoc.Highlighting ( languages, Style, tango, pygments,
37+ espresso, kate, haddock, monochrome )
3738import System.Environment ( getArgs, getProgName )
3839import System.Exit ( exitWith, ExitCode (..) )
3940import System.FilePath
@@ -45,7 +46,7 @@ import System.IO ( stdout, stderr )
4546import System.IO.Error ( isDoesNotExistError )
4647import Control.Exception.Extensible ( throwIO )
4748import qualified Text.Pandoc.UTF8 as UTF8
48−import Text.CSL
49+import qualified Text.CSL as CSL
4950import Text.Pandoc.Biblio
5051import Control.Monad (when, unless, liftM)
5152import Network.HTTP (simpleHTTP, mkRequest, getResponseBody, RequestMethod(..))
@@ -100,6 +101,8 @@ data Opt = Opt
100101 , optXeTeX :: Bool -- ^ Format latex for xetex
101102 , optSmart :: Bool -- ^ Use smart typography
102103 , optHtml5 :: Bool -- ^ Produce HTML5 in HTML
104+ , optHighlight :: Bool -- ^ Highlight source code
105+ , optHighlightStyle :: Style -- ^ Style to use for highlighted code
103106 , optChapters :: Bool -- ^ Use chapter for top-level sects
104107 , optHTMLMathMethod :: HTMLMathMethod -- ^ Method to print HTML math
105108 , optReferenceODT :: Maybe FilePath -- ^ Path of reference.odt
@@ -144,6 +147,8 @@ defaultOpts = Opt
144147 , optXeTeX = False
145148 , optSmart = False
146149 , optHtml5 = False
150+ , optHighlight = True
151+ , optHighlightStyle = pygments
147152 , optChapters = False
148153 , optHTMLMathMethod = PlainMath
149154 , optReferenceODT = Nothing
@@ -242,6 +247,28 @@ options =
242247 (\opt -> return opt { optHtml5 = True }))
243248 "" -- "Produce HTML5 in HTML output"
244249
250+ , Option "" ["no-highlight"]
251+ (NoArg
252+ (\opt -> return opt { optHighlight = False }))
253+ "" -- "Don't highlight source code"
254+
255+ , Option "" ["highlight-style"]
256+ (ReqArg
257+ (\arg opt -> do
258+ newStyle <- case map toLower arg of
259+ "pygments" -> return pygments
260+ "tango" -> return tango
261+ "espresso" -> return espresso
262+ "kate" -> return kate
263+ "monochrome" -> return monochrome
264+ "haddock" -> return haddock
265+ _ -> UTF8.hPutStrLn stderr
266+ ("Unknown style: " ++ arg) >>
267+ exitWith (ExitFailure 39)
268+ return opt{ optHighlightStyle = newStyle })
269+ "STYLE")
270+ "" -- "Style for highlighted code"
271+
245272 , Option "m" ["latexmathml", "asciimathml"]
246273 (OptArg
247274 (\arg opt ->
@@ -691,6 +718,8 @@ main = do
691718 , optSelfContained = selfContained
692719 , optSmart = smart
693720 , optHtml5 = html5
721+ , optHighlight = highlight
722+ , optHighlightStyle = highlightStyle
694723 , optChapters = chapters
695724 , optHTMLMathMethod = mathMethod
696725 , optReferenceODT = referenceODT
@@ -774,7 +803,7 @@ main = do
774803 return $ ("mathml-script", s) : variables
775804 _ -> return variables
776805
777− refs <- mapM (\f -> catch (readBiblioFile f) $ \e -> do
806+ refs <- mapM (\f -> catch (CSL.readBiblioFile f) $ \e -> do
778807 UTF8.hPutStrLn stderr $ "Error reading bibliography `" ++ f ++ "'"
779808 UTF8.hPutStrLn stderr $ show e
780809 exitWith (ExitFailure 23)) reffiles >>= \rs -> return $ concat rs
@@ -795,7 +824,7 @@ main = do
795824 stateLiterateHaskell = "+lhs" `isSuffixOf` readerName' ||
796825 lhsExtension sources,
797826 stateStandalone = standalone',
798− stateCitations = map refId refs,
827+ stateCitations = map CSL.refId refs,
799828 stateSmart = smart || writerName' `elem`
800829 ["latex", "context", "latex+lhs", "man"],
801830 stateColumns = columns,
@@ -835,7 +864,8 @@ main = do
835864 slideVariant == DZSlides,
836865 writerChapters = chapters,
837866 writerListings = listings,
838− writerHighlight = True }
867+ writerHighlight = highlight,
868+ writerHighlightStyle = highlightStyle }
839869
840870 when (isNonTextOutput writerName' && outputFile == "-") $
841871 do UTF8.hPutStrLn stderr ("Error: Cannot write " ++ writerName' ++ " output to stdout.\n" ++