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.
This commit is contained in:
John MacFarlane
2025-09-19 10:15:32 +02:00
parent 3cf8c5f716
commit 643712ca70
2 changed files with 10 additions and 2 deletions
+9 -1
View File
@@ -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
+1 -1
View File
@@ -98,7 +98,7 @@ Pandoc
[ Para [ Str "Code in a block quote:" ]
, CodeBlock
( "" , [ "" ] , [] )
"sub status {\nprint \"working\";\n}\n"
"sub status {\n print \"working\";\n}\n"
, Para [ Str "A list:" ]
, OrderedList
( 1 , Decimal , Period )