Skip to content

Commit 16939c1

Browse files
committed
Added basic support for line anchors
1 parent 3c4c8dc commit 16939c1

File tree

6 files changed

+20
-5
lines changed

6 files changed

+20
-5
lines changed

material/assets/stylesheets/main.956c2c2d.min.css renamed to material/assets/stylesheets/main.52c8dc4b.min.css

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/assets/stylesheets/main.52c8dc4b.min.css.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/assets/stylesheets/main.956c2c2d.min.css.map

-1
This file was deleted.

material/base.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
{% endif %}
3535
{% endblock %}
3636
{% block styles %}
37-
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.956c2c2d.min.css' | url }}">
37+
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.52c8dc4b.min.css' | url }}">
3838
{% if config.theme.palette %}
3939
{% set palette = config.theme.palette %}
4040
<link rel="stylesheet" href="{{ 'assets/stylesheets/palette.9204c3b2.min.css' | url }}">

mkdocs.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ markdown_extensions:
136136
- pymdownx.emoji:
137137
emoji_index: !!python/name:materialx.emoji.twemoji
138138
emoji_generator: !!python/name:materialx.emoji.to_svg
139-
- pymdownx.highlight
139+
- pymdownx.highlight:
140+
line_spans: __codeline
141+
anchor_linenums: True
140142
- pymdownx.inlinehilite
141143
- pymdownx.keys
142144
- pymdownx.magiclink:

src/assets/stylesheets/main/extensions/pymdownx/_highlight.scss

+13
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,14 @@
200200
content: attr(data-linenos);
201201
user-select: none;
202202
}
203+
204+
// Code block line anchors - Chrome and Safari seem to have a strange bug
205+
// where scroll margin is not applied to anchors inside code blocks. Setting
206+
// positioning to absolute seems to fix the problem. Interestingly, this does
207+
// not happen in Firefox.
208+
code a[id] {
209+
position: absolute;
210+
}
203211
}
204212

205213
// ----------------------------------------------------------------------------
@@ -267,6 +275,11 @@
267275
}
268276
}
269277

278+
// Code block line numbers container
279+
.linenodiv a {
280+
color: inherit;
281+
}
282+
270283
// ----------------------------------------------------------------------------
271284

272285
// Scoped in typesetted content to match specificity of regular content

0 commit comments

Comments
 (0)