7

When viewing my post in edit mode, the code blocks do not have syntax highlighting, even after waiting for a while first. After submitting it, the post does have syntax highlighting.

I can also get the syntax highlighting to update in edit mode if I explicitly add the <!-- language: lang-c# --> before the code block, but without it will never update with highlighting.

Is this considered as a bug? Sometimes I take some time to find why the code is not being syntax highlighting and I find it difficult to reviewing my code blocks in edit mode without it.

Update: Syntax highlighting seems to work in the preview when I modify an already-posted post in just about any way {1(C#), 2}, but for new posts it just refuses to work unless given a language hint.

7
  • There is a delay, this is not a bug. Mar 4, 2014 at 16:50
  • No,this is not a delay because I take more than half hour for writing the post and it never has syntax highlighting in that period in edit mode,or you can try to go inside edit mode of that post and see whether it will show you the syntax highlighting,thanks
    – V-SHY
    Mar 4, 2014 at 17:00
  • Ah, indeed, this is a regression. It should work the way I described, but it is currently b0rken. Mar 4, 2014 at 17:02
  • Ya, it might be caused by having very long line in the code sample.
    – V-SHY
    Mar 4, 2014 at 17:07
  • 2
    No, I confirmed the problem with other posts. Mar 4, 2014 at 17:07
  • meta.stackexchange.com/a/229511/115866
    – balpha StaffMod
    Apr 15, 2014 at 7:00
  • Waiting for next build:-)
    – V-SHY
    Apr 15, 2014 at 7:18

1 Answer 1

3

I can confirm this problem.

What seems to be happening is that (in the absence of explicit <!-- language: foo --> hints) the syntax highlighting is based on the tags: to know that your code is C# and should be highlighted as such, the question needs to be tagged with (or some other tag associated with that language).

However, until you've actually posted the question, it doesn't really have any fixed tags. Yes, there's a box at the bottom of the edit form where you can select some tags to apply to the question when you post it, but the syntax highlighter doesn't seem to pay any attention it — it only cares about the tags the question already had before you started editing it.

Arguably, the syntax highlighting rules should change whenever the tag list is changed in the tag editor box. If so, this is a bug / missing feature.

1
  • It used to work just fine; but Balpha fixed it again. Apr 15, 2014 at 7:02

You must log in to answer this question.

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