Skip to content

Commit

Permalink
LaTeX writer: Don't highlight code in headings.
Browse files Browse the repository at this point in the history
This causes compilation errors, and I don't know how
to work around them.  Closes #5574.
  • Loading branch information
jgm committed Jun 12, 2019
1 parent 9725522 commit bec95c9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Text/Pandoc/Writers/LaTeX.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions test/command/5574.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
No highlighting inside heading:
```
% pandoc -t latex
# `foo`{.cpp}
^D
\hypertarget{foo}{%
\section{\texorpdfstring{\texttt{foo}}{foo}}\label{foo}}
```

0 comments on commit bec95c9

Please sign in to comment.