From a55fb5f29d3772981adfc494c2597f0a1b8bdb64 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 13 Oct 2020 20:53:39 -0700 Subject: LaTeX writer: escape option values in lstlistings environment. Closes #6742. --- src/Text/Pandoc/Writers/LaTeX.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index f7342f6e1..965395d7c 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -635,6 +635,7 @@ blockToLaTeX (CodeBlock (identifier,classes,keyvalAttr) str) = do let listingsCodeBlock = do st <- get ref <- toLabel identifier + let esc = escapeStringUsing (backslashEscapes "\\{}%~_&#^") let params = if writerListings (stOptions st) then (case getListingsLanguage classes of Just l -> [ "language=" <> mbBraced l ] @@ -644,7 +645,7 @@ blockToLaTeX (CodeBlock (identifier,classes,keyvalAttr) str) = do || "number-lines" `elem` classes ] ++ [ (if key == "startFrom" then "firstnumber" - else key) <> "=" <> mbBraced attr | + else key) <> "=" <> mbBraced (esc attr) | (key,attr) <- keyvalAttr, key `notElem` ["exports", "tangle", "results"] -- see #4889 -- cgit v1.2.3