I just answered a question on SO and was wondering about the syntax highlighting. As you can see at Xpath - get maximum attribute for each element the syntax highlighting for XPath goes wrong, obviously because // is interpreted as a comment.

I saw the page at Changes to syntax highlighting and the list provided at http://pastebin.com/AWMtu5rK, which says that xpath should map to lang-xml. However, it would be rather strange to have // interpreted as a comment in XML as it is no valid comment.

So I was wondering whether the Google Code Prettify is the cause of the problem or the mapping in general or in this particular case is incorrect.


The list of mappings you list to is inaccurate, I suppose it went through some changes since it was posted.

As Jeff says here, "webby" languages such as Python are mapped to the default syntax highlighting (the page you link to says it's mapped to lang-py which is not true today). The same seems to be true for xpath which is mapped to default. You can see this by checking the CSS class associated with the code block, which is default and not lang-xml.

You can override the default by putting <!-- language: lang-xml --> before the code block.

  • Thanks, that helped a lot. However, I would consider mapping xpath to default a bug and instead map it to xml automatically as it is done for xquery. First, because XPath is a subset of XQuery, so it seems reasonable and secondly, because currently xml does no syntax highlighting for XPath/XQuery, which is still better and less confusing than an incorrect syntax highlighting. – dirkk Jun 3 '13 at 11:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .