Skip to content

Wrap latex commands #14

@ratnanil

Description

@ratnanil

As stated in #13, I want to use the latex-environment filter to highlight specific parts of my code, using the listings latex package / environment together with colorbox. Per default, all latex code within a listings environment is ignored. However, I can specify an escape character in the package options (see here)

escapechar=⟨character⟩ or escapechar={}
If not empty the given character escapes the user to LATEX: all code between
two such characters is interpreted as LATEX code

So if I set the escapechar = |, everything in between | in my listing environment will be interpreted as latex code. Is there a way to get this input:

:::{.lstlisting}
[one]{.colorbox optons = "gray"}, [two]{.colorbox options = "red"}
:::

to this latex output (note the wrapping |)?:

\begin{lstlisting}
|\colorbox{gray}{one}|, |\colorbox{red}{two}|
\end{lstlisting}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions