Skip to main content

air-markdown

PyPI version

Markdown = Air Tags + Mistletoe

Features

  • Handy Markdown() Air Tag that renders Markdown into HTML.
  • Powerful AirMarkdown() Air Tag that renders Markdown into HTML, including rendering of Air Tags inside ````air-live``` blocks. For example, if you have:
air.H2("Heading 2")

it will render as <h2>Heading 2</h2>.

Installation

Via uv:

uv add air-markdown

Or pip:

pip install air-markdown

Usage

from air_markdown import Markdown

Markdown('# Hello, world')

Renders as:

<h1>Hello, world.</h1>

Customizing the rendered HTML

Mistletoe allows for customization of the renderer through overloading of the Markdown.html_renderer property.

from air_markdown import Markdown
import mistletoe

class SupermanRenderer(mistletoe.HtmlRenderer):
    def render_strong(self, token: mistletoe.span_token.Strong) -> str:
        template = '<strong class="superman">{}</strong>'
        return template.format(self.render_inner(token))  

Markdown.html_renderer = SupermanRenderer

Now Markdown("**Look in the sky!**") renders

<p><strong class="superman">Look in the sky!</strong></p>\n

Wrapping Markdown output

If you need to wrap Markdown output, just override the Markdown.wrapper. So if you need all content to be wrapped by a section tag:

Markdown.wrapper = lambda self, x: f'<section>{x}</section>'   

assert Markdown('# Big').render() == '<section><h1>Big</h1>\n</section>'

TailwindTypographyMarkdown()

Useful for when using Tailwind Typography, it wraps content in an <article class="prose"> tag.

html = TailwindTypographyMarkdown('# Tailwind support').render()
assert html == '<article class="prose"><h1>Tailwind support</h1>\n</article>'

Credits

This package was created with Cookiecutter and the audreyfeldroy/cookiecutter-pypackage project template.

Release files for air-markdown 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for air-markdown 0.5.0
File Size Uploaded
air_markdown-0.5.0.tar.gz 6.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for air-markdown 0.5.0
File Interpreter ABI Platform
air_markdown-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.6 kB

Release files / air_markdown-0.5.0.tar.gz

Download URL air_markdown-0.5.0.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
3a4d70a9c561b54b5ec6eb0ed6946ece56c33940c7bc8a087f1b37189a892005
BLAKE2b-256 checksum
How to use checksums
68abfb7a2ce8673249716cb70b084bc1d9c969af4436bad542f74fa296b6a173
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","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}

Release files / air_markdown-0.5.0-py3-none-any.whl

Download URL air_markdown-0.5.0-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
85c756864f36755f636a8e25254832a6725b4bb150a0d92d202e006cdbadcab7
BLAKE2b-256 checksum
How to use checksums
ebf822fb05e8016e4fa0df06885627344843275602459a092f19300626bc375d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","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}

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page