Air Tags + Markdown
Project description
air-markdown
Markdown = Air Tags + Mistletoe
- Free software: MIT License
- Documentation: https://air-markdown.readthedocs.io.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file air_markdown-0.3.0.tar.gz.
File metadata
- Download URL: air_markdown-0.3.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9007861eab6aa97018486a92a1f3de5e90cb3b82ca51f07e02e0b3f3cf29b035
|
|
| MD5 |
7c8eee760543f1e5cbf058b2f5cc2e66
|
|
| BLAKE2b-256 |
f3101cd4fd2f709ed379b817d9144fe2a3039e8d3321b28f007a0faf69af54e3
|
File details
Details for the file air_markdown-0.3.0-py3-none-any.whl.
File metadata
- Download URL: air_markdown-0.3.0-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
960c0b7921acde83545c482580bc428f24c72cba72611b08b37e7d5552ddfe5d
|
|
| MD5 |
5a15abec710b54da308d27fa2a945a3e
|
|
| BLAKE2b-256 |
97925e7e5c68cfdd9905eb33e935d43d4b8986d9fcbb200f824a994b9fb90671
|