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

While browsing StackOverflow, I stumbled onto this question, and noticed that the syntax highlighting was off, even though the code in the question was formatted properly and the question was properly tagged.

Are there some (edge?) cases where the syntax highlighting will not work?

Also, the highlighting in answers to that question doesn't work as well.

share|improve this question
    
I've added the <!-- language: lang-python --> at the start of the code block and it seems to have sorted it. Sorry if this cancels your bug report :) You can still see the problem in the revisions though... –  Lix Jul 25 '12 at 7:21
    
Actually, in the revisions, the code is correctly highlighted. I'm not saying there wasn't a problem before you inserted the language hint, just that you can no longer see it now. –  Martijn Pieters Jul 25 '12 at 7:26
    
Ah, no, I see it now. It's being highlighted as SQL instead of python. –  Martijn Pieters Jul 25 '12 at 7:28

1 Answer 1

up vote 3 down vote accepted

There are two tags on that question that have language hints associated with them: and . The latter won in this case and the code was highlighted as SQL. See Changes to syntax highlighting on how tags dictate language hints for syntax highlighting.

The correct way to fix it is to insert an explicit language hint, which Lix already did. See How do I format my code blocks?

share|improve this answer
    
Is there a list of tag-to-implicit-highlighting-hint? –  nhahtdh Jul 25 '12 at 7:31
    
Heh, it's funny that the database tag won the syntax highlighting, but that the python tag won when computing the page title. :) –  Joachim Pileborg Jul 25 '12 at 7:31
    
@nhahtdh: I added a link to the original post on syntax highlighting on SE sites. –  Martijn Pieters Jul 25 '12 at 7:35
    
@MartijnPieters: I have a feeling that it is outdated. –  nhahtdh Jul 25 '12 at 7:38
    
The interesting thing is that according to Jeff's original post on syntax highlighting it's prettify that made this decision; two tags with language hints means that SE let's prettify decide instead of setting a language, apparently. –  Martijn Pieters Jul 25 '12 at 7:38
    
@nhahtdh: moderators can attach a language hint to tags, but there is no public list. –  Martijn Pieters Jul 25 '12 at 7:39
    
@MartijnPieters: Shouldn't it be made public? Even just for the purpose of referencing? –  nhahtdh Jul 25 '12 at 7:43
    
@nhahtdh: Open a feature request question here on meta and see if people agree. –  Martijn Pieters Jul 25 '12 at 7:48
    
@MartijnPieters: OK. Probably later. Kinda low on energy right now and I don't want to write a crappy question. –  nhahtdh Jul 25 '12 at 7:52

You must log in to answer this question.

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