Skip to content

pymarkdown-builder

A Markdown document builder with line and span writing modes.

PyPI version Documentation Status CI codecov Code style: black Ruff Docstring Style License: GPL v3

Installation

You can install with pip, poetry, or any other package manager:

pip install pymarkdown-builder

Usage

For more examples, see the documentation.

from pymarkdown_builder import MarkdownBuilder
from pymarkdown_builder import Tokens as t


builder = (
    MarkdownBuilder()
    .lines(
        t.h1("pymarkdown-builder"),
        t.quote("A Markdown document builder with line and span writing modes."),
    )
    .br()
    .spans(
        t.p("A paragraph with an "),
        t.link("https://google.com", "inline link"),
        t.p(" and a "),
        t.bold | "bold " | t.italic | "and italic" | t.italic | t.bold,
    )
)

assert builder.document == "# pymarkdown-builder\n\n> A Markdown document builder with line and span writing modes.\n\nA paragraph with an [inline link](https://google.com) and a **bold *and italic***"

License

This project is licensed under the terms of the GPL-3.0-only license.