Consider header files when determining whether to use csquotes.
This commit is contained in:
parent
e08399a16b
commit
f0c47907ca
2 changed files with 14 additions and 8 deletions
13
README
13
README
|
@ -184,10 +184,10 @@ document contains images), [`color`], [`hyperref`], [`ulem`],
|
||||||
[`mathspec`], [`polyglossia`] (with `lang`), [`xecjk`], and
|
[`mathspec`], [`polyglossia`] (with `lang`), [`xecjk`], and
|
||||||
[`bidi`] (with the `dir` variable set). The [`upquote`] and
|
[`bidi`] (with the `dir` variable set). The [`upquote`] and
|
||||||
[`microtype`] packages are used if available, and [`csquotes`] will
|
[`microtype`] packages are used if available, and [`csquotes`] will
|
||||||
be used for [smart punctuation] if added to the template. The
|
be used for [smart punctuation] if added to the template or included in
|
||||||
[`natbib`], [`biblatex`], [`bibtex`], and [`biber`] packages can
|
any header file. The [`natbib`], [`biblatex`], [`bibtex`], and [`biber`]
|
||||||
optionally be used for [citation rendering]. These are included with
|
packages can optionally be used for [citation rendering]. These are
|
||||||
all recent versions of [TeX Live].
|
included with all recent versions of [TeX Live].
|
||||||
|
|
||||||
PDF output can be controlled using [variables for LaTeX].
|
PDF output can be controlled using [variables for LaTeX].
|
||||||
|
|
||||||
|
@ -2377,8 +2377,9 @@ correct output, converting straight quotes to curly quotes, `---` to
|
||||||
em-dashes, `--` to en-dashes, and `...` to ellipses. Nonbreaking spaces
|
em-dashes, `--` to en-dashes, and `...` to ellipses. Nonbreaking spaces
|
||||||
are inserted after certain abbreviations, such as "Mr."
|
are inserted after certain abbreviations, such as "Mr."
|
||||||
|
|
||||||
Note: if your LaTeX template calls for the [`csquotes`] package, pandoc will
|
Note: if your LaTeX template or any included header file call for the
|
||||||
detect this automatically and use `\enquote{...}` for quoted text.
|
[`csquotes`] package, pandoc will detect this automatically and use
|
||||||
|
`\enquote{...}` for quoted text.
|
||||||
|
|
||||||
Inline formatting
|
Inline formatting
|
||||||
-----------------
|
-----------------
|
||||||
|
|
|
@ -38,7 +38,7 @@ import Text.Pandoc.Options
|
||||||
import Text.Pandoc.Templates
|
import Text.Pandoc.Templates
|
||||||
import Text.Printf ( printf )
|
import Text.Printf ( printf )
|
||||||
import Network.URI ( isURI, unEscapeString )
|
import Network.URI ( isURI, unEscapeString )
|
||||||
import Data.Aeson (object, (.=))
|
import Data.Aeson ( object, (.=), FromJSON )
|
||||||
import Data.List ( (\\), isInfixOf, stripPrefix, intercalate, intersperse )
|
import Data.List ( (\\), isInfixOf, stripPrefix, intercalate, intersperse )
|
||||||
import Data.Char ( toLower, isPunctuation, isAscii, isLetter, isDigit, ord )
|
import Data.Char ( toLower, isPunctuation, isAscii, isLetter, isDigit, ord )
|
||||||
import Data.Maybe ( fromMaybe )
|
import Data.Maybe ( fromMaybe )
|
||||||
|
@ -129,7 +129,12 @@ pandocToLaTeX options (Pandoc meta blocks) = do
|
||||||
| otherwise -> return ()
|
| otherwise -> return ()
|
||||||
-- check for \usepackage...{csquotes}; if present, we'll use
|
-- check for \usepackage...{csquotes}; if present, we'll use
|
||||||
-- \enquote{...} for smart quotes:
|
-- \enquote{...} for smart quotes:
|
||||||
when ("{csquotes}" `isInfixOf` template) $
|
let headerIncludesField :: FromJSON a => Maybe a
|
||||||
|
headerIncludesField = getField "header-includes" metadata
|
||||||
|
let headerIncludes = fromMaybe [] $ mplus
|
||||||
|
(fmap return headerIncludesField)
|
||||||
|
headerIncludesField
|
||||||
|
when (any (isInfixOf "{csquotes}") (template : headerIncludes)) $
|
||||||
modify $ \s -> s{stCsquotes = True}
|
modify $ \s -> s{stCsquotes = True}
|
||||||
let (blocks'', lastHeader) = if writerCiteMethod options == Citeproc then
|
let (blocks'', lastHeader) = if writerCiteMethod options == Citeproc then
|
||||||
(blocks', [])
|
(blocks', [])
|
||||||
|
|
Loading…
Add table
Reference in a new issue