You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/contributing/index.md
+43Lines changed: 43 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -228,3 +228,46 @@ They stand out better from the main text, and can be collapsed by default if nee
228
228
This note is collapsed, because it uses `???`.
229
229
230
230
If an admonition is collapsed by default, it should have a title.
231
+
232
+
### Code blocks
233
+
234
+
Use [code blocks](https://squidfunk.github.io/mkdocs-material/reference/code-blocks/) when you want to display monospace text in a programming language, terminal output, configuration files etc.
235
+
The documentation uses [pygments](https://pygments.org) for highlighting.
236
+
See [list of available lexers](https://pygments.org/docs/lexers/#) for the languages that you can use for code blocks.
237
+
238
+
Use [`console`](https://pygments.org/docs/lexers/#pygments.lexers.shell.BashSessionLexer) for interactive sessions with prompt-output pairs:
239
+
````markdown
240
+
```console title="Hello, world!"
241
+
$ echo "Hello, world!"
242
+
Hello, world!
243
+
```
244
+
````
245
+
246
+
The above becomes:
247
+
248
+
```console title="Hello, world!"
249
+
$ echo"Hello, world!"
250
+
Hello, world!
251
+
```
252
+
253
+
!!! warning
254
+
`terminal` is not a valid lexer, but MkDocs or pygments will not warn about using it as a language.
255
+
The text will be rendered without highlighting.
256
+
257
+
Note the use of `title=...`, which will give the code block a heading.
258
+
259
+
!!! tip
260
+
Include a title whenever possible to describe what the code block does or is.
261
+
262
+
If you want to display commands without that can easily be copied, use `bash` as the language.
0 commit comments