From d7894a3f028bde626274b03b3da96428711047e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vedran=20Mileti=C4=87?= Date: Mon, 2 Aug 2021 14:19:42 +0200 Subject: [PATCH] Documented the use of line ranges in hl_lines (#2903) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Vedran Miletić --- docs/reference/code-blocks.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/reference/code-blocks.md b/docs/reference/code-blocks.md index 16d0dbbbc..ec4c06a25 100644 --- a/docs/reference/code-blocks.md +++ b/docs/reference/code-blocks.md @@ -368,6 +368,30 @@ def bubble_sort(items): items[j], items[j + 1] = items[j + 1], items[j] ``` +Line ranges can also be used for conveniently specifying multiple lines. + +_Example_: + +```` markdown +``` python hl_lines="2-5" +def bubble_sort(items): + for i in range(len(items)): + for j in range(len(items) - 1 - i): + if items[j] > items[j + 1]: + items[j], items[j + 1] = items[j + 1], items[j] +``` +```` + +_Result_: + +``` python hl_lines="2-5" +def bubble_sort(items): + for i in range(len(items)): + for j in range(len(items) - 1 - i): + if items[j] > items[j + 1]: + items[j], items[j + 1] = items[j + 1], items[j] +``` + ### Highlighting inline code blocks When [InlineHilite][21] is enabled, inline code blocks can be highlighted by