13
$\begingroup$

Usually when code is typed in questions/answers color syntax highlighting shows up if the language is specified as follows,

```python
import numpy as np
```

But it doesn't show up for question/answers in this site.

import numpy as np

Also see for example this answer.
Is this feature not enabled here? Shouldn't this be enabled here as this site would contain a lot of code?

$\endgroup$
4
  • 5
    $\begingroup$ Yes, it needs to be enabled; I guess, if your post gets a few more upvotes, one of the CM will do that for us. $\endgroup$ May 1, 2020 at 15:39
  • 1
    $\begingroup$ I believe StackOverflow has this enabled. $\endgroup$ May 1, 2020 at 16:35
  • 1
    $\begingroup$ @NikeDattani All the coding sites have it enabled, and there is code hinting taken from the tags. On Chemistry it can be invoked like shown above, as long as there are not restrictions for beta sites (there shouldn't) this should be easy, -- given it has enough support from the community here. $\endgroup$ May 1, 2020 at 22:12
  • $\begingroup$ @Martin-マーチン thanks for your insight as always. Yes, it was quick for them to enable MathJax, so perhaps the same might be true for color. It is the weekend though. Let's see! $\endgroup$ May 1, 2020 at 22:15

2 Answers 2

9
$\begingroup$

I enabled syntax highlighting for y'all on the main site. Once moderators are appointed, they'll be able to set up a default language to use for code blocks in questions/answers in specific tags. (Until then, feel free to ping me in the comments and I can take care of it.)

For all tags that don't have a language preference set, the highlighter will do its best to guess unless the code block itself provides a language hint like in the example in your request.

More (gory) details on how the highlighter works can be found here on Meta Stack Exchange.

Enjoy, and please let me know if there are any issues.

$\endgroup$
3
$\begingroup$

As the comments by myself and at least one other are in favor of this, and the question has 7 upvotes and 0 dowvotes, I would like to bump this up (especially since the request for the "cite" button came much later, but that was already sorted out some days ago!).

The question provides an example where this feature would be useful, but one has to click on a link to see it. I am showing it here more explicitly: This excellent answer would look even better with the syntax highlighting:

enter image description here

$\endgroup$

You must log in to answer this question.

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