mdclense
A lightweight, efficient Python library for converting Markdown to plain text.
mdclensestrips away all Markdown formatting while preserving the original content, making it perfect for text analysis, content extraction, and data processing pipelines.
Features
- Comprehensive Markdown support
- Preserves content while removing formatting
- Handles complex nested structures
- Clean whitespace management
- JSON-like structure support
- Zero dependencies beyond Python standard library
Supported Markdown Elements
- Headers (ATX and Setext style)
- Emphasis (bold, italic, bold-italic)
- Links and images
- Lists (ordered, unordered, and task lists)
- Code blocks and inline code
- Blockquotes
- Tables
- Horizontal rules
- HTML tags
- Strikethrough
- Footnotes
- Escaped characters
Installation
pip install mdclense
Quick Start
from mdclense.parser import MarkdownParser
# Create a parser instance
parser = MarkdownParser()
# Convert markdown to plain text
markdown_text = """
# Hello World
This is a **bold** and *italic* text with a [link](http://example.com).
- List item 1
- List item 2
"""
plain_text = parser.parse(markdown_text)
print(plain_text)
Output:
Hello World
This is a bold and italic text with a link.
List item 1
List item 2
Advanced Usage
Handling JSON-like Structures
# Parse markdown content from JSON-like structure
json_text = '"answer": "This is **bold** text with a [link](url)"'
plain_text = parser.parse(json_text)
print(plain_text) # Output: This is bold text with a link
Working with Code Blocks
markdown_text = '''
Here's some code:
```python
def hello():
print("world")
'''
plain_text = parser.parse(markdown_text) print(plain_text) # Code blocks are replaced with [CODE BLOCK] placeholder
## API Reference
### MarkdownParser Class
```python
class MarkdownParser:
def parse(markdown_text: str) -> str:
"""
Convert markdown text to plain text by removing all markdown formatting.
Args:
markdown_text (str): The markdown text to be converted
Returns:
str: Plain text without markdown formatting
"""
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Testing
# Install development dependencies
pip install pytest
# Run tests
pytest tests/
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Inspired by the need for a simple, dependency-free Markdown to plain text converter
- Thanks to all contributors who have helped shape this project
Metadata
Release files for mdclense 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mdclense-0.1.2.tar.gz | 7.2 kB | Without provenance | Details for mdclense-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mdclense-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for mdclense-0.1.2-py3-none-any.whl |
Total release size: 12.3 kB
Release files / mdclense-0.1.2.tar.gz
| Download URL | mdclense-0.1.2.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e8464f17bde450cff66aba64d5391f146432e293434619e7798fb7166e33a515
|
|
BLAKE2b-256 checksum How to use checksums |
b27e0f7547766716534a8ed484f0509f1f296d7b820e352642e3412ead030acc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.9
|
Release files / mdclense-0.1.2-py3-none-any.whl
| Download URL | mdclense-0.1.2-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
41c9c45a099478424b866b3c1a23c51397a4d135f0dce019c9128bbb4f4fb987
|
|
BLAKE2b-256 checksum How to use checksums |
9171dd6769438749c63b7b2cd09e4374e0be6e9a0752a4850d7d8b51ef9c879b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.9
|
Security for mdclense 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.