Added basic support for line anchors

This commit is contained in:
squidfunk 2021-12-08 21:53:52 +01:00
parent 3c4c8dce9c
commit 16939c16ae
6 changed files with 20 additions and 5 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -34,7 +34,7 @@
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block styles %} {% block styles %}
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.956c2c2d.min.css' | url }}"> <link rel="stylesheet" href="{{ 'assets/stylesheets/main.52c8dc4b.min.css' | url }}">
{% if config.theme.palette %} {% if config.theme.palette %}
{% set palette = config.theme.palette %} {% set palette = config.theme.palette %}
<link rel="stylesheet" href="{{ 'assets/stylesheets/palette.9204c3b2.min.css' | url }}"> <link rel="stylesheet" href="{{ 'assets/stylesheets/palette.9204c3b2.min.css' | url }}">

View File

@ -136,7 +136,9 @@ markdown_extensions:
- pymdownx.emoji: - pymdownx.emoji:
emoji_index: !!python/name:materialx.emoji.twemoji emoji_index: !!python/name:materialx.emoji.twemoji
emoji_generator: !!python/name:materialx.emoji.to_svg emoji_generator: !!python/name:materialx.emoji.to_svg
- pymdownx.highlight - pymdownx.highlight:
line_spans: __codeline
anchor_linenums: True
- pymdownx.inlinehilite - pymdownx.inlinehilite
- pymdownx.keys - pymdownx.keys
- pymdownx.magiclink: - pymdownx.magiclink:

View File

@ -200,6 +200,14 @@
content: attr(data-linenos); content: attr(data-linenos);
user-select: none; user-select: none;
} }
// Code block line anchors - Chrome and Safari seem to have a strange bug
// where scroll margin is not applied to anchors inside code blocks. Setting
// positioning to absolute seems to fix the problem. Interestingly, this does
// not happen in Firefox.
code a[id] {
position: absolute;
}
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -267,6 +275,11 @@
} }
} }
// Code block line numbers container
.linenodiv a {
color: inherit;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Scoped in typesetted content to match specificity of regular content // Scoped in typesetted content to match specificity of regular content