Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 158 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

Something in the following JavaSript code block seems to be confusing the syntax highlitgher:

var data = JSON.parse(jsonstr); //parse the JSON to a JS object
var ids = [];

for(var i=0; i<data.length; i++){

   //loop over the array and if the id is defined add it
   if(typeof data[i].id !== "undefined"){

It's getting rendered like this:

enter image description here

The problem persists even after manually forcing the language with <!-- language: lang-js-->. It's working just fine for other answers to the same question.

What's wrong? Is it something on the code, or an issue with the highlighter script? The answer in question can be found here.

share|improve this question
up vote 3 down vote accepted

You forgot to include a space in the language hint:

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

instead of:

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

I fixed that for you.

The post had several conflicting tags (mainly ruby vs. javascript) so the hint was required to prevent the prettifier from making the wrong guess.

share|improve this answer
Oh god. Stupid me. Sorry. – bfavaretto Mar 13 '13 at 13:55
@bfavaretto: NP, don't feel sorry! You tried to help, and it was an easy mistake to make. :-) If you stop editing and wait 5 seconds, the prettifier is re-applied, so you can see if your fix worked in the preview window. – Martijn Pieters Mar 13 '13 at 13:59
Thanks. I think I tried with the space earlier, and the preview was still showing the broken highlighting. But I probably was trying stuff too fast. – bfavaretto Mar 13 '13 at 14:26

You must log in to answer this question.

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