For data, input text, output text, and errors, use code formatting with no syntax highlighting. Syntax highlighting is only intended for use on the specific code language which it's highlighting. If the syntax highlighting language being used isn't correct for any particular code block, then you should add syntax highlighting hints to have the text correctly highlighted (including removing syntax highlighting where it's not appropriate).
Some people suggest using other markdown-formatting styles, in particular quote formatting. IMO, using other formatting types can lead to confusion. For instance, quote format removes line-breaks, both in how it's displayed and how it's stored in the post's source. Removing line-breaks can result in not actually representing the output which is being performed by the code, or make error-text hard to read.
Ideally, there would be another formatting style that provides a monospaced font and preformatted text. Unfortunately, there's only code format. So, for code, data (input and output), and errors put them in code format, but clearly label them.
How to apply no syntax highlighting to a code block
You will need to add a syntax highlighting hint to have the text correctly highlighted with the appropriate language. In this case, that is lang-none
.
Using code fences (current recommended method)
Use code fences to add the syntax highlighting hint at the start of the code block.
Example Markdown text (code fences)
```lang-none
Your text (errors, data, input, output, etc.)
```
Results in
Your text (errors, data, input, output, etc.)
Use a <!-- language: lang-none -->
HTML comment to apply the syntax highlighting hint to the immediately following code block.
Using an HTML comment based language hint is deprecated, but still functional for all methods of displaying text in a code block.
Put/leave the errors/data/input/output in code format (using any of A) code fences, B) 4 space indent, or C) wrapped in HTML <pre><code>
) and, on a separate line prior to the that code block (and for 4 space indent with a blank line between the comment and the code), just add:
<!-- language: none -->
Example Markdown text (code fences)
<!-- language: none -->
```
Your text (errors, data, input, output, etc.)
```
Results in
Your text (errors, data, input, output, etc.)
Example Markdown text (4 space indent)
<!-- language: none -->
Your text (errors, data, input, output, etc.)
Results in
Your text (errors, data, input, output, etc.)
Example Markdown text (<pre><code>
)
<!-- language: none -->
<pre><code>Your text (errors, data, input, output, etc.)</pre></code>
Results in
Your text (errors, data, input, output, etc.)
Example code block without specifying lang-none
(to verify there is a difference)
Your text (errors, data, input, output, etc.)
Testing to verify that the HTML comment based syntax highlighting hint was still working was performed in this answer to: Formatting Sandbox.
>
instead of four spaces at the beginning of a line.code:
in search.