LaTeX writer: Don't highlight code in headings.

This causes compilation errors, and I don't know how
to work around them.  Closes #5574.
This commit is contained in:
John MacFarlane 2019-06-11 20:43:20 -07:00
parent 9725522a7f
commit bec95c97ac
2 changed files with 12 additions and 3 deletions

View file

@ -1190,10 +1190,11 @@ inlineToLaTeX (Code (_,classes,kvs) str) = do
Right h -> modify (\st -> st{ stHighlighting = True }) >>
return (text (T.unpack h))
case () of
_ | writerListings opts && not (inHeading || inItem) -> listingsCode
_ | inHeading || inItem -> rawCode -- see #5574
| writerListings opts -> listingsCode
| isJust (writerHighlightStyle opts) && not (null classes)
-> highlightCode
| otherwise -> rawCode
-> highlightCode
| otherwise -> rawCode
inlineToLaTeX (Quoted qt lst) = do
contents <- inlineListToLaTeX lst
csquotes <- liftM stCsquotes get

8
test/command/5574.md Normal file
View file

@ -0,0 +1,8 @@
No highlighting inside heading:
```
% pandoc -t latex
# `foo`{.cpp}
^D
\hypertarget{foo}{%
\section{\texorpdfstring{\texttt{foo}}{foo}}\label{foo}}
```