From b76ba44c52563806f89fbdb0d825e19c32dc9d36 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 30 Dec 2011 09:56:09 -0800 Subject: 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 --- src/Text/Pandoc/Writers/LaTeX.hs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 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 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) $ -- cgit v1.2.3