Skip to content

Commit 3cc6e4a

Browse files
committed
Documentation
1 parent 87d5ca4 commit 3cc6e4a

File tree

5 files changed

+95
-22
lines changed

5 files changed

+95
-22
lines changed

docs/blog/posts/the-past-present-and-future.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ are still exclusively available to sponsors as part of [Insiders]:
119119
- [Boosting pages in search]
120120
- [Brand new search plugin]
121121
- [Code annotations]
122-
- [Code annotations: anchor links]
122+
- Code annotations: anchor links
123123
- [Code annotations: strip comments]
124124
- [Code block titles]
125125
- [Code block line anchors]
@@ -167,7 +167,6 @@ __55__ times, `mkdocs-material-insiders` was shipped __72__ times.
167167
[Boosting pages in search]: ../../setup/setting-up-site-search.md#search-boosting
168168
[Brand new search plugin]: search-better-faster-smaller.md
169169
[Code annotations]: ../../reference/code-blocks.md#adding-annotations
170-
[Code annotations: anchor links]: ../../reference/code-blocks.md#anchor-links
171170
[Code annotations: strip comments]: ../../reference/code-blocks.md#stripping-comments
172171
[Code block titles]: ../../reference/code-blocks.md#adding-a-title
173172
[Code block line anchors]: ../../setup/extensions/python-markdown-extensions.md#anchor-linenums

docs/insiders/index.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,16 @@ a handful of them, [thanks to our awesome sponsors]!
8888
## What's in it for me?
8989

9090
The moment you [become a sponsor][how to become a sponsor], you'll get __immediate
91-
access to 23 additional features__ that you can start using right away, and
91+
access to 25 additional features__ that you can start using right away, and
9292
which are currently exclusively available to sponsors:
9393

9494
<div class="mdx-columns" markdown>
9595

96+
- [x] [Code range selection] :material-alert-decagram:{ .mdx-pulse title="Added on February 19, 2023" }
97+
- [x] [Code annotations: custom selectors] :material-alert-decagram:{ .mdx-pulse title="Added on February 19, 2023" }
9698
- [x] [Privacy plugin: optimization support] :material-alert-decagram:{ .mdx-pulse title="Added on February 6, 2023" }
97-
- [x] [Optimize plugin] :material-alert-decagram:{ .mdx-pulse title="Added on January 21, 2023" }
98-
- [x] [Navigation path] (Breadcrumbs) :material-alert-decagram:{ .mdx-pulse title="Added on January 14, 2023" }
99+
- [x] [Optimize plugin]
100+
- [x] [Navigation path] (Breadcrumbs)
99101
- [x] [Typeset plugin]
100102
- [x] [Privacy plugin: external links]
101103
- [x] [Navigation subtitles]
@@ -287,7 +289,7 @@ are released for general availability.
287289
- [x] [Blog plugin: related links]
288290
- [x] [Blog plugin: custom index pages]
289291
- [x] [Tags plugin: additional indexes]
290-
- [x] [Tags plugin: allow list] and [custom sorting]
292+
- [x] [Tags plugin: allow list] + [custom sorting]
291293
- [x] [Navigation subtitles]
292294

293295
[Meta plugin]: ../reference/index.md#built-in-meta-plugin
@@ -302,10 +304,10 @@ are released for general availability.
302304

303305
- [x] [Optimize plugin]
304306
- [x] [Typeset plugin]
305-
- [x] [Privacy plugin: external links]
306307
- [x] [Navigation path] (Breadcrumbs)
307308
- [x] [Privacy plugin: optimization support]
308-
- [ ] Code block line wrapping
309+
- [x] [Privacy plugin: external links]
310+
- [ ] Privacy plugin: external link validation
309311

310312
[Optimize plugin]: ../setup/building-an-optimized-site.md#built-in-optimize-plugin
311313
[Typeset plugin]: ../reference/index.md#built-in-typeset-plugin
@@ -316,7 +318,12 @@ are released for general availability.
316318

317319
#### $ 24,000 – Blockpaprika
318320

319-
- [ ] [Instant previews]
321+
- [x] [Code range selection]
322+
- [x] [Code annotations: custom selectors]
323+
- [ ] Code line wrap button
324+
325+
[Code range selection]: ../reference/code-blocks.md#code-selection-button
326+
[Code annotations: custom selectors]: ../reference/code-blocks.md#custom-selectors
320327

321328
### Goals completed
322329

@@ -343,14 +350,13 @@ can be used by all users.
343350
#### $ 8,000 – Scotch Bonnet
344351

345352
- [x] [Social cards]
346-
- [x] [Code annotations: anchor links]
353+
- [x] Code annotations: anchor links
347354
- [x] [Code annotations: strip comments]
348355
- [x] [Tag icons]
349356
- [x] [Table of contents anchor following]
350357
- [x] Sidebars automatically scroll to active item
351358

352359
[Social cards]: ../setup/setting-up-social-cards.md
353-
[Code annotations: anchor links]: ../reference/code-blocks.md#anchor-links
354360
[Code annotations: strip comments]: ../reference/code-blocks.md#stripping-comments
355361
[Tag icons]: ../setup/setting-up-tags.md#tag-icons-and-identifiers
356362
[Table of contents anchor following]: ../setup/setting-up-navigation.md#anchor-following

docs/reference/code-blocks.md

