4

I was editing a question on Mathematics that included Python code and tried to add a Prettify hint:

 <!-- language: lang-python -->

...but it did not have a highlighting effect.

So I guess syntax highlighting is limited to the code-related SE sites, but in cases like the above where example code crops up elsewhere it would be quite helpful. Is there a reason the feature is not included elsewhere?

2
  • 1
    math.se already has to load Mathjax, which is quite heavy. I assume that loading Prettify as well would slow it down too much for very little actual benefit. Mar 5, 2014 at 12:37
  • I would guess not an Mathematics; the <pre> tag wrapping the code block is not marked with highlighting classes. Mar 5, 2014 at 12:40

1 Answer 1

5

We have code highlighting on for sites that are code heavy (Stack Overflow, Programmers, Game Dev to name a few). It makes sense to do this.

However, this comes at a cost - an additional processing time, an extra JavaScript file to parse through and execute as well as a client side delay while the highlighting code processes the page.

Having this overhead for sites that where the very vast majority of the posts will not benefit from it is the reason it is not enabled on most sites.

2
  • 1
    That makes sense. I guess there wouldn't be a cheap/costless way to only load highlighting when explicit Prettify hints are included in a post? Mar 5, 2014 at 12:45
  • @pianoman - costless? Never. It would always have a cost. As for cheaply? This would have to be implemented first - and an async operation loading the JS and then prettifying would not be the best user experience.
    – Oded
    Mar 5, 2014 at 12:47

You must log in to answer this question.

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