Skip to content

Commit 1247530

Browse files
committed
Update code blocks style guide
1 parent 194524b commit 1247530

File tree

1 file changed

+31
-21
lines changed

1 file changed

+31
-21
lines changed

docs/contributing/index.md

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -236,38 +236,48 @@ The documentation uses [pygments](https://pygments.org) for highlighting.
236236
See [list of available lexers](https://pygments.org/docs/lexers/#) for the languages that you can use for code blocks.
237237

238238
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-
````
245239

246-
The above becomes:
240+
=== "Markdown"
247241

248-
```console title="Hello, world!"
249-
$ echo "Hello, world!"
250-
Hello, world!
251-
```
242+
````markdown
243+
```console title="Hello, world!"
244+
$ echo "Hello, world!"
245+
Hello, world!
246+
```
247+
````
248+
249+
=== "Rendered"
250+
251+
```console title="Hello, world!"
252+
$ echo "Hello, world!"
253+
Hello, world!
254+
```
252255

253256
!!! warning
254257
`terminal` is not a valid lexer, but MkDocs or pygments will not warn about using it as a language.
255258
The text will be rendered without highlighting.
256259

260+
!!! warning
261+
Use `$` as the prompt character, optionally preceded by text.
262+
`>` as the prompt character will not be highlighted correctly.
263+
257264
Note the use of `title=...`, which will give the code block a heading.
258265

259266
!!! tip
260267
Include a title whenever possible to describe what the code block does or is.
261268

262-
If you want to display commands without that can easily be copied, use `bash` as the language.
263-
````markdown
264-
```bash title="Hello, world!"
265-
echo "Hello, world!"
266-
```
267-
````
269+
If you want to display commands without output that can easily be copied, use `bash` as the language:
268270

269-
The above becomes:
271+
=== "Markdown"
270272

271-
```bash title="Hello, world!"
272-
echo "Hello, world!"
273-
```
273+
````markdown
274+
```bash title="Hello, world!"
275+
echo "Hello, world!"
276+
```
277+
````
278+
279+
=== "Rendered"
280+
281+
```bash title="Hello, world!"
282+
echo "Hello, world!"
283+
```

0 commit comments

Comments
 (0)