5

Easy question, I'm sure (and apologies if it's a dupe), but is there a way to turn off colorization in code fragments? Perhaps by explicitly tagging the code as being in a specific language? That is, over on SO under the [c] tag, if I write

Coca Cola 100

I see Coca Cola in blue, and 100 in red. How do I turn this off?

See this answer for context.

(And where's the documentation on SO's markup format? I think I've seen it somewhere, but I can't find it anywhere on the Help Center just now.)

3
  • <!-- language: lang-none --> turns off syntax highlighting
    – Erik A
    Jun 15, 2018 at 13:48
  • 2
    Or, if it's not code, don't format it as code... Jun 15, 2018 at 15:47
  • 1
    It is possible to set code formatting langauge like this as well: ```lang-none Coca Cola 100 ``` ref.: meta.stackexchange.com/a/184109 Jun 24, 2022 at 13:35

1 Answer 1

8

You can force the language of a code block by using <!-- language: lang-<language> --> html comment.

If you need to disable syntax color, use <!-- language: lang-none -->

Revision:https://stackoverflow.com/posts/50875495/revisions

As @Erik von Asmuth mentioned, <!-- language-all: lang-none --> can be used for multiple code blocks in the post.

6
  • 1
    <!-- language-all: lang-none --> would've saved you some work on that revision
    – Erik A
    Jun 15, 2018 at 13:50
  • Thanks, and thanks for editing the answer. I still would have had trouble, because I wouldn't have known exactly where to put the HTML comment, whether it had to be indented along with the code, etc. Jun 15, 2018 at 14:02
  • It should be a line above the code block without indentation. @SteveSummit
    – Suraj Rao
    Jun 15, 2018 at 14:03
  • @SurajRao Got it, and now I've finally chased the link to the FAQ post that explains this and has examples. Jun 15, 2018 at 14:06
  • Could you specify WHERE to put this tag? When using triple-backtick-notation and putting it directly after the first three backticks it doesn't seem to have any effect in my post Where exactly do you put this tag when using triple-backtick-notation? I've got a piece of text words like 'is' are colorized due to involuntary syntax highlighting. Tried putting this tag directly after the first three backticks. Did not help. The post in question: stackoverflow.com/questions/1795109/… Sep 12, 2021 at 14:47
  • @Drkawashima might be an issue with the new syntax highlighter. Could be related to this bug. The old way still works. I have edited your post using that
    – Suraj Rao
    Sep 12, 2021 at 14:54

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