mdit-plain

1.0.1 · active · verified Thu Apr 16

mdit-plain is a Python renderer for the markdown-it-py library, designed to convert Markdown documents into clean plain text by effectively stripping out all markup. Its primary purpose is to facilitate Natural Language Processing (NLP) and other text-based analyses where unformatted content is required. The current version is 1.0.1, released in January 2023, indicating a slow release cadence since then.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize markdown-it-py with the mdit-plain renderer to convert a Markdown string into plain text, effectively removing all formatting.

from markdown_it import MarkdownIt
from mdit_plain.renderer import RendererPlain

markdown_text = """
# Header One

This is **some** *markdown* text with a [link](https://example.com).

* List item 1
* List item 2

> A blockquote.
"""

# Initialize MarkdownIt parser with the plain text renderer
parser = MarkdownIt(renderer_cls=RendererPlain)

# Render the markdown to plain text
plain_text = parser.render(markdown_text)

print(plain_text)
# Expected Output:
# Header One
#
# This is some markdown text with a link.
#
# * List item 1
# * List item 2
#
# > A blockquote.

view raw JSON →