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

I think it used to work in the past but now code highlight has no effect on JavaScript whatsover.

jQuery example:

$(document).keypress(function (event) {
    var key = String.fromCharCode(event.which);
    $("#Container li").each(function (index) {
        var text = $(this).text();
        if (text.length > 0 && text.charAt(0).toLowerCase() == key.toLowerCase())
        {
            $("#Container").scrollTop($(this).position().top);
            break;
        }           
    });
});

Pure javascript example:

<script type="text/javascript">
    for (var i = 0; i < 5; i++) {
        alert("hello" + i);
    }
</script>

Has anything changed? Maybe I'm doing something wrong?

share|improve this question
    
Working fine on SO? Like stackoverflow.com/questions/4421786/… But indeed: not here stackoverflow.com/questions/4421540/… –  Arjan Dec 12 '10 at 13:17
    
@Arjan so is this just me? :-/ –  Shadow Wizard Dec 12 '10 at 13:20
1  
I don't think it's just you, I've noticed HTML formatting off the past 2 days as well, something definitely changed...I spent a while yesterday trying to format a post for syntax highlighting for HTML and gave up...when noticed several questions with the same issues - having proper markdown. This question leads me to believe there were changes: meta.stackexchange.com/questions/71856/… not sure if that was the cause or another symptom of some other change. –  Nick Craver Dec 12 '10 at 13:30
    
@Nick thanks for confirming.. hope some mod will jump by and fix it soon. :) –  Shadow Wizard Dec 12 '10 at 13:38
    
@Shadow - tagged it syntax-highlighting as well, hopefully it'll get some love –  Nick Craver Dec 12 '10 at 13:41
    
@Shadow, I assume the first link in the comment works for you too, but the 2nd does not? So no, it's not just you, but it depends on the post (or more likely: its content). See also the Formatting Sandbox. –  Arjan Dec 12 '10 at 13:41
    
@Arjan yep first link show the highlight fine. Wonder how this can be reproduced? Going to mess around in the Sandbox.. :) –  Shadow Wizard Dec 12 '10 at 13:47
    
@Shadow, just in case you don't know: the successful highlighting blocks have <pre class="prettyprint">, as used by a JavaScript code prettifier. –  Arjan Dec 12 '10 at 13:57
    
@Arjan cool.. can we add this manually somehow?? –  Shadow Wizard Dec 12 '10 at 14:00
    
Just add class="prettyprint" (like using Firebug, or Chrome's Web Inspector), and then run javascript:prettyPrint() in the location bar. That will indeed make your examples work just fine. It seems the class="prettyprint" is just lacking in the HTML. –  Arjan Dec 12 '10 at 14:02

2 Answers 2

up vote 3 down vote accepted

We are experimenting with prettify language hints based on tags. Expect changes and a subsequent meta post outlining this soon.

share|improve this answer
    
Here is the meta post: meta.stackexchange.com/questions/72082/… –  Jon Seigel Dec 13 '10 at 4:49
    
Cheers, added javascript tag to stackoverflow.com/questions/4421540/… and highlight working as expected. Sweet! :) –  Shadow Wizard Dec 13 '10 at 8:55

Somehow the erroneous blocks are currently rendered like:

<div class="post-text">
  <pre>
    <code>

...rather than

<div class="post-text">
  <pre class="prettyprint">
    <code>

(And the code prettifier needs that class.)

share|improve this answer

You must log in to answer this question.

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