Skip to main content

Extract Markdown code blocks from text strings.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mdextractor-2025.4.231259.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mdextractor-2025.4.231259-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file mdextractor-2025.4.231259.tar.gz.

File metadata

  • Download URL: mdextractor-2025.4.231259.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.11

File hashes

Hashes for mdextractor-2025.4.231259.tar.gz
Algorithm Hash digest
SHA256 075658d4e66b463ea755736380c5c6ff7d92abeb4f565d8b8356af1374810016
MD5 66c2d4e33ba9d16efc307e7e86c8411f
BLAKE2b-256 a9a74b66f32f38843158c43dfde9d9b9346637e40bd61a8e0c043db1a8c464fd

See more details on using hashes here.

File details

Details for the file mdextractor-2025.4.231259-py3-none-any.whl.

File metadata

File hashes

Hashes for mdextractor-2025.4.231259-py3-none-any.whl
Algorithm Hash digest
SHA256 266f272254c1141b384ccbe773eafc3eb38b4015d159df5d98519fe8a3358b1e
MD5 2c20f32741f1f12464e7f4d58926465c
BLAKE2b-256 a03f26e6072dedf73288dc30a2bad5e34bf5c8f669f9deeece659ec6966126a6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page