From bdd448ea2cf41324a63bd09771b5ac553e65f540 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Thu, 31 Dec 2009 21:18:36 +0000 Subject: LaTeX writer: Only require listings package if needed. That is, if literate Haskell code is used. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1759 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Writers/LaTeX.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Writers/LaTeX.hs') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 1c8604c8a..b9e7e42a8 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -49,6 +49,7 @@ data WriterState = , stLink :: Bool -- true if document has links , stUrl :: Bool -- true if document has visible URL link , stGraphics :: Bool -- true if document contains images + , stLHS :: Bool -- true if document has literate haskell code } -- | Convert Pandoc to LaTeX. @@ -58,7 +59,8 @@ writeLaTeX options document = WriterState { stInNote = False, stOLLevel = 1, stOptions = options, stVerbInNote = False, stEnumerate = False, stTable = False, stStrikeout = False, stSubscript = False, - stLink = False, stUrl = False, stGraphics = False } + stLink = False, stUrl = False, stGraphics = False, + stLHS = False } pandocToLaTeX :: WriterOptions -> Pandoc -> State WriterState String pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do @@ -88,6 +90,7 @@ pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do [ ("subscript", "yes") | stSubscript st ] ++ [ ("links", "yes") | stLink st ] ++ [ ("url", "yes") | stUrl st ] ++ + [ ("lhs", "yes") | stLHS st ] ++ [ ("graphics", "yes") | stGraphics st ] return $ if writerStandalone options then renderTemplate context $ writerTemplate options @@ -139,7 +142,9 @@ blockToLaTeX (CodeBlock (_,classes,_) str) = do st <- get env <- if writerLiterateHaskell (stOptions st) && "haskell" `elem` classes && "literate" `elem` classes - then return "code" + then do + modify $ \s -> s{ stLHS = True } + return "code" else if stInNote st then do modify $ \s -> s{ stVerbInNote = True } -- cgit v1.2.3