Code: Select all
Code, edit and compile here:
\documentclass{article}\usepackage{listings}\lstdefinelanguage{XQuery}[]{XML}{tag=[s]<>, % =*: also apply styles within tag, =**: cumulate stylesmorekeywords={text},sensitive=false}\lstset{%language=XQuery,tagstyle=\bfseries,keywordstyle=\underbar,stringstyle=\itshape,showstringspaces=false}\begin{document}\begin{lstlisting}text <hello type='text/plain'>world</hello>/text()\end{lstlisting}\end{document}
whereas the desired output would be:text <hello type='text/plain'>world</hello>/text()
In particular the word "text" within the hello-tag should NOT be underlined (because there are no * or ** in the definition of "tag=[s]<>"). In fact if you put one or two *, that part works as expected ("text" is in stringstyle (italics) or stringstyle+tagstyle (italics and bold) respectively).text <hello type='text/plain'>world</hello>/text()
But the "text" words outside don't get their keywordstyle in either of the cases.
I did have a look at lstdrvrs.dtx, where XML is defined. But I couldn't work out what the cause could be.
Does anyone have an idea? Is there somebody in this forum who already did (try to) define an own language as well?
Cheers