Python bindings for mq, a jq-like command-line tool for Markdown processing
Project description
mq
Python bindings for the mq Markdown processor.
Overview
markdown-query provides Python bindings to the mq, allowing Python developers to use mq's Markdown processing capabilities directly from Python code.
Installation
pip install markdown-query
Usage
import mq
# Process a markdown string with an mq query
markdown = '# Hello\n\nThis is a paragraph\n\n## Section\n\nMore text.\n\n```js\nconsole.log("code")\n```'
print(mq.run("select(or(.h1, .code))", markdown, None).values)
# ['# Hello', '```js\nconsole.log("code")\n```']
print(mq.run("select(or(.h1, .code)) | to_text()", markdown, None).values)
# ['Hello', 'console.log("code")']
print(mq.run("select(or(.h1, .code)) | to_text()", markdown, None)[0].text)
# Hello
print([m for m in mq.run("select(or(.h1, .code))", markdown, None)])
# MarkdownType.Heading
print(mq.run("select(or(.h1, .code))", markdown, None)[0].markdown_type)
# MarkdownType.Heading
# Process a html string with an mq query
markdown = '<h1>Title</h1><p>Paragraph</p>'
options = mq.Options()
options.input_format = mq.InputFormat.HTML
print(mq.run(".h1 | upcase()", markdown, options).values)
# ['# TITLE']
Using with markitdown
You can combine mq with markitdown for even more powerful Markdown processing workflows:
from markitdown import MarkItDown
import mq
markitdown = MarkItDown()
result = markitdown.convert("https://github.com/harehare/mq")
print(mq.run(".code | to_text()", result, None))
print(mq.run(".[] | to_html()", result, None))
For more detailed usage and examples, refer to the documentation.
Playground
An Online Playground is available, powered by WebAssembly.
License
This project is licensed under the MIT License. See the 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 Distributions
Built Distributions
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 markdown_query-0.2.0-pp311-pypy311_pp73-win_amd64.whl.
File metadata
- Download URL: markdown_query-0.2.0-pp311-pypy311_pp73-win_amd64.whl
- Upload date:
- Size: 834.1 kB
- Tags: PyPy, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17443e0f0d12ad7720530c96238617633c8cfb31bc77941a3433ecfa10632abf
|
|
| MD5 |
a0e3246715491de24f52db401f8164d9
|
|
| BLAKE2b-256 |
11f652847d9abc464fedbb8cc67aa4fffb6f04adbee69f7d952cc99ce6dfc567
|
File details
Details for the file markdown_query-0.2.0-pp310-pypy310_pp73-win_amd64.whl.
File metadata
- Download URL: markdown_query-0.2.0-pp310-pypy310_pp73-win_amd64.whl
- Upload date:
- Size: 835.8 kB
- Tags: PyPy, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0bcc7db2ea1702125edec6c0360a903613510c069a93513ce428bed441eb973e
|
|
| MD5 |
f1ae98be18bab996ca83408da081f79c
|
|
| BLAKE2b-256 |
0c02c07adaa9644c68dd81c0c47e82aa0258b627dcc4c21a7d21800547c8b971
|
File details
Details for the file markdown_query-0.2.0-pp39-pypy39_pp73-win_amd64.whl.
File metadata
- Download URL: markdown_query-0.2.0-pp39-pypy39_pp73-win_amd64.whl
- Upload date:
- Size: 835.5 kB
- Tags: PyPy, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2224333b75c7258435aecf0871ea21e1bdc3a50ade025d02ee1d4d9ffec21e05
|
|
| MD5 |
cf62117eddc40ceabfc589f25c62ba30
|
|
| BLAKE2b-256 |
4056e9ea9cc3f9acca6de416f0c47bfdf09614018b0704abd082a08f50cf7705
|
File details
Details for the file markdown_query-0.2.0-cp313-cp313t-win_amd64.whl.
File metadata
- Download URL: markdown_query-0.2.0-cp313-cp313t-win_amd64.whl
- Upload date:
- Size: 832.4 kB
- Tags: CPython 3.13t, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb8836964baa39c3f9dd664d2bb79d7ea3365684ab87df0aa51cf06c1bfa4ba9
|
|
| MD5 |
0992b4c4966a8c250536133424a145e9
|
|
| BLAKE2b-256 |
9cdee81a8db35398520a1fa9fae729f73712eef597ad23d4bc1e8abb3718cef6
|
File details
Details for the file markdown_query-0.2.0-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: markdown_query-0.2.0-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 835.6 kB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c5383bcba780b63c6db1bea1e8877acc0f7bfe15abc454a55efe6cdd3055398
|
|
| MD5 |
51eea344adbde669aea07043a46e0675
|
|
| BLAKE2b-256 |
b5d94459c7636d2d3625c7ac58f217c201d60a2a3ff64e5d153c40014f246dba
|
File details
Details for the file markdown_query-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: markdown_query-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 820.1 kB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22fde3f0e4875917d68a5c53ce70d300769dc477aca86c6ee5408d27ac478724
|
|
| MD5 |
221d164ad58550e0d1fcbde172aec968
|
|
| BLAKE2b-256 |
528cb5f7bb1373f3d7af70cefff122ed210bf5cc661b321c037d956a16f81991
|
File details
Details for the file markdown_query-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: markdown_query-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 769.6 kB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d9382ef6cbcde653b4dc3620dd91714c4e606337bb21c8896e7f2001895d870
|
|
| MD5 |
43e084b1b94887b52f67896b4b5b738a
|
|
| BLAKE2b-256 |
ae4c563651b0f1e60cfe6a652be9b5b1763c11d7f9ec40459393779b0504b796
|
File details
Details for the file markdown_query-0.2.0-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: markdown_query-0.2.0-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 750.3 kB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5978c5406591dec31155b9a4d3ec7bd8f2c8070b511aa8bab9d738a20dc06fa0
|
|
| MD5 |
717d8c0821387630b4510c5b036dd11e
|
|
| BLAKE2b-256 |
af4cd9a521d5bbf33b8e4287fca00c2fa75ed5e8b72a7580a8653df4c5f6d10f
|
File details
Details for the file markdown_query-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: markdown_query-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 822.8 kB
- Tags: CPython 3.9+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f77f98b0cc1431cfd1cf6d99c69dc1e46bfa45d976e4f1ac9882f83c460464a
|
|
| MD5 |
576d082a7e94e08f7c84228de04d7094
|
|
| BLAKE2b-256 |
b832e3043698b86d8e391dd68202b28263aa1e8e9b583ba48eeb58890785f0bf
|