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
This commit is contained in:
fiddlosopher 2009-12-31 21:18:36 +00:00
parent 07fe1aedd0
commit bdd448ea2c
4 changed files with 9 additions and 6 deletions

View file

@ -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 }

View file

@ -9,8 +9,10 @@ $else$
\usepackage[mathletters]{ucs}
\usepackage[utf8x]{inputenc}
$endif$
$if(lhs)$
\usepackage{listings}
\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}
$endif$
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
$endif$

View file

@ -2,8 +2,6 @@
\usepackage{amsmath}
\usepackage[mathletters]{ucs}
\usepackage[utf8x]{inputenc}
\usepackage{listings}
\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\setcounter{secnumdepth}{0}

View file

@ -2,8 +2,6 @@
\usepackage{amsmath}
\usepackage[mathletters]{ucs}
\usepackage[utf8x]{inputenc}
\usepackage{listings}
\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\usepackage{fancyvrb}