Skip to content

CodeEmphasisLine called on every word in a line instead of the whole line #9

@coreyhuinker

Description

@coreyhuinker

Here is my input file, example.md, only a slight variation on doc example from the docs:

---
header-includes:
  - \usepackage{listings}
  - \lstset{basicstyle=\ttfamily}
  - \newcommand{\CodeEmphasis}[1]{\textcolor{red}{\textit{#1}}}
  - \newcommand{\CodeEmphasisLine}[1]{\colorbox{yellow}{#1}}
---

# My Slide {.fragile}

```{.haskell emphasize=2:3-2:14,3:3-3:12,4-4}
myFunc = do
  one two three
  four five six
  seven eight nine
  ten eleven twelve
```

When I run pandoc --filter pandoc-emphasize-code --to beamer example.md --output example.pdf

Instead of one solid yellow background I get irregularly shaped backgrounds around each word.

When I run pandoc --filter pandoc-emphasize-code --to beamer example.md

I get the following output:

\begin{frame}[fragile]{My Slide}
\protect\hypertarget{my-slide}{}

\begin{lstlisting}[escapechar=£,language=haskell]
myFunc = do
  £\CodeEmphasis{one}£ £\CodeEmphasis{two}£ £\CodeEmphasis{thre}£e
  £\CodeEmphasis{four}£ £\CodeEmphasis{five}£ six
  £\CodeEmphasisLine{seven}£ £\CodeEmphasisLine{eight}£ £\CodeEmphasisLine{nine}£
  ten eleven twelve
\end{lstlisting}

\end{frame}

and you can see \CodeEmphasisLine is wrapped around each word in the line, rather than the line itself. This has no consequences the styling is purely on the text (i.e. \textit), but when the styling involves the background color it leads to a PDF with a series of blocks around each word, with white/background-space in between the highlighted words.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions