20

Does the explicit language formatting tag have a none option? For a question I'm writing, I'm trying to ASCII out a directory structure, but it keeps getting colored weirdly.

If there is not a <!-- language: none --> would other people find this useful?

To be clear, it would still display as a code block, but no syntax coloring would be applied to the code in the block.

2 Answers 2

19

Two options:

You can pre tag it:

foo
bar

The above text is:

<pre>
foo
bar
</pre>

Or you can language hint it for none, though that is lang-none (as opposed to lang-java and the like). The full set of language hints can be seen at What is syntax highlighting and how does it work? over on MSE.

foo
bar

And that bit is:

<!-- language: lang-none -->

    foo
    bar

5
  • Bookmarking that link! I knew that page was somewhere, but I couldn't find it at all.
    – JamesENL
    Commented Sep 25, 2014 at 3:37
  • 3
    The keyword none does work too.
    – animuson StaffMod
    Commented Sep 25, 2014 at 3:38
  • Hmm, I tried none, and it still coloured numbers, and key words.
    – JamesENL
    Commented Sep 25, 2014 at 3:44
  • Does none work properly in not highlighting C code (the default language)? Commented Jun 27, 2018 at 1:37
  • Using <pre> tags worked for me. The <!-- language: lang-none --> solution didn't work (words appeared still coloured) Commented Feb 26, 2020 at 14:04
7

Update: Use three-backticks plus none

The Answer by user289086 is correct. But since the time that was authored, Stack Exchange has added another formatting code: three backticks (`) on their own line above and below your code. With this approach there is no need to indent your lines of code four spaces.

This new "three-tick" syntax (also known as "code fences", discussed here) on the first line can optionally be followed by the short name of your desired format. For example java, or in your case here, none.

Here is an example:

When run:

```none
INFO - Method `launch` running at 2020-06-28T04:16:17.742443Z
Running Wine report. Now: 2020-06-28T04:16:20.786653Z
Running Tools report. Now: 2020-06-28T04:16:30.787891Z
Running Appliance report. Now: 2020-06-28T04:16:40.791585Z
Running Wine report. Now: 2020-06-28T04:16:50.796355Z
Running Fruit report. Now: 2020-06-28T04:17:00.800407Z
Running Appliance report. Now: 2020-06-28T04:17:10.805166Z
INFO - Method `shutdown` running at 2020-06-28T04:17:17.783938Z
```

Let's complicate that a bit…

That content appears to the reader like this:

When run:

INFO - Method `launch` running at 2020-06-28T04:16:17.742443Z
Running Wine report. Now: 2020-06-28T04:16:20.786653Z
Running Tools report. Now: 2020-06-28T04:16:30.787891Z
Running Appliance report. Now: 2020-06-28T04:16:40.791585Z
Running Wine report. Now: 2020-06-28T04:16:50.796355Z
Running Fruit report. Now: 2020-06-28T04:17:00.800407Z
Running Appliance report. Now: 2020-06-28T04:17:10.805166Z
INFO - Method `shutdown` running at 2020-06-28T04:17:17.783938Z

Let's complicate that a bit…

You must log in to answer this question.

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