@@ -49,6 +49,7 @@ data WriterState =
4949 , stLink :: Bool -- true if document has links
5050 , stUrl :: Bool -- true if document has visible URL link
5151 , stGraphics :: Bool -- true if document contains images
52+ , stLHS :: Bool -- true if document has literate haskell code
5253 }
5354
5455-- | Convert Pandoc to LaTeX.
@@ -58,7 +59,8 @@ writeLaTeX options document =
5859 WriterState { stInNote = False, stOLLevel = 1, stOptions = options,
5960 stVerbInNote = False, stEnumerate = False,
6061 stTable = False, stStrikeout = False, stSubscript = False,
61− stLink = False, stUrl = False, stGraphics = False }
62+ stLink = False, stUrl = False, stGraphics = False,
63+ stLHS = False }
6264
6365pandocToLaTeX :: WriterOptions -> Pandoc -> State WriterState String
6466pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
@@ -88,6 +90,7 @@ pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
8890 [ ("subscript", "yes") | stSubscript st ] ++
8991 [ ("links", "yes") | stLink st ] ++
9092 [ ("url", "yes") | stUrl st ] ++
93+ [ ("lhs", "yes") | stLHS st ] ++
9194 [ ("graphics", "yes") | stGraphics st ]
9295 return $ if writerStandalone options
9396 then renderTemplate context $ writerTemplate options
@@ -139,7 +142,9 @@ blockToLaTeX (CodeBlock (_,classes,_) str) = do
139142 st <- get
140143 env <- if writerLiterateHaskell (stOptions st) && "haskell" `elem` classes &&
141144 "literate" `elem` classes
142− then return "code"
145+ then do
146+ modify $ \s -> s{ stLHS = True }
147+ return "code"
143148 else if stInNote st
144149 then do
145150 modify $ \s -> s{ stVerbInNote = True }