Registry / ai-ml / mdit-plain

mdit-plain

JSON →
library1.0.1pypypi✓ verified 85d ago

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.

pip install mdit-plain
INSTALL
IMPORT
SIG · MDIT-PLAIN
M
mdit-plain
ai-mlpythonv1.0.1
Install
1.5s avg
Import
59ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.060s · 17.8MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.5s · import 0.058s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RendererPlain
from mdit_plain.renderer import RendererPlain
MarkdownIt
from markdown_it import MarkdownIt
from markdown_it_py import MarkdownIt
The core library is imported as 'markdown_it', not 'markdown_it_py'.

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.
Debug
Known issues
breakingmdit-plain relies on the internal API of markdown-it-py. Major version updates in markdown-it-py (e.g., v4.0.0, released after mdit-plain 1.0.1) may introduce breaking internal API changes that can cause mdit-plain to fail or produce incorrect output.
fix
Check for official mdit-plain updates or compatibility notes for newer markdown-it-py versions. If no update is available, consider pinning markdown-it-py to a compatible older version (e.g., `<4.0.0`) or implementing a custom plain text renderer.
affects: mdit-plain <= 1.0.1 with markdown-it-py >= 4.0.0
gotchamdit-plain primarily strips Markdown syntax. It does not perform advanced text normalization, such as intelligently collapsing multiple spaces, standardizing inconsistent line breaks, or converting complex Markdown structures (like tables) into highly readable plain text formats. The output might retain some whitespace artifacts.
fix
For highly normalized plain text output, additional post-processing steps (e.g., using regular expressions for whitespace, or a library like BeautifulSoup if an intermediate HTML conversion is acceptable) may be necessary after mdit-plain has processed the text.
affects: All versions
gotchaThe library has not seen updates since January 2023. While functional for its core purpose, this indicates limited active maintenance for new Markdown features, bug fixes for edge cases, or compatibility with future Python versions or markdown-it-py releases.
fix
Be aware that new Markdown syntax or complex parsing requirements might not be supported. Consider contributing to the project, forking it, or exploring alternative solutions if active development and immediate support are critical.
affects: All versions (due to lack of recent updates)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'markdown_it'
The core dependency 'markdown-it-py' is not installed.
fix
Install the required dependency: `pip install markdown-it-py`
ImportError: cannot import name 'RendererPlain' from 'mdit_plain.renderer'
mdit-plain is not installed, or there's a typo in the import path.
fix
Ensure mdit-plain is installed (`pip install mdit-plain`) and the import statement is `from mdit_plain.renderer import RendererPlain`.
Markdown syntax (e.g., `**bold**`, `[link](url)`) is still present in the output after rendering.
The MarkdownIt parser was not correctly configured to use `mdit-plain.RendererPlain`. It's likely using markdown-it-py's default HTML renderer.
fix
When initializing `MarkdownIt`, ensure you pass `renderer_cls=RendererPlain`: `parser = MarkdownIt(renderer_cls=RendererPlain)`.
Upgrade
Version history
1.0.1latest on PyPI · released Jan 2, 2023
Audit
Dependencies
markdown-it-pyrequiredmdit-plain is a renderer for markdown-it-py and requires it to function.
Agent activity
4 hits · last 30 days
node
4
Resources
mdit-plain — pip install mdit-plain · libregistry