0

I'm trying to use Minted to perform syntax highlighting of Cucumber code in LaTeX. I want to use escapeinside to color Cucumber parameters, since they depend on definitions and can't be automatically highlighted by the parser without additional information. However, If an escapeinside sequence contains a number, the escapeinside delimiter is getting marked as a syntax error, thus this MWE:

\documentclass[10pt]{article}
\usepackage[cache=false]{minted}

\begin{document}

\begin{minted}[gobble=0,escapeinside=||]{cucumber}
Feature: Invented example
  Scenario: Check the results
    Given |1|
\end{minted}

\end{document}

produces this output (unaltered):

Syntax-highlighted Cucumber code from the MWE. The pipe characters are present, and appear with a red box.

The pipe characters, which should not be displayed at all, are shown, and are marked with red boxes indicating a syntax error. What is going on here, and how can I fix this?

1 Answer 1

1

I was able to work around the issue by setting the number in a macro and referencing the macro within the escapeinside:

\documentclass[10pt]{article}
\usepackage[cache=false]{minted}

\begin{document}

\newcommand{\one}{1}
\begin{minted[gobble=0,escapeinside=||]{cucumber}
Feature: Invented example
  Scenario: Check the results
    Given |\one|
\end{minted}

\end{document}
2
  • +1 could you accept this answer please if you answered your own question, it'll keep getting bumped by the community bot otherwise :)
    – JamesT
    Feb 18, 2023 at 11:02
  • 1
    @JamesT Alas, I was hoping for a better answer; mine is far from ideal. However, since no other seems to be forthcoming, I've accepted this one for now.
    – A. R.
    Feb 19, 2023 at 12:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .