Skip to main content

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 anchor
  • title: the title of the headline as HTML
  • children: 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

lektor_markdown_header_anchors-0.4.0.tar.gz (37.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file lektor_markdown_header_anchors-0.4.0.tar.gz.

File metadata

  • Download URL: lektor_markdown_header_anchors-0.4.0.tar.gz
  • Upload date:
  • Size: 37.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for lektor_markdown_header_anchors-0.4.0.tar.gz
Algorithm Hash digest
SHA256 74663067bca240ef8c3e325982712f30e94fa3c7b91a8a19bffa9bb143b17d8e
MD5 020b74a3e6a26a96cbd735b67ddf8916
BLAKE2b-256 0614d20638c0cfe011afa46a0861634aa0f886a75dfd60ef9a4327950749bd31

See more details on using hashes here.

File details

Details for the file lektor_markdown_header_anchors-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: lektor_markdown_header_anchors-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for lektor_markdown_header_anchors-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8b5ec3f7dcc28ae7887a028400d518b50bd3bb926fe23d2935dd080a4122fb54
MD5 c4799f2deb55fe59df79e9fb4a93c2fa
BLAKE2b-256 a326e8d896b7003e9aac1eed4a68c11dfa6c65990b8a69b33fdd828841420e66

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page