git.iko.soy/typeable/pandoc
on master help sign in
LaTeX writer: Don't highlight code in headings.

This causes compilation errors, and I don't know how to work around them. Closes #5574.

commitbec95c97ace807b4f6c6ad359bf0b310b905f707 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 11 Jun 2019, 20:43 (7 years ago) parent9725522
2 files changed+12−3
src/Text/Pandoc/Writers/LaTeX.hs+4−3 test/command/5574.md+8
src/Text/Pandoc/Writers/LaTeX.hs+4−3
@@ -1190,10 +1190,11 @@ inlineToLaTeX (Code (_,classes,kvs) str) = do
11901190 Right h -> modify (\st -> st{ stHighlighting = True }) >>
11911191 return (text (T.unpack h))
11921192 case () of
1193− _ | writerListings opts && not (inHeading || inItem) -> listingsCode
1193+ _ | inHeading || inItem -> rawCode -- see #5574
1194+ | writerListings opts -> listingsCode
11941195 | isJust (writerHighlightStyle opts) && not (null classes)
1195− -> highlightCode
1196− | otherwise -> rawCode
1196+ -> highlightCode
1197+ | otherwise -> rawCode
11971198inlineToLaTeX (Quoted qt lst) = do
11981199 contents <- inlineListToLaTeX lst
11991200 csquotes <- liftM stCsquotes get
test/command/5574.mdnew file+8
@@ -0,0 +1,8 @@
1+No highlighting inside heading:
2+```
3+% pandoc -t latex
4+# `foo`{.cpp}
5+^D
6+\hypertarget{foo}{%
7+\section{\texorpdfstring{\texttt{foo}}{foo}}\label{foo}}
8+```