@@ -49,6 +49,7 @@ data WriterState =
49 , stLink :: Bool -- true if document has links
49 , stLink :: Bool -- true if document has links
50 , stUrl :: Bool -- true if document has visible URL link
50 , stUrl :: Bool -- true if document has visible URL link
51 , stGraphics :: Bool -- true if document contains images
51 , stGraphics :: Bool -- true if document contains images
52+ , stLHS :: Bool -- true if document has literate haskell code
54-- | Convert Pandoc to LaTeX.
55-- | Convert Pandoc to LaTeX.
@@ -58,7 +59,8 @@ writeLaTeX options document =
58 WriterState { stInNote = False, stOLLevel = 1, stOptions = options,
59 WriterState { stInNote = False, stOLLevel = 1, stOptions = options,
59 stVerbInNote = False, stEnumerate = False,
60 stVerbInNote = False, stEnumerate = False,
60 stTable = False, stStrikeout = False, stSubscript = False,
61 stTable = False, stStrikeout = False, stSubscript = False,
61− stLink = False, stUrl = False, stGraphics = False }
62+ stLink = False, stUrl = False, stGraphics = False,
63pandocToLaTeX :: WriterOptions -> Pandoc -> State WriterState String
65pandocToLaTeX :: WriterOptions -> Pandoc -> State WriterState String
64pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
66pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
@@ -88,6 +90,7 @@ pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
88 [ ("subscript", "yes") | stSubscript st ] ++
90 [ ("subscript", "yes") | stSubscript st ] ++
89 [ ("links", "yes") | stLink st ] ++
91 [ ("links", "yes") | stLink st ] ++
90 [ ("url", "yes") | stUrl st ] ++
92 [ ("url", "yes") | stUrl st ] ++
93+ [ ("lhs", "yes") | stLHS st ] ++
91 [ ("graphics", "yes") | stGraphics st ]
94 [ ("graphics", "yes") | stGraphics st ]
92 return $ if writerStandalone options
95 return $ if writerStandalone options
93 then renderTemplate context $ writerTemplate options
96 then renderTemplate context $ writerTemplate options
@@ -139,7 +142,9 @@ blockToLaTeX (CodeBlock (_,classes,_) str) = do
139 st <- get
142 st <- get
140 env <- if writerLiterateHaskell (stOptions st) && "haskell" `elem` classes &&
143 env <- if writerLiterateHaskell (stOptions st) && "haskell" `elem` classes &&
141 "literate" `elem` classes
144 "literate" `elem` classes
146+ modify $ \s -> s{ stLHS = True }
142− then return "code"
147+ return "code"
143 else if stInNote st
148 else if stInNote st
145 modify $ \s -> s{ stVerbInNote = True }
150 modify $ \s -> s{ stVerbInNote = True }