git.iko.soy/typeable/pandoc
on master help sign in
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

commitb76ba44c52563806f89fbdb0d825e19c32dc9d36 authorJohn MacFarlane <fiddlosopher@gmail.com> dateFri 30 Dec 2011, 09:56 (15 years ago) parent7702d2c
1 file changed+9−6
src/Text/Pandoc/Writers/LaTeX.hs+9−6
src/Text/Pandoc/Writers/LaTeX.hs+9−6
@@ -82,12 +82,15 @@ writeLaTeX options document =
8282pandocToLaTeX :: WriterOptions -> Pandoc -> State WriterState String
8383pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
8484 let template = writerTemplate options
85− let templateLines = lines template
86− let usesBookClass x = "\\documentclass" `isPrefixOf` x &&
87− ("{memoir}" `isSuffixOf` x || "{book}" `isSuffixOf` x ||
88− "{report}" `isSuffixOf` x)
89− when (any usesBookClass templateLines) $
90− modify $ \s -> s{stBook = True}
85+ -- set stBook depending on documentclass
86+ let bookClasses = ["memoir","book","report","scrreprt","scrbook"]
87+ case lookup "documentclass" (writerVariables options) of
88+ Just x | x `elem` bookClasses -> modify $ \s -> s{stBook = True}
89+ | otherwise -> return ()
90+ Nothing | any (\x -> "\\documentclass" `isPrefixOf` x &&
91+ (any (`isSuffixOf` x) bookClasses))
92+ (lines template) -> modify $ \s -> s{stBook = True}
93+ | otherwise -> return ()
9194 -- check for \usepackage...{csquotes}; if present, we'll use
9295 -- \enquote{...} for smart quotes:
9396 when ("{csquotes}" `isInfixOf` template) $