A package to extract code blocks from a LLM response, enclosed in triple backticks.
Project description
extractCodeBlock
A simple Python package to extract code blocks enclosed within triple backticks (```) from a string content.
Features
- Extracts multiple code blocks with language identifiers.
- Returns a list of dictionaries where each dictionary maps the block language/name to its content.
- Useful for parsing markdown or text or code with embedded code snippets.
Installation
Install the package via pip once published on PyPi:
pip install extractCodeBlock
Usage
from extractCodeBlock import extractCodeBlock
text = """
```python
print("Hello World !")```
```sql
SELECT * FROM users;```
"""
code_blocks = extractCodeBlock(text)
print(code_blocks)
Output:
[{'python': 'print("Hello World !")'}, {'sql': 'SELECT * FROM users;'}]
License
This project is licensed under the MIT License - see the [LICENSE] (LICENSE) file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file extractcodeblock-0.1.0.tar.gz.
File metadata
- Download URL: extractcodeblock-0.1.0.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cccaa0d2013f82fdaab32cddcfe5613c25bb500cd3cdfdd8a7f76178868df13e
|
|
| MD5 |
aa7ba2f1e2cbd07e863f62342f3686bd
|
|
| BLAKE2b-256 |
64e226eae164d2cb7cb3e7b6102c5be4d4c7f3948b85ccbfca4b390c3a62f87d
|
File details
Details for the file extractcodeblock-0.1.0-py3-none-any.whl.
File metadata
- Download URL: extractcodeblock-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ca6ac62ee47995e5749da0d4b907e5f8323159f1695cf8a4978f6ca1975ffac
|
|
| MD5 |
78fb7890435262d0ee782a3e0ddc0b2a
|
|
| BLAKE2b-256 |
d984b9f3352d3fc94ab7bedae1f08e97aeaaaaf048e145a33a8da70080a643e5
|