aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-06-11 20:43:20 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2019-06-11 20:47:29 -0700
commitbec95c97ace807b4f6c6ad359bf0b310b905f707 (patch)
treea474fb1282799e620fc76001f8a9c422dae55033
parent9725522a7f939f090800b6fcd0742d4d8ff671ed (diff)
downloadpandoc-bec95c97ace807b4f6c6ad359bf0b310b905f707.tar.gz
LaTeX writer: Don't highlight code in headings.
This causes compilation errors, and I don't know how to work around them. Closes #5574.
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs7
-rw-r--r--test/command/5574.md8
2 files changed, 12 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index 9933c6d36..3acf80866 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -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
diff --git a/test/command/5574.md b/test/command/5574.md
new file mode 100644
index 000000000..441b3afd6
--- /dev/null
+++ b/test/command/5574.md
@@ -0,0 +1,8 @@
+No highlighting inside heading:
+```
+% pandoc -t latex
+# `foo`{.cpp}
+^D
+\hypertarget{foo}{%
+\section{\texorpdfstring{\texttt{foo}}{foo}}\label{foo}}
+```