diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Writers/LaTeX.hs | 15 |
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) $ |