Skip to content

Commit 0676ae1

Browse files
committed
Documentation
1 parent 7192639 commit 0676ae1

File tree

2 files changed

+88
-31
lines changed

2 files changed

+88
-31
lines changed

docs/insiders.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ The following features are currently exclusively available to sponsors:
112112

113113
<div class="mdx-columns" markdown="1">
114114

115+
- [x] [Code block annotations :material-new-box:][24]
115116
- [x] [Anchor tracking :material-new-box:][23]
116117
- [x] [Section index pages][21]
117118
- [x] [Latest release tag][15]
@@ -171,18 +172,19 @@ the public for general availability.
171172
#### $ 4,000 – Ghost Pepper
172173

173174
- [x] [Anchor tracking][23]
174-
- [ ] Code block annotations
175+
- [x] [Code block annotations][24]
175176
- [ ] Back-to-top button
176177

177178
[23]: setup/setting-up-navigation.md#anchor-tracking
179+
[24]: reference/code-blocks.md#adding-annotations
178180

179181
#### $ 5,000 – Aji Panca
180182

181-
- [x] [Mermaid.js integration][24]
183+
- [x] [Mermaid.js integration][25]
182184
- [ ] List of last searches
183185
- [ ] Advanced routing for versioning
184186

185-
[24]: reference/diagrams.md
187+
[25]: reference/diagrams.md
186188

187189
#### $ 6,000 – Trinidad Scorpion
188190

@@ -198,10 +200,10 @@ the public for general availability.
198200

199201
#### Future
200202

201-
- [ ] [Material for MkDocs Live Edit][25]
203+
- [ ] [Material for MkDocs Live Edit][26]
202204
- [ ] New layouts and styles
203205

204-
[25]: https://twitter.com/squidfunk/status/1338252230265360391
206+
[26]: https://twitter.com/squidfunk/status/1338252230265360391
205207

206208
### Goals completed
207209

@@ -247,10 +249,10 @@ implemented behind feature flags; all configuration changes are
247249
backward-compatible. This means that your users will be able to build the
248250
documentation locally with Material for MkDocs and when they push their changes,
249251
it can be built with Insiders (e.g. as part of GitHub Actions). Thus, it's
250-
recommended to [install Insiders][26] only in CI, as you don't want to expose
252+
recommended to [install Insiders][27] only in CI, as you don't want to expose
251253
your `GH_TOKEN` to users.
252254

253-
[26]: publishing-your-site.md#github-pages
255+
[27]: publishing-your-site.md#github-pages
254256

255257
### Terms
256258

@@ -259,7 +261,7 @@ commercial project. Can we use Insiders under the same terms and conditions?_
259261

260262
Yes. Whether you're an individual or a company, you may use _Material for MkDocs
261263
Insiders_ precisely under the same terms as Material for MkDocs, which are given
262-
by the [MIT license][27]. However, we kindly ask you to respect the following
264+
by the [MIT license][28]. However, we kindly ask you to respect the following
263265
guidelines:
264266

265267
- Please __don't distribute the source code__ of Insiders. You may freely use
@@ -270,7 +272,7 @@ guidelines:
270272
- If you cancel your subscription, you're removed as a collaborator and will
271273
miss out on future updates of Insiders. However, you may __use the latest
272274
version__ that's available to you __as long as you like__. Just remember that
273-
[GitHub deletes private forks][28].
275+
[GitHub deletes private forks][29].
274276

275-
[27]: license.md
276-
[28]: https://docs.github.com/en/github/setting-up-and-managing-your-github-user-account/removing-a-collaborator-from-a-personal-repository
277+
[28]: license.md
278+
[29]: https://docs.github.com/en/github/setting-up-and-managing-your-github-user-account/removing-a-collaborator-from-a-personal-repository

docs/reference/code-blocks.md

Lines changed: 75 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -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
211266
Line 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
269324
prefixing them with a shebang-like sequence, i.e. `#!`, directly followed by
270325
the [language short name][17].
271326

@@ -279,11 +334,11 @@ _Result_:
279334

280335
The `#!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.
287342
Consult the [Python Markdown Extensions][16] documentation to learn about all
288343
available 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
307362
is especially useful to reference and embed the contents of source files
308363
directly into your project documentation.
309364

@@ -321,23 +376,23 @@ _Result_:
321376
last 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
325380
from a document to move repeating content to separate files, which is also
326381
explained 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

361416
Let'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
363418
to most of them.
364419

365420
Create an [additional stylesheet][6], and add:
@@ -371,7 +426,7 @@ Create an [additional stylesheet][6], and add:
371426
```
372427

373428
If 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
375430
override 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

Comments
 (0)