I've added a hook to lstlisting to do some special highlighting. Now I've got it to highlight %-prefixed variables just fine, but I'd like to handle the special case "%this" in another way.
Unfortunately when lstlisting find a keyword followed by a comma, it gives me this\unhbox \voidb@x \kern \z@
which I have a hard time parsing.. Essentially I just need to check if it is a "this" keyword, this has proved tricky however.
Just to be a little more specific, I can't just do a substring because %thisVal should not be accepted, only %this.
I tried the Sanitizer from another thread but had no success.
If the token didn't have all that other stuff appended, all I needed to do is:
\ifnum\pdf@strcmp{\@restTestChar}{this}=0%
\def\lst@thestyle{\color{thisColor}}%
\else
\def\lst@thestyle{\color{variableColor}}%
\fi
I was thinking that any way to just remove anything after the first \ should work, but I can't figure out how to do this as it is not a string per se.
Aucun commentaire:
Enregistrer un commentaire