Skip to content

Commit d7894a3

Browse files
Documented the use of line ranges in hl_lines (#2903)
Co-authored-by: Vedran Miletić <[email protected]>
1 parent b7e5b3d commit d7894a3

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

docs/reference/code-blocks.md

+24
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,30 @@ def bubble_sort(items):
368368
items[j], items[j + 1] = items[j + 1], items[j]
369369
```
370370

371+
Line ranges can also be used for conveniently specifying multiple lines.
372+
373+
_Example_:
374+
375+
```` markdown
376+
``` python hl_lines="2-5"
377+
def bubble_sort(items):
378+
for i in range(len(items)):
379+
for j in range(len(items) - 1 - i):
380+
if items[j] > items[j + 1]:
381+
items[j], items[j + 1] = items[j + 1], items[j]
382+
```
383+
````
384+
385+
_Result_:
386+
387+
``` python hl_lines="2-5"
388+
def bubble_sort(items):
389+
for i in range(len(items)):
390+
for j in range(len(items) - 1 - i):
391+
if items[j] > items[j + 1]:
392+
items[j], items[j + 1] = items[j + 1], items[j]
393+
```
394+
371395
### Highlighting inline code blocks
372396

373397
When [InlineHilite][21] is enabled, inline code blocks can be highlighted by

0 commit comments

Comments
 (0)