Skip to content

Get rid of backticks for green in lstlistings #2

Description

@sdawans

the listings package we use to display code doesn't play well with colored text. We need to use this hackish kind of syntax to do it:

In the preamble:

\lstdefinestyle{BashInputStyle}{
   language=bash,
   linewidth=0.95\linewidth,
   xleftmargin=0.05\linewidth,
   moredelim=**[is][\color{red}]{§}{§},
   moredelim=**[is][\color{OliveGreen}]{`}{`}
 }

Then in the code, here I use § delimiters to get red text:

\begin{lstlisting}[style=BashInputStyle]
  $ echo hello > newfile.txt
  $ git status
  # On branch master
  # Untracked files:
  #   (use "git add <file>..." to include in what will be committed)
  #
    §newfile.txt§
  nothing added to commit but untracked files present (use "git add" to track)
\end{lstlisting}

For now we use:

  • Backticks for green
  • § for red

backticks need to be replaced by something else because they are sometimes present in the code, such as when displaying tree output in the ASCII charset.

To make things even easier: the delimiters must be in the extended-ascii charset because listings doesn't understand UTF-8.

🆒

I think ° is a good candidate

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions