git.iko.soy/typeable/pandoc
on master help sign in
LaTeX writer: Improved detection of book classes.
b76ba44John MacFarlane
src/Text/Pandoc/Writers/LaTeX.hs+9−6
@@ -82,12 +82,15 @@ writeLaTeX options document =
82pandocToLaTeX :: WriterOptions -> Pandoc -> State WriterState String
82pandocToLaTeX :: WriterOptions -> Pandoc -> State WriterState String
83pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
83pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
84 let template = writerTemplate options
84 let template = writerTemplate options
85− let templateLines = lines template
85+ -- set stBook depending on documentclass
86− let usesBookClass x = "\\documentclass" `isPrefixOf` x &&
86+ let bookClasses = ["memoir","book","report","scrreprt","scrbook"]
87− ("{memoir}" `isSuffixOf` x || "{book}" `isSuffixOf` x ||
87+ case lookup "documentclass" (writerVariables options) of
88− "{report}" `isSuffixOf` x)
88+ Just x | x `elem` bookClasses -> modify $ \s -> s{stBook = True}
89− when (any usesBookClass templateLines) $
89+ | otherwise -> return ()
90+ Nothing | any (\x -> "\\documentclass" `isPrefixOf` x &&
91+ (any (`isSuffixOf` x) bookClasses))
90− modify $ \s -> s{stBook = True}
92+ (lines template) -> modify $ \s -> s{stBook = True}
93+ | otherwise -> return ()
91 -- check for \usepackage...{csquotes}; if present, we'll use
94 -- check for \usepackage...{csquotes}; if present, we'll use
92 -- \enquote{...} for smart quotes:
95 -- \enquote{...} for smart quotes:
93 when ("{csquotes}" `isInfixOf` template) $
96 when ("{csquotes}" `isInfixOf` template) $