git.iko.soy/typeable/pandoc
on master help sign in
Consider header files when determining whether to use csquotes.
commitf0c47907ca1d7ee9600a574c3e007640c7700d7d authorAndreas Lööw <AndreasLoow@users.noreply.github.com> dateSat 17 Oct 2015, 22:58 (11 years ago) parente08399a
2 files changed+14−8
README+7−6 src/Text/Pandoc/Writers/LaTeX.hs+7−2
README+7−6
@@ -184,10 +184,10 @@ document contains images), [`color`], [`hyperref`], [`ulem`],
184184[`mathspec`], [`polyglossia`] (with `lang`), [`xecjk`], and
185185[`bidi`] (with the `dir` variable set). The [`upquote`] and
186186[`microtype`] packages are used if available, and [`csquotes`] will
187−be used for [smart punctuation] if added to the template. The
188−[`natbib`], [`biblatex`], [`bibtex`], and [`biber`] packages can
189−optionally be used for [citation rendering]. These are included with
190−all recent versions of [TeX Live].
187+be used for [smart punctuation] if added to the template or included in
188+any header file. The [`natbib`], [`biblatex`], [`bibtex`], and [`biber`]
189+packages can optionally be used for [citation rendering]. These are
190+included with all recent versions of [TeX Live].
191191
192192PDF output can be controlled using [variables for LaTeX].
193193
@@ -2377,8 +2377,9 @@ correct output, converting straight quotes to curly quotes, `---` to
23772377em-dashes, `--` to en-dashes, and `...` to ellipses. Nonbreaking spaces
23782378are inserted after certain abbreviations, such as "Mr."
23792379
2380−Note: if your LaTeX template calls for the [`csquotes`] package, pandoc will
2381−detect this automatically and use `\enquote{...}` for quoted text.
2380+Note: if your LaTeX template or any included header file call for the
2381+[`csquotes`] package, pandoc will detect this automatically and use
2382+`\enquote{...}` for quoted text.
23822383
23832384Inline formatting
23842385-----------------
src/Text/Pandoc/Writers/LaTeX.hs+7−2
@@ -38,7 +38,7 @@ import Text.Pandoc.Options
3838import Text.Pandoc.Templates
3939import Text.Printf ( printf )
4040import Network.URI ( isURI, unEscapeString )
41−import Data.Aeson (object, (.=))
41+import Data.Aeson ( object, (.=), FromJSON )
4242import Data.List ( (\\), isInfixOf, stripPrefix, intercalate, intersperse )
4343import Data.Char ( toLower, isPunctuation, isAscii, isLetter, isDigit, ord )
4444import Data.Maybe ( fromMaybe )
@@ -129,7 +129,12 @@ pandocToLaTeX options (Pandoc meta blocks) = do
129129 | otherwise -> return ()
130130 -- check for \usepackage...{csquotes}; if present, we'll use
131131 -- \enquote{...} for smart quotes:
132− when ("{csquotes}" `isInfixOf` template) $
132+ let headerIncludesField :: FromJSON a => Maybe a
133+ headerIncludesField = getField "header-includes" metadata
134+ let headerIncludes = fromMaybe [] $ mplus
135+ (fmap return headerIncludesField)
136+ headerIncludesField
137+ when (any (isInfixOf "{csquotes}") (template : headerIncludes)) $
133138 modify $ \s -> s{stCsquotes = True}
134139 let (blocks'', lastHeader) = if writerCiteMethod options == Citeproc then
135140 (blocks', [])