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

For some reason, my code highlighting works when I'm editing the question, but not in my actual post.

screenshot

(I've tried giving it a hint; no difference.)

Is this a bug?

share|improve this question

2 Answers 2

The question does not have any tags that designate which rules to highlight the code. See Changes to syntax highlighting for more information.

In that case, it would be a good idea to put a language hint for your code instead. I don't know what would apply to so perhaps you should use the default rules.

Just put in <!-- language: lang-default --> before your code block to override it.

Note that d or lang-d is currently not a supported language.

share|improve this answer
    
That's what I meant when I said I tried giving it a hint. But the last sentence seems to explain it... –  Mehrdad May 24 '11 at 0:54
    
@Mehrdad: I was trying to keep the answer as general as I could just in case other people were not aware of these features. –  Jeff Mercado May 24 '11 at 0:56

Specifying a language hint definitely works. I tried adding the hint for C to the D code, and the result looks just like the edit preview shown in the screenshot. I say it's probably close enough.

The reason it "works" in the edit preview is that it's performing a best-guess highlight. It looks to me like it's best guess is C, which makes sense here. Once you submit the answer, it uses the question tags to determine the highlighting that is applied.

If you are really interested in getting syntax highlighting for D code, you'll need to either submit a bug to Google's Code Prettify project and wait for them to add it, or submit a patch yourself. More information is available in my answer here: Why is there no syntax highlight for SQL merge statements?

share|improve this answer

You must log in to answer this question.

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