@@ -206,6 +206,61 @@ import tensorflow as tf
206206
207207 [17] : https://pygments.org/docs/lexers/
208208
209+ # ## Adding annotations
210+
211+ [:octicons-file-code-24 : Source][18] ·
212+ :octicons-beaker-24 : Experimental ·
213+ [:octicons-heart-fill-24:{ : .mdx-heart } Insiders only][18]{: .mdx-insiders }
214+
215+ Annotations offer a comfortable and friendly way to attach explanations to
216+ arbitrary sections of code blocks by adding simple markers within block/inline
217+ comments that refer to items of a list following the code block, i.e. `(1)`,
218+ ` (2)` , etc. Material for MkDocs removes the list from the flow of the document,
219+ injects the content of each list item into a tooltip, and links each list marker
220+ to the corresponding tooltip.
221+
222+ In order to opt-in to annotation support, a slightly different syntax is
223+ required – just add the respective [language short code][17] and the `.annotate`
224+ class, after the three backticks.
225+
226+ _Example_ :
227+
228+ ` ` ` ` markdown
229+ ``` { : .js .annotate }
230+ document$.subscribe(function() { // (1)
231+ var tables = document.querySelectorAll(/* (2) */ "article table")
232+ tables.forEach(function(table) {
233+ new Tablesort(table)
234+ })
235+ })
236+ ```
237+
238+ 1 . ...
239+ 2 . ...
240+ ````
241+
242+ _Result_:
243+
244+ <figure markdown="1">
245+
246+ [![Annotations][19]][19]
247+
248+ <figcaption markdown="1">
249+
250+ A demo is worth a thousand words — check it out at
251+ [squidfunk.github.io/mkdocs-material-insiders][20]
252+
253+ </figcaption>
254+ </figure>
255+
256+ _Annotations require syntax highlighting with [Pygments][24] – they're currently
257+ not compatible with other JavaScript-based syntax highlighters. Support may be
258+ added later on._
259+
260+ [18]: ../insiders.md
261+ [19]: ../assets/screenshots/annotations.png
262+ [20]: https://squidfunk.github.io/mkdocs-material-insiders/reference/code-blocks/#adding-annotations
263+
209264### Adding line numbers
210265
211266Line numbers can be added to a code block by using the `linenums="<start>"`
@@ -265,7 +320,7 @@ def bubble_sort(items):
265320
266321### Highlighting inline code blocks
267322
268- When [InlineHilite][18 ] is enabled, inline code blocks can be highlighted by
323+ When [ InlineHilite] [ 21 ] is enabled, inline code blocks can be highlighted by
269324prefixing them with a shebang-like sequence, i.e. ` #! ` , directly followed by
270325the [ language short name] [ 17 ] .
271326
@@ -279,11 +334,11 @@ _Result_:
279334
280335The ` #!python range() ` function is used to generate a sequence of numbers.
281336
282- [ 18 ] : #inlinehilite
337+ [ 21 ] : #inlinehilite
283338
284339### Adding keyboard keys
285340
286- When [ Keys] [ 19 ] is enabled, keyboard keys can be rendered with a simple syntax.
341+ When [ Keys] [ 22 ] is enabled, keyboard keys can be rendered with a simple syntax.
287342Consult the [ Python Markdown Extensions] [ 16 ] documentation to learn about all
288343available key codes.
289344
@@ -297,13 +352,13 @@ _Result_:
297352
298353++ctrl+alt+del++
299354
300- [ 19 ] : #keys
355+ [ 22 ] : #keys
301356
302357### Embedding external files
303358
304- _ Also known as transcludes or file transclusion in [ MultiMarkdown] [ 20 ] _ .
359+ _ Also known as transcludes or file transclusion in [ MultiMarkdown] [ 23 ] _ .
305360
306- When [ Snippets] [ 21 ] is enabled, content from other files can be embedded, which
361+ When [ Snippets] [ 24 ] is enabled, content from other files can be embedded, which
307362is especially useful to reference and embed the contents of source files
308363directly into your project documentation.
309364
@@ -321,23 +376,23 @@ _Result_:
321376last 4 years
322377```
323378
324- Note that [ Snippets] [ 21 ] is not limited to code blocks, but can be used anywhere
379+ Note that [ Snippets] [ 24 ] is not limited to code blocks, but can be used anywhere
325380from a document to move repeating content to separate files, which is also
326381explained in the [ official documentation] [ 16 ] .
327382
328- [ 20 ] : https://fletcher.github.io/MultiMarkdown-5/transclusion.html
329- [ 21 ] : #snippets
383+ [ 23 ] : https://fletcher.github.io/MultiMarkdown-5/transclusion.html
384+ [ 24 ] : #snippets
330385
331386## Customization
332387
333388### Custom syntax theme
334389
335- [ :octicons-file-code-24: Source] [ 22 ] ·
390+ [ :octicons-file-code-24: Source] [ 25 ] ·
336391:octicons-mortar-board-24: Difficulty: _ easy_
337392
338- If [ Pygments] [ 23 ] is used, Material for MkDocs provides the [ styles for code
339- blocks] [ 22 ] , which are built with a custom and well-balanced palette that works
340- equally well for both [ color schemes] [ 24 ] :
393+ If [ Pygments] [ 26 ] is used, Material for MkDocs provides the [ styles for code
394+ blocks] [ 25 ] , which are built with a custom and well-balanced palette that works
395+ equally well for both [ color schemes] [ 27 ] :
341396
342397- :material-checkbox-blank-circle:{: style="color: var(--md-code-hl-number-color) " } ` --md-code-hl-number-color `
343398- :material-checkbox-blank-circle:{: style="color: var(--md-code-hl-special-color) " } ` --md-code-hl-special-color `
@@ -359,7 +414,7 @@ Code block foreground, background and line highlight colors are defined via:
359414- :material-checkbox-blank-circle:{: style="color: var(--md-code-hl-color) " } ` --md-code-hl-color `
360415
361416Let's say you want to change the color of ` #!js "strings" ` . While there are
362- several [ types of string tokens] [ 25 ] , Material for MkDocs assigns a single color
417+ several [ types of string tokens] [ 28 ] , Material for MkDocs assigns a single color
363418to most of them.
364419
365420Create an [ additional stylesheet] [ 6 ] , and add:
@@ -371,7 +426,7 @@ Create an [additional stylesheet][6], and add:
371426```
372427
373428If you want to tweak a specific type of string, i.e. `` #!js `backticks` `` , you
374- can lookup the specific class name in the [ syntax theme definition] [ 26 ] , and
429+ can lookup the specific class name in the [ syntax theme definition] [ 29 ] , and
375430override it as part of your additional stylesheet:
376431
377432``` css
@@ -380,8 +435,8 @@ override it as part of your additional stylesheet:
380435}
381436```
382437
383- [ 22 ] : https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/stylesheets/main/_colors.scss#
384- [ 23 ] : #use-pygments
385- [ 24 ] : ../setup/changing-the-colors.md#color-scheme
386- [ 25 ] : https://pygments.org/docs/tokens/#literals
387- [ 26 ] : https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/stylesheets/main/extensions/markdown/_codehilite.scss
438+ [ 25 ] : https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/stylesheets/main/_colors.scss#
439+ [ 26 ] : #use-pygments
440+ [ 27 ] : ../setup/changing-the-colors.md#color-scheme
441+ [ 28 ] : https://pygments.org/docs/tokens/#literals
442+ [ 29 ] : https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/stylesheets/main/extensions/markdown/_codehilite.scss
0 commit comments