Skip to main content

Air Tags + Markdown

Project description

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.

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

air_markdown-0.5.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

air_markdown-0.5.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file air_markdown-0.5.0.tar.gz.

File metadata

  • Download URL: air_markdown-0.5.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for air_markdown-0.5.0.tar.gz
Algorithm Hash digest
SHA256 3a4d70a9c561b54b5ec6eb0ed6946ece56c33940c7bc8a087f1b37189a892005
MD5 b08d385b78190d7f139721af68dd20a9
BLAKE2b-256 68abfb7a2ce8673249716cb70b084bc1d9c969af4436bad542f74fa296b6a173

See more details on using hashes here.

File details

Details for the file air_markdown-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: air_markdown-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for air_markdown-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 85c756864f36755f636a8e25254832a6725b4bb150a0d92d202e006cdbadcab7
MD5 8db060b911cb60dc9cbbf8f70e35627e
BLAKE2b-256 ebf822fb05e8016e4fa0df06885627344843275602459a092f19300626bc375d

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