Lektor plugin that adds anchors and table of contents to markdown headers.
Project description
lektor-markdown-header-anchors
This plugin extends the markdown support in Lektor in a way that headlines are given anchors and a table of contents is collected.
Enabling the Plugin
To enable the plugin run this command:
$ lektor plugins add markdown-header-anchors
In Templates
Within templates it becomes possible to access the .toc
property of
markdown data. It's a list where each item has the following attributes:
anchor
: the name of the anchortitle
: the title of the headline as HTMLchildren
: a list of headers below that header
Example rendering:
<h4>Table Of Contents</h4>
<ul class="toc">
{% for item in this.body.toc recursive %}
<li><a href="#{{ item.anchor }}">{{ item.title }}</a>{%
if item.children %}<ul>{{ loop(item.children) }}</ul>{% endif %}</li>
{% endfor %}
</ul>
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file lektor-markdown-header-anchors-0.3.1.tar.gz
.
File metadata
- Download URL: lektor-markdown-header-anchors-0.3.1.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d38c8bc891784f409f13b0945d835412a3626d4fc9c5b6e3b6bdf43fc07fb89 |
|
MD5 | 665ce61ef3646f14e8e8515dedf21818 |
|
BLAKE2b-256 | 79cd1067aec9423a05494bf75ae3ccfb088e69a96624c76f55a3c54cb97b58bf |
File details
Details for the file lektor_markdown_header_anchors-0.3.1-py2.py3-none-any.whl
.
File metadata
- Download URL: lektor_markdown_header_anchors-0.3.1-py2.py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23036131c210de9e0367ddd6b5ba51967a1e43027ebcacaf650c62c3b1e65b4b |
|
MD5 | c8a093c17596c1c81d03bab43c226022 |
|
BLAKE2b-256 | e24e55552e63a481b0d1ee161c0db4e30d69978b1598b6c0ce63b5d6654cd5c2 |