2
$\begingroup$

Would it be possible to enable syntax highlighting (colour) for code blocks on the Mathematics site?

Example from the Stack Overflow site:

Syntax highlighting

$\endgroup$
11
  • $\begingroup$ You mean like the highlight one uses on pdf text documents ? $\endgroup$
    – user486983
    Feb 14 '20 at 14:22
  • $\begingroup$ @Isabella I mean for code blocks. $\endgroup$
    – Maggyero
    Feb 14 '20 at 14:32
  • $\begingroup$ ah. I was not aware that math.stack had code blocks. Anyway I'd suggest to add the tags feature request $\endgroup$
    – user486983
    Feb 14 '20 at 14:42
  • 1
    $\begingroup$ @Isabella Done. $\endgroup$
    – Maggyero
    Feb 14 '20 at 14:47
  • 1
    $\begingroup$ I suppose that some users around here (including me) are not really familiar with the way syntax highlighting works on Stack Exchange sites. It might be good to give some pointers to basic info - I was able to find some links in the corresponding tag-info on Meta Stack Exchange. $\endgroup$ Feb 14 '20 at 15:01
  • 6
    $\begingroup$ If you're posting any substantial amount of code then your question is probably off-topic. $\endgroup$ Feb 14 '20 at 16:25
  • 1
    $\begingroup$ To help other confused readers: This image is an example of syntax highlighting d33wubrfki0l68.cloudfront.net/… $\endgroup$
    – s.harp
    Feb 14 '20 at 16:39
  • $\begingroup$ @MartinSleziak I have updated the post. $\endgroup$
    – Maggyero
    Feb 14 '20 at 17:22
  • 4
    $\begingroup$ It would be helpful to have your thoughts on how syntax highlighting would contribute to the site. I suspect the posts at Math.SE will mainly involve pseudo-code rather than compiler parseable code specific to a programming language, but I'll try to quantify this impression. $\endgroup$
    – hardmath
    Feb 14 '20 at 18:48
  • 3
    $\begingroup$ There are some instances where non-pseudocode code fits in on MSE, though, for example in computer-algebra-systems, computational-mathematics, gap, magma-cas, etc. $\endgroup$
    – Alexander Gruber Mod
    Feb 14 '20 at 19:59
  • 1
    $\begingroup$ @hardmath I am just talking from my experience as a user. I was disappointed to see that the program in my post was in black and white here. $\endgroup$
    – Maggyero
    Feb 14 '20 at 23:30
4
$\begingroup$

Quoting former staff member @Oded:

We do not usually turn it on for sites that do not have a majority of posts with code in them (Lego, cooking, RPG are examples of such sites). Security tends to have more prose than code - hence, it isn't turned on.

The reason for this is that turning it on means including more JavaScript and slows everything down - performance matters to us.

Now, one could argue that MathJax is already ~1 MB or so (if I interpreted my browser tools correctly), which makes the 573 kB of Highlight.js less of a problem. (Yes, your browser caches those files; it's not 1.5 MB per page visit. Still, if you're on a slow 2G/3G connection ...)

$\endgroup$
1
  • 1
    $\begingroup$ There's a cooking site with a lot of code? $\endgroup$ Jun 22 at 11:00

You must log in to answer this question.

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