A Python interface to pulldown-cmark.
Project description
pulldown-cmark-py
An easy-to-use, configurable Python wrapper around pulldown-cmark.
Installation
uv add pulldown-cmark
Usage
pulldown-cmark-py provides just one function.
def render(markdown: list[str], options: Options | None = None) -> list[str]: ...
The Options class configures callbacks and CommonMark extensions; see
help(Options) for details.
class Options:
tables: bool
footnotes: bool
strikethrough: bool
tasklists: bool
smart_punctuation: bool
heading_attributes: bool
yaml_style_metadata_blocks: bool
pluses_delimited_metadata_blocks: bool
old_footnotes: bool
gfm: bool
definition_list: bool
superscript: bool
subscript: bool
wikilinks: bool
math: Callable[[str, bool], str] | None
code: Callable[[str, str | None], str] | None
Simple callback examples are given below.
from latex2mathml.converter import convert
from pygments import highlight
from pygments.formatters import HtmlFormatter
from pygments.lexers import get_lexer_by_name, guess_lexer
def math_callback(buffer: str, display: bool) -> str:
return convert(buffer, "display" if display else "inline")
def code_callback(buffer: str, language: str | None) -> str:
lexer = get_lexer_by_name(language) if language else guess_lexer(buffer)
return highlight(buffer, lexer, HtmlFormatter())
Project details
Release history Release notifications | RSS feed
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 pulldown_cmark-0.1.1.tar.gz.
File metadata
- Download URL: pulldown_cmark-0.1.1.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98c93af9bc995baae5f05bcdfb1c669ec1ae30938cbaca450b9969e5bfbcc4ac
|
|
| MD5 |
d8ec844da790048be630280e9a70a6df
|
|
| BLAKE2b-256 |
fb53c7b626e4cdad8f0416b2ff82325a1c7a9f60d390992aa1956a5f87f20ed1
|
File details
Details for the file pulldown_cmark-0.1.1-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: pulldown_cmark-0.1.1-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 413.2 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de4b77bd84483bc1a27e3f77fc7a9eae94af2d65521ffb9a6b00fa76f6dfc150
|
|
| MD5 |
947640b4b66c4b67a5b8cdc4e5d54198
|
|
| BLAKE2b-256 |
c6f8d5230773ada0687ac7266555749043388c4658dc44e384931c99c5edb77f
|