# Minted bug or misuse?

Consider the following minted code:

\begin{minted}[escapeinside=||]{ocaml}
foo |this is escaped| bar
\end{minted}


which works as expected, i.e., the escaped text is actually escaped.

However, if we change the language from ocaml to prolog, then the escaped text is no longer escaped:

\begin{minted}[escapeinside=||]{prolog}
foo |this is no longer escaped| bar
\end{minted}


Is this a minted bug or did I misuse the minted package? I tried several escape characters but nothing worked out for me.

minted uses Pygments to do the actual highlighting, and this includes escapeinside. Pygment's implementation of escapeinside can be fragile in some circumstances, and does not work inside strings or comments.
In the prolog case, foo is tokenized as a String.Atom, so when the lexer reaches the first |, it is in the wrong mode for starting an escape. In contrast, in the ocaml case, foo is tokenized as a Name, so the lexer interprets | as an escape. Ultimately this comes down to an interaction between the way that Pygments implements escapeinside, and the way that the prolog lexer works.