1

Possible Duplicate:
Python's “//” operator wrongly treated as a comment (part 2)

I just noticed it in the first revision of this answer, and after a quick search here on meta it turned out the question has been already asked a while ago. However, I didn't quite understand what the consensus was. The tag as I see it means nothing needs to be done, but in this case it must mean something else (maybe that it can be sorted out by SO mods or something), because clearly something should be done. From the linked question I understand that there are cases when the syntax highlighting can work incorrectly if multiple languages are used without explicit specification, but I suppose the defaults should at least work if Python is the only language used in the post and there are no misleading tags, like in the shown recent example. Can someone elaborate on the situation?

I must add that not only '//' is treated as a beginning of a comment, but also #define is processed in a wrong way, the rest of the comment being highlighted.

  • 1
    Did you read the answer to that question you linked? – animuson Mar 24 '12 at 19:52
  • @animuson Sure, but I confess I could not understand it. It says, "code blocks tend to be mixed with javascript blocks, html blocks, etcetera", but how does it mean that python syntax highlighting shouldn't work right? There is only one code block and only one language tag. The default case, you know. – Lev Levitsky Mar 24 '12 at 20:01
  • Ah, now thanks to @Jeremy I see that it really can be dealt with by specifying the language explicitly. But I still don't really get it, I thought it was derived from the tags? What prevented the highlighting engine from extracting that info? @Jeremy just put language: lang-py in there, right? – Lev Levitsky Mar 24 '12 at 20:07
  • @LevLevitsky I think Jeff's reasoning is that because Python is often used on the web, there's a decent chance that people will include HTML code in posts only tagged python, so the tag uses the "default" highlighting that does a decent job with HTML and Python in most cases. I often specify highlighting manually so I don't need to worry about this. – Jeremy Banks Mar 24 '12 at 20:11
  • @LevLevitsky Please see Syntax highlighting language hints for information about how to specify the highlighting you want. – Jeremy Banks Mar 24 '12 at 20:14
  • Thanks @JeremyBanks, it's a bit clearer now. Yet, my personal opinion is that one shouldn't have to specify the language in such cases; rather, they should do it if they use more than one language in the post. Isn't it logical? I mean, I'm subscribed to the python tag and at least in ~90% of the cases there is no XML or anything except Python in the posts. – Lev Levitsky Mar 24 '12 at 20:21
  • Ooh, there was a "Part 2"... sorry, missed it. – Lev Levitsky Mar 25 '12 at 10:17

Browse other questions tagged .