I'm using lstnewenvironment
to color my SAS datasteps. I'm using emph/emphstyle to add new keywords (as I didn't get to work morekeyword and otherkeyword).
If I use (in=...
) after a dataset name the in should be considered as a keyword (in blue)
If I use x in (1,2) then in should not be considered as a keyword.
How can I conditionally assign a color to in when it is followed by an equal sign (or blank + equal sign) and black when it isn't ?
Many thanks in advance for your help.
Right now the only solution I got is to use escapeinside={(*@}{@*)}
, and assign manually the color locally.
Here is an example:
\documentclass[a4paper,12pt]{report} \usepackage{xcolor} \usepackage{listings} \usepackage{textcomp} \definecolor{sasdarkblue} {RGB}{0,0,114} %#000072 \definecolor{sasblue} {RGB}{21,23,206} %#1517CE \definecolor{sasviolet} {RGB}{109,23,110} %#6D176E \lstnewenvironment{sasdatastep}{% \lstset{% basicstyle =\small\ttfamily,% language =SAS,% keywordstyle =\color{sasblue}\ttfamily,% escapechar =|,% escapeinside ={(*@}{@*)},% stringstyle =\color{sasviolet}\ttfamily,% showstringspaces=false,% keepspaces =true,% sensitive =false,% emph =[1]{run,data,\%macro,\%mend}, % emphstyle =[1]\color{sasdarkblue}\ttfamily\textbf, % emph =[2]{in,indsname,point,nobs},% emphstyle =[2]\color{sasblue}, % emph =[3]{indsname,point,nobs},% upquote =true% } }{} \begin{document} \begin{sasdatastep} data new; set one (in=_one) two (in=_two); run; data one; set one (where=(x in (1,2))); run; \end{sasdatastep} \end{document}
minted
.