PyPI version License: MIT Downloads LinkedIn
mdextractor is a Python package designed for extracting code blocks from Markdown text. It efficiently identifies blocks enclosed in triple backticks (```), optionally preceded by language identifiers, and extracts their contents.
To install mdextractor, use pip:
pip install mdextractor
Using mdextractor is straightforward. Here's an example:
from mdextractor import extract_md_blocks text = """ \`\`\`python print("Hello, Markdown!") \`\`\` """ blocks = extract_md_blocks(text) print(blocks) # Output: ['print("Hello, Markdown!")']
This package is useful in various applications where extracting code or preformatted text from Markdown is necessary.
- Efficient extraction of Markdown code blocks.
- Supports language specifiers following the opening backticks.
- Works with multi-line and single-line code blocks.
- Simple API with a single function call.
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
mdextractor is licensed under the MIT License.