2

I'm working on the implementation of a HTML5 code style for \listings.

Currently I have the problem that there are different ways to define HTML tags. In my example, I don't get /p in <p></p> marked.

Screenshot:

enter image description here

My keyword definition looks like this:

otherkeywords={>,><,</p,<p,</p>}

If I add /p to the list, then </p> is not marked anymore.

Here is my language definition:

\lstdefinelanguage{HTML5}{
  language=html,
  sensitive=true,   
  alsoletter={<>=-},    
  morecomment=[s]{<!-}{-->},
  tag=[s],
  otherkeywords={>,><,</p,<p,</p>}
}

For a complete example I've created this document: https://www.writelatex.com/74567mmxwkw

  • 1
    Shouldn't it work if you omit >< from the keyword list? – clemens Feb 24 '13 at 12:40
  • Wow. That was easy. I missed the forest for the trees. Thank you! You can write this as a solution, so that I can check off the question. – Benny Neugebauer Feb 24 '13 at 16:36
  • @cgnieder Please write a short answer (or cast the first closing vote). – lockstep Mar 6 '13 at 12:18
3

You're declaring the keyword >< which leads to the wrong coloring. The line

<p></p>

is interpreted as the keywords <p and >< followed by /p (which is no keyword) and then again a keyword, >.

Leaving the >< keyword out should suffice. The line the would be interpreted as the keywords <p, >, </p, and >, which should be what you want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.