Skip to main content

Lektor plugin that adds anchors and table of contents to markdown headers.

Project description


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 %}

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for lektor-markdown-header-anchors, version 0.3.1
Filename, size File type Python version Upload date Hashes
Filename, size lektor_markdown_header_anchors-0.3.1-py2.py3-none-any.whl (4.1 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size lektor-markdown-header-anchors-0.3.1.tar.gz (3.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page