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

This question already has an answer here:

Syntax highlighter works strangely in the current question.

The weird thing is that in other questions the highlighting works fine. Firstly, I supposed the system haven't detected the language, but copying snippets from other questions didn't enable it either.

What is the reason?


UPDATE: It looks like the system detected the language as XML, not JavaScript. Does it consider tags? If so, why it doesn't place tag at the first place for detection?

share|improve this question

marked as duplicate by Martijn Pieters, Bo Persson, Lance Roberts, hims056, lunboks Feb 14 '13 at 18:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
It didn't detect the language at all. –  Martijn Pieters Feb 14 '13 at 16:29

1 Answer 1

up vote 4 down vote accepted

The question is tagged as XML and and JavaScript, at which point the highlighter cops out; it won't force a choice on you.

Add a language hint:

<!-- language: lang-js -->

    ... js code block ...

to specify it manually.

From the Formatting FAQ:

Prettify is used to add colour to the code, but only if the language can be uniquely determined given the tags of the question, or if manual hints have been provided

Emphasis mine.

share|improve this answer
    
Ah yeah. I have already added this assumption to the question. But why it does not consider JavaScript as a first tag then? –  VisioN Feb 14 '13 at 16:25
    
The JS tag might be more popular than XML when it comes to tagging, that does not mean that you can infer from that what code you posted. Because the language cannot be determined uniquely, it doesn't make a choice at all. –  Martijn Pieters Feb 14 '13 at 16:27
    
In the face of ambiguity, refuse the temptation to guess -- Tim Peters, The Zen of Python. –  Martijn Pieters Feb 14 '13 at 16:28
    
Alright. Thanks a lot! –  VisioN Feb 14 '13 at 16:29

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