@@ -38,7 +38,7 @@ import Text.Pandoc.Options
38import Text.Pandoc.Templates
38import Text.Pandoc.Templates
39import Text.Printf ( printf )
39import Text.Printf ( printf )
40import Network.URI ( isURI, unEscapeString )
40import Network.URI ( isURI, unEscapeString )
41−import Data.Aeson (object, (.=))
41+import Data.Aeson ( object, (.=), FromJSON )
42import Data.List ( (\\), isInfixOf, stripPrefix, intercalate, intersperse )
42import Data.List ( (\\), isInfixOf, stripPrefix, intercalate, intersperse )
43import Data.Char ( toLower, isPunctuation, isAscii, isLetter, isDigit, ord )
43import Data.Char ( toLower, isPunctuation, isAscii, isLetter, isDigit, ord )
44import Data.Maybe ( fromMaybe )
44import Data.Maybe ( fromMaybe )
@@ -129,7 +129,12 @@ pandocToLaTeX options (Pandoc meta blocks) = do
129 | otherwise -> return ()
129 | otherwise -> return ()
130 -- check for \usepackage...{csquotes}; if present, we'll use
130 -- check for \usepackage...{csquotes}; if present, we'll use
131 -- \enquote{...} for smart quotes:
131 -- \enquote{...} for smart quotes:
132+ let headerIncludesField :: FromJSON a => Maybe a
133+ headerIncludesField = getField "header-includes" metadata
134+ let headerIncludes = fromMaybe [] $ mplus
135+ (fmap return headerIncludesField)
132− when ("{csquotes}" `isInfixOf` template) $
137+ when (any (isInfixOf "{csquotes}") (template : headerIncludes)) $
133 modify $ \s -> s{stCsquotes = True}
138 modify $ \s -> s{stCsquotes = True}
134 let (blocks'', lastHeader) = if writerCiteMethod options == Citeproc then
139 let (blocks'', lastHeader) = if writerCiteMethod options == Citeproc then
135 (blocks', [])
140 (blocks', [])