What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 142 Stack Exchange communities.

Like it or not, but XML has become quite common and is showing up in questions that are not directly related to XML at all (i.e. the question is not about parsing/reading/handling the XML, but the XML shows up as context, for example).

A good example is this question (and many other android-related questions).

Since the question has the tag it (rightfully) assumes that source in it is Java code.

This means that Java syntax highlighting is also applied to the XML which has strange results (for example the blue package statement).

It might be a good idea to check the first 5 letters of a code-block and if they are <?xml then override all other auto-detection and format it as XML.

I'm aware that this would give XML a special state (since no other language gets that kind of special treatment, as far as I know), but it's pervasiveness does ask for this.

share|improve this question
Tumbleweed, yay! Am I the only one pedantic enough to be annoyed by un-highlighted XML? –  Joachim Sauer May 5 '11 at 10:50
What's the issue with just editing in the syntax colouring hint? –  Tim Stone Jul 7 '11 at 13:44
@Tim: I don't think most people know about it. Also, XML is very wide spread and detecting it is pretty trivial, so it wouldn't be much work. –  Joachim Sauer Jul 7 '11 at 13:47

1 Answer 1

up vote 3 down vote accepted

No -- what we would typically do in this case is decide that Java is a "webby" language and is frequently accompanied by JavaScript, HTML, XML, json, etc and switch the tag to default (aka auto-detect) inference.

This will lead to sub-optimal Java syntax highlighting, but it solves your concern about XML.

share|improve this answer
I'd rather live with un-highlighted XML in Java answers, than with sub-optimal Java syntax highlighting. But thank for the answer. –  Joachim Sauer Jul 11 '11 at 8:37
@joa the default prettify autodetect is pretty good, we had it for 2 years on SO and nobody was complaining about it except for rare edge cases. –  Jeff Atwood Jul 11 '11 at 8:40

You must log in to answer this question.

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