diff options
| author | John MacFarlane <[email protected]> | 2025-09-19 10:15:32 +0200 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2025-09-19 10:16:25 +0200 |
| commit | 643712ca70b924c0edcc059699aa1ee42234be34 (patch) | |
| tree | c81db41f4ba543cf3ccead4cf95d75fe2322de99 /src | |
| parent | 3cf8c5f7161a63341f70a26a0f47894dca49dc83 (diff) | |
LaTeX writer: avoid `\_` in bibliography variable.
Since underscores are common in filenames, and pandoc will
render strings to variables using default LaTeX escaping, we
special-case `bibliography`, under the assumption that this variable
will be used in the context of the `\bibliography{..}` command,
which accepts unescaped underscores.
Closes #11152.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/Writers/LaTeX.hs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 24ed4bebc..14c8de08a 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -215,7 +215,15 @@ pandocToLaTeX options (Pandoc meta blocks) = do _ -> []) $ lookupMetaInlines "nocite" meta - let context = defField "toc" (writerTableOfContents options) $ + -- see #7414, avoid escaped underscores + let unescapeUnderscore = T.replace "\\_" "_" + let bibliography' = map unescapeUnderscore <$> + getField "bibliography" metadata + + let context = (case bibliography' of + Nothing -> id + Just xs -> resetField "bibliography" xs) $ + defField "toc" (writerTableOfContents options) $ defField "lof" (writerListOfFigures options) $ defField "lot" (writerListOfTables options) $ defField "toc-depth" (tshow |
