I'm looking for a possibility to find a way to colorize data. If a text starts in a line with XYZ from that point until the next blank line the text should be set in a defined colour. With the comment feature like
comment=[s]{^XYZ}{
}
it is not possible.
comment=[s]{XYZ}{</end>}
works, but it is not solution for my need. At least, XYZ can also be in the normal text, but only if a line starts with it, the text block should be coloured. Is there a solution with listings?
Here is an example:
\documentclass{report}
\usepackage{listings,xcolor}
\lstdefinelanguage{text}{}
\lstnewenvironment{mylang}{\lstset{language=text,
comment=[s]{XYZ}{</end>},%
commentstyle=\color{green},%
basicstyle=\footnotesize\ttfamily,%
showstringspaces=false,%
showspaces=false,%
}}{}
\begin{document}
\begin{mylang}
Only a test, this is not a comment
XYZ this should colored as a comment
and this line too
this is not a command, because only lines starting with XYZ
are comments </end>
This is not a comment, too
\end{mylang}
\end{document}
Here is an example:
\documentclass{report}
\usepackage{listings,xcolor}
\lstdefinelanguage{text}{}
\lstnewenvironment{mylang}{\lstset{language=text,
comment=[s]{XYZ}{</end>},%
commentstyle=\color{green},%
basicstyle=\footnotesize\ttfamily,%
showstringspaces=false,%
showspaces=false,%
}}{}
\begin{document}
\begin{mylang}
Only a test, this is not a comment
XYZ this should colored as a comment
and this line too
this is not a command, because only lines starting with XYZ
are comments </end>
This is not a comment, too
\end{mylang}
\end{document}

