summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers/LaTeX.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2011-12-30 09:56:09 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2011-12-30 09:57:00 -0800
commitb76ba44c52563806f89fbdb0d825e19c32dc9d36 (patch)
tree458460e39e5662a98b70710a7d964e475e5e0a4e /src/Text/Pandoc/Writers/LaTeX.hs
parent7702d2ca82f3013ba522985c41aedf71c10df9fb (diff)
LaTeX writer: Improved detection of book classes.
We now check the `documentclass` variable, and if that is not set, we look through the template itself. Also, we have added the KOMA classes scrreprt and scrbook. You can now make a book using markdown2pdf -V documentclass:book
Diffstat (limited to 'src/Text/Pandoc/Writers/LaTeX.hs')
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index 4575c6b14..fa715df25 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -82,12 +82,15 @@ writeLaTeX options document =
pandocToLaTeX :: WriterOptions -> Pandoc -> State WriterState String
pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
let template = writerTemplate options
- let templateLines = lines template
- let usesBookClass x = "\\documentclass" `isPrefixOf` x &&
- ("{memoir}" `isSuffixOf` x || "{book}" `isSuffixOf` x ||
- "{report}" `isSuffixOf` x)
- when (any usesBookClass templateLines) $
- modify $ \s -> s{stBook = True}
+ -- set stBook depending on documentclass
+ let bookClasses = ["memoir","book","report","scrreprt","scrbook"]
+ case lookup "documentclass" (writerVariables options) of
+ Just x | x `elem` bookClasses -> modify $ \s -> s{stBook = True}
+ | otherwise -> return ()
+ Nothing | any (\x -> "\\documentclass" `isPrefixOf` x &&
+ (any (`isSuffixOf` x) bookClasses))
+ (lines template) -> modify $ \s -> s{stBook = True}
+ | otherwise -> return ()
-- check for \usepackage...{csquotes}; if present, we'll use
-- \enquote{...} for smart quotes:
when ("{csquotes}" `isInfixOf` template) $