Skip to content

Commit 6e66f27

Browse files
committed
mkdocs: Fix numbered code annotations
There was a regression introduced in `mkdocs-material` that broke how numbered annotations were rendered. See this issue for details: squidfunk/mkdocs-material#6042 This commit adds a style to make them look reasonably well again. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 9d1f3cd commit 6e66f27

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

docs/css/style.css

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,44 @@ a.external:hover::after, a.md-nav__link[href^="https:"]:hover::after {
2727
margin-bottom: 1.5rem;
2828
}
2929

30-
/* Code annotations with numbers
31-
* https://squidfunk.github.io/mkdocs-material/reference/code-blocks/#annotations-with-numbers
30+
/* Code annotations with numbers.
31+
*
32+
* Normally annothations are shown with a (+) button that expands the
33+
* annotation. To be able to explain code step by step, it is good to have
34+
* annotations with numbers, to be able to follow the notes in a particular
35+
* order.
36+
*
37+
* To do this, we need some custom CSS rules. Before this customization was
38+
* officially supported and documented, but now they are not officially
39+
* supported anymore, so it could eventually break (it already did once).
40+
*
41+
* If that happens we either need to look into how to fix the CSS ourselves or
42+
* remove the feature. To do the customization, this is what we should be able
43+
* to count on:
44+
*
45+
* "you can be sure that the data-md-annotation-id attribute will always be
46+
* present in the source, which means you can always number them in any way you
47+
* like."
48+
*
49+
* Code annotation are described here:
50+
* https://squidfunk.github.io/mkdocs-material/reference/code-blocks/#code-annotations
51+
*
52+
* Here are the original docs on how to enable numbered annotations:
53+
* https://web.archive.org/web/20230724161216/https://squidfunk.github.io/mkdocs-material/reference/code-blocks/#annotations-with-numbers
54+
*
55+
* This is the PR fixing the numbered annotations when they broke:
56+
* https://github.com/frequenz-floss/frequenz-sdk-python/pull/684
57+
*
58+
* And this is the reported regression when it was decided to drop support for
59+
* numbered annotations officially:
60+
* https://github.com/squidfunk/mkdocs-material/issues/6042
3261
*/
3362
.md-typeset .md-annotation__index > ::before {
3463
content: attr(data-md-annotation-id);
3564
}
3665
.md-typeset :focus-within > .md-annotation__index > ::before {
3766
transform: none;
3867
}
68+
.md-typeset .md-annotation__index {
69+
width: 4ch;
70+
}

0 commit comments

Comments
 (0)