Lines changed: 74 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ following lines to `mkdocs.yml`:
2121
markdown_extensions:
2222
- pymdownx.highlight:
2323
anchor_linenums: true
24+
line_spans: __span
25+
pygments_lang_class: true
2426
- pymdownx.inlinehilite
2527
- pymdownx.snippets
2628
- pymdownx.superfences
@@ -81,6 +83,47 @@ theme:
8183
```
8284
````
8385

86+
### Code selection button :material-alert-decagram:{ .mdx-pulse title="Added on February 19, 2023" }
87+
88+
[:octicons-heart-fill-24:{ .mdx-heart } Sponsors only][Insiders]{ .mdx-insiders } ·
89+
[:octicons-tag-24: insiders-4.32.0][Insiders] ·
90+
:octicons-beaker-24: Experimental
91+
92+
Code blocks can include a button to allow for the selection of line ranges by
93+
the user, which is perfect for linking to a specific subsection of a code block. This allows the user to apply [line highlighting] dynamically. Add the following
94+
to `mkdocs.yml` to enable it globally:
95+
96+
``` yaml
97+
theme:
98+
features:
99+
- content.code.select
100+
```
101+
102+
??? info "Enabling or disabling code selection buttons for a specific code block"
103+
104+
If you don't want to enable code selection buttons globally, you can enable
105+
them for a specific code block by using a slightly different syntax based on
106+
the [Attribute Lists] extension:
107+
108+
```` yaml
109+
``` { .yaml .select }
110+
# Code block content
111+
```
112+
````
113+
114+
Note that the language shortcode which has to come first must now also be
115+
prefixed by a `.`. Similarly, the selection button can also be disabled for
116+
a specific code block:
117+
118+
```` { .yaml .no-select }
119+
``` { .yaml .no-select }
120+
# Code block content
121+
```
122+
````
123+
124+
[Insiders]: ../insiders/index.md
125+
[line highlighting]: #highlighting-specific-lines
126+
84127
### Code annotations
85128

86129
[:octicons-tag-24: 8.0.0][Code annotations support] ·
@@ -119,24 +162,45 @@ theme:
119162
[Code annotations support]: https://github.com/squidfunk/mkdocs-material/releases/tag/8.0.0
120163
[Attribute Lists]: ../setup/extensions/python-markdown.md#attribute-lists
121164

122-
#### Anchor links
165+
#### Custom selectors :material-alert-decagram:{ .mdx-pulse title="Added on February 19, 2023" }
123166

124-
[:octicons-tag-24: 8.5.0][Anchor links support] ·
167+
[:octicons-heart-fill-24:{ .mdx-heart } Sponsors only][Insiders]{ .mdx-insiders } ·
168+
[:octicons-tag-24: insiders-4.32.0][Insiders] ·
125169
:octicons-beaker-24: Experimental
126170

127-
In order to be able to link to code annotations and share them more easily, an
128-
anchor link is automatically added to each annotation, which you can copy via
129-
right click or open in a new tab:
171+
Normally, code annotations can only be [placed in comments], as comments can be
172+
considered safe for placement. However, sometimes it might be necessary to place
173+
annotations in parts of the code block where comments are not allowed, e.g. in
174+
strings.
175+
176+
Additional selectors can be set per-language:
130177

131178
``` yaml
132-
# (1)!
179+
extra:
180+
annotate:
181+
json: [.s2] # (1)!
182+
```
183+
184+
1. [`.s2`][s2] is the name of the lexeme that [Pygments] generates for double-quoted
185+
strings. If you want to use a code annotation in another lexeme than a
186+
comment, inspect the code block and determine which lexeme needs to be added
187+
to the list of additional selectors.
188+
189+
__Important__: Code annotations cannot be split between lexemes.
190+
191+
Now, code annotations can be used from within strings in JSON:
192+
193+
``` json
194+
{
195+
"key": "value (1)"
196+
}
133197
```
134198

135-
1. If you ++cmd++ :material-plus::material-cursor-default-outline: me, I'm
136-
rendered open in a new tab. You can also right-click me to __copy link
137-
address__ to share me with others.
199+
1. :man_raising_hand: I'm a code annotation! I can contain `code`, __formatted
200+
text__, images, ... basically anything that can be written in Markdown.
138201

139-
[Anchor links support]: https://github.com/squidfunk/mkdocs-material/releases/tag/8.5.0
202+
[placed in comments]: #adding-annotations
203+
[s2]: https://github.com/squidfunk/mkdocs-material/blob/87d5ca487b9d9ab95c41ee72813149d214048693/src/assets/stylesheets/main/extensions/pymdownx/_highlight.scss#L45
140204

141205
## Usage
142206

docs/setup/ensuring-data-privacy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ The following configuration options are available for external assets:
325325
[technical limitations]: #limitations
326326
[built-in optimize plugin]: building-an-optimized-site.md#built-in-optimize-plugin
327327

328-
#### External links :material-alert-decagram:{ .mdx-pulse title="Added on October 18, 2022" }
328+
#### External links
329329

330330
[:octicons-heart-fill-24:{ .mdx-heart } Sponsors only][Insiders]{ .mdx-insiders } ·
331331
[:octicons-tag-24: insiders-4.26.0][Insiders] ·

mkdocs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ hooks:
9494

9595
# Customization
9696
extra:
97+
annotate:
98+
json: [.s2]
9799
analytics:
98100
provider: google
99101
property: !ENV GOOGLE_ANALYTICS_KEY
@@ -132,6 +134,8 @@ markdown_extensions:
132134
emoji_index: !!python/name:materialx.emoji.twemoji
133135
- pymdownx.highlight:
134136
anchor_linenums: true
137+
line_spans: __span
138+
pygments_lang_class: true
135139
- pymdownx.inlinehilite
136140
- pymdownx.keys
137141
- pymdownx.magiclink:

0 commit comments

Comments
 (0)