I am trying to use the hack to highlight code between (but not including) two delimiters discussed in this question, but I am producing duplicate delimiters.
My goal is to highlight in orange everything between by (including the word "by") up until (but not including) a semicolon. So ideally thus X by a,b,c; would be highlighted as thus X \textcolor{orange}{by a,b,c};.
Here's a minimal working example with the bug:
\documentclass[varwidth=6.75in]{standalone}
\usepackage{listings}
\usepackage{xcolor}
\definecolor{citeOrange}{HTML}{fb7640}
\newcommand{\mizarByStyle}[1]{\ \textcolor{citeOrange}{by} \textcolor{citeOrange}{#1};}
\lstdefinelanguage{mizar}{
morekeywords=[0]{->,(#,#),.=)},
moredelim=[is][\mizarByStyle]{\ by}{;}
}
\lstnewenvironment{mizar}[1][]%
{\lstset{language=mizar,
basicstyle=\ttfamily,
upquote=true}}%
{}
\begin{document}
\begin{mizar}
theorem Th3:
for f being Element of Aut G
holds f is Automorphism of G
proof
let f be Element of Aut G;
f is bijective Homomorphism of G,G by AUTGROUP:def 1;
thus thesis;
end;
\end{mizar}
\end{document}
And this is what it looks like:
Addendum: what I suspect is happening is that listings is treating thus X by a:def 3; as several "tokens" delimited between by and ;, which then applies the \mizarByStyle to each "token". And if this is the case, is there any way to remedy the situation?
Almost certainly I will need to highlight situations like thus X by a, b, c; and the spaces between the a, b, and c would produce this "bug" all over again :(
