@@ -41,7 +41,8 @@ import Data.Char ( toLower, isPunctuation )
41import Control.Monad.State
41import Control.Monad.State
42import Text.Pandoc.Pretty
42import Text.Pandoc.Pretty
43import System.FilePath (dropExtension)
43import System.FilePath (dropExtension)
44−import Text.Pandoc.Highlighting (highlightLaTeX, defaultLaTeXMacros)
44+import Text.Pandoc.Highlighting (highlight, pygments, styleToLaTeX,
45+ formatLaTeXInline, formatLaTeXBlock)
46data WriterState =
47data WriterState =
47 WriterState { stInNote :: Bool -- true if we're in a note
48 WriterState { stInNote :: Bool -- true if we're in a note
@@ -60,7 +61,7 @@ data WriterState =
60 , stLHS :: Bool -- true if document has literate haskell code
61 , stLHS :: Bool -- true if document has literate haskell code
61 , stBook :: Bool -- true if document uses book or memoir class
62 , stBook :: Bool -- true if document uses book or memoir class
62 , stCsquotes :: Bool -- true if document uses csquotes
63 , stCsquotes :: Bool -- true if document uses csquotes
63− , stHighlighting :: Bool -- true if document has highlighted code
64+ , stHighlighting :: Bool -- true if document has highlighted code
66-- | Convert Pandoc to LaTeX.
67-- | Convert Pandoc to LaTeX.
@@ -131,7 +132,7 @@ pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
131 [ ("graphics", "yes") | stGraphics st ] ++
132 [ ("graphics", "yes") | stGraphics st ] ++
132 [ ("book-class", "yes") | stBook st] ++
133 [ ("book-class", "yes") | stBook st] ++
133 [ ("listings", "yes") | writerListings options || stLHS st ] ++
134 [ ("listings", "yes") | writerListings options || stLHS st ] ++
134− [ ("highlighting-macros", defaultLaTeXMacros) | stHighlighting st ] ++
135+ [ ("highlighting-macros", styleToLaTeX pygments) | stHighlighting st ] ++
135 citecontext
136 citecontext
136 return $ if writerStandalone options
137 return $ if writerStandalone options
137 then renderTemplate context template
138 then renderTemplate context template
@@ -160,6 +161,7 @@ stringToLaTeX isUrl = escapeStringUsing latexEscapes
160 , ('\x2019', "'")
161 , ('\x2019', "'")
161 , ('\x201C', "``")
162 , ('\x201C', "``")
162 , ('\x201D', "''")
163 , ('\x201D', "''")
164+ , ('\x2026', "\\ldots{}")
165-- | Puts contents into LaTeX command.
167-- | Puts contents into LaTeX command.
@@ -231,7 +233,7 @@ blockToLaTeX (CodeBlock (_,classes,keyvalAttr) str) = do
231 return $ flush ("\\begin{lstlisting}" <> printParams $$ text str $$
233 return $ flush ("\\begin{lstlisting}" <> printParams $$ text str $$
232 "\\end{lstlisting}") $$ cr
234 "\\end{lstlisting}") $$ cr
233 highlightedCodeBlock =
235 highlightedCodeBlock =
234− case highlightLaTeX False ("",classes,keyvalAttr) str of
236+ case highlight formatLaTeXBlock ("",classes,keyvalAttr) str of
235 Nothing -> rawCodeBlock
237 Nothing -> rawCodeBlock
236 Just h -> modify (\st -> st{ stHighlighting = True }) >>
238 Just h -> modify (\st -> st{ stHighlighting = True }) >>
237 return (text h)
239 return (text h)
@@ -407,7 +409,7 @@ inlineToLaTeX (Code (_,classes,_) str) = do
407 let chr = ((enumFromTo '!' '~') \\ str) !! 0
409 let chr = ((enumFromTo '!' '~') \\ str) !! 0
408 return $ text $ "\\lstinline" ++ [chr] ++ str ++ [chr]
410 return $ text $ "\\lstinline" ++ [chr] ++ str ++ [chr]
409 highlightCode = do
411 highlightCode = do
410− case highlightLaTeX True ("",classes,[]) str of
412+ case highlight formatLaTeXInline ("",classes,[]) str of
411 Nothing -> rawCode
413 Nothing -> rawCode
412 Just h -> modify (\st -> st{ stHighlighting = True }) >>
414 Just h -> modify (\st -> st{ stHighlighting = True }) >>
413 return (text h)
415 return (text h)