You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

mdextractor

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mdextractor

Extract Markdown code blocks from text strings.

2025.4.231259
pipPyPI
Maintainers
1

PyPI version License: MIT Downloads LinkedIn

mdextractor

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.

Installation

To install mdextractor, use pip:

pip install mdextractor

Usage

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.

Features

  • 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.

Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

License

mdextractor is licensed under the MIT License.

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts