Skip to main content

markdown-it-py plugin to add ID attribute support to headings

Project description

mdit-py-heading-attrs

PyPI version Python versions License

mdit-py-heading-attrs is a markdown-it-py plugin to add attribute support to headings. Currently, only anchors are supported.

Example

Input markdown:

## Getting Started {#getting-started}

Output HTML:

<h2 id="getting-started">Getting Started</h2>

Installation

pip install mdit-py-heading-attrs

Or with uv:

uv add mdit-py-heading-attrs

Usage

from markdown_it import MarkdownIt
from mdit_py_heading_attrs import heading_attrs_plugin

md = MarkdownIt().use(heading_attrs_plugin)

markdown = """
## Getting Started {#getting-started}
"""

html = md.render(markdown)
print(html)

Output:

<h2 id="getting-started">Getting Started</h2>

Syntax

Add an ID to any heading using {#id} syntax at the end:

## Heading {#my-id}

Supported Heading Formats

# ATX heading {#h1-id}
## ATX heading {#h2-id}
### ATX heading {#h3-id}

## ATX with closing ## {#my-id}

Setext H1 {#setext-h1}
==========

Setext H2 {#setext-h2}
----------

Escaping

Use backslash to escape braces if you want them to render literally:

## Code Example \{not-an-id\}

Renders as:

<h2>Code Example {not-an-id}</h2>

See Also

  • mdit-py-plugins: collection of core plugins for markdown-it-py.
  • mdit-py-figure: plugin to parse markdown paragraphs that start with an image into HTML <figure> elements.

Changelog

See CHANGELOG.md.

License

Apache-2.0

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

mdit_py_heading_attrs-1.0.0.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

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

mdit_py_heading_attrs-1.0.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file mdit_py_heading_attrs-1.0.0.tar.gz.

File metadata

  • Download URL: mdit_py_heading_attrs-1.0.0.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mdit_py_heading_attrs-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8e5dec03d56a1fb7eb06751c3b29aabf03e08dfc72d47d16aa643abe75ee4913
MD5 0f3070cd8f5d7c307855ea9c34f11226
BLAKE2b-256 61ec69ee7c6829709f1608669176ab50e30def86f0af17d40557c57b258af9bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdit_py_heading_attrs-1.0.0.tar.gz:

Publisher: pypi_upload.yml on mangoumbrella/mdit-py-heading-attrs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mdit_py_heading_attrs-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mdit_py_heading_attrs-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 558d2b93e73592e3a5ebeb2e283701faf6ee4215b7e155fa782d728655b082bf
MD5 da4ca49a029f7298b8b249bd0f8f3f60
BLAKE2b-256 4bb1fd2e3ca7e0c3489962634d02b00e3aece0c6706e2d8017fdf1f0edf7d0fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdit_py_heading_attrs-1.0.0-py3-none-any.whl:

Publisher: pypi_upload.yml on mangoumbrella/mdit-py-heading-attrs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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