@@ -25,6 +25,10 @@ markdown_extensions:
25
25
- pymdownx.snippets
26
26
` ` `
27
27
28
+ The following sections discuss how to use different syntax highlighting features
29
+ with [Pygments], the recommended highlighter, so they don't apply when using a
30
+ JavaScript syntax highlighter.
31
+
28
32
See additional configuration options:
29
33
30
34
- [Highlight]
@@ -79,12 +83,6 @@ theme:
79
83
80
84
# # Usage
81
85
82
- This section discusses how to use different syntax highlighting features with
83
- [Pygments] – the default highlighter – so they don't apply when using
84
- a JavaScript syntax highlighter.
85
-
86
- # ## Specifying the language
87
-
88
86
Code blocks must be enclosed with two separate lines containing three backticks.
89
87
To add syntax highlighting to those blocks, add the language shortcode directly
90
88
after the opening block. See the [list of available lexers] to find the
@@ -106,6 +104,39 @@ import tensorflow as tf
106
104
107
105
[list of available lexers] : https://pygments.org/docs/lexers/
108
106
107
+ # ## Adding a title
108
+
109
+ [:octicons-tag-24 : 7.3.6][Title support] ·
110
+ :octicons-beaker-24 : Experimental
111
+
112
+ In order to provide additional context, a custom title can be added to a code
113
+ block by using the `title="<custom title>"` option directly after the shortcode,
114
+ e.g. to display the name of a file :
115
+
116
+ _Example_ :
117
+
118
+ ` ` ` ` markdown
119
+ ` ` ` py title="bubble_sort.py"
120
+ def bubble_sort(items):
121
+ for i in range(len(items)):
122
+ for j in range(len(items) - 1 - i):
123
+ if items[j] > items[j + 1]:
124
+ items[j], items[j + 1] = items[j + 1], items[j]
125
+ ` ` `
126
+ ````
127
+
128
+ _Result_ :
129
+
130
+ ` ` ` py title="bubble_sort.py"
131
+ def bubble_sort(items):
132
+ for i in range(len(items)):
133
+ for j in range(len(items) - 1 - i):
134
+ if items[j] > items[j + 1]:
135
+ items[j], items[j + 1] = items[j + 1], items[j]
136
+ ` ` `
137
+
138
+ [Title support] : https://github.com/squidfunk/mkdocs-material/releases/tag/7.3.6
139
+
109
140
# ## Adding annotations
110
141
111
142
Code annotations can be placed anywhere in a code block where a comment for the
@@ -253,14 +284,14 @@ from within a code block:
253
284
_ Example_ :
254
285
255
286
```` markdown
256
- ```
287
+ ``` title=".browserslistrc"
257
288
--8<-- ".browserslistrc"
258
289
```
259
290
````
260
291
261
292
_ Result_ :
262
293
263
- ```
294
+ ``` title=".browserslistrc"
264
295
last 4 years
265
296
```
266
297
0 commit comments