Skip to main content

Python bindings for mq, a jq-like command-line tool for Markdown processing

Project description

mq

ci GitHub Release codecov CodSpeed Badge

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


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

markdown_query-0.2.7-pp311-pypy311_pp73-win_amd64.whl (1.5 MB view details)

Uploaded PyPyWindows x86-64

markdown_query-0.2.7-pp310-pypy310_pp73-win_amd64.whl (1.5 MB view details)

Uploaded PyPyWindows x86-64

markdown_query-0.2.7-pp39-pypy39_pp73-win_amd64.whl (1.5 MB view details)

Uploaded PyPyWindows x86-64

markdown_query-0.2.7-cp313-cp313t-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.13tWindows x86-64

markdown_query-0.2.7-cp39-abi3-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.9+Windows x86-64

markdown_query-0.2.7-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

markdown_query-0.2.7-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.4 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

markdown_query-0.2.7-cp39-abi3-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.2.7-cp39-abi3-macosx_10_12_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file markdown_query-0.2.7-pp311-pypy311_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for markdown_query-0.2.7-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 efd8f856428dd61a3e283860ca2d7b48ca1485a1f7ea1ea547b3ca6c797bd742
MD5 aad71313ce4c7ee6890923d62d881048
BLAKE2b-256 956e9e6413b37e62ddaa39a247d725b52657dea51117581f908043433988fc34

See more details on using hashes here.

File details

Details for the file markdown_query-0.2.7-pp310-pypy310_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for markdown_query-0.2.7-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 f97628ee48687012814f9c133babfb27a88f396755c0140fc82b0007e657be0f
MD5 a9d5196f90dccea26d11ec5a8ac16181
BLAKE2b-256 d5cd2e6b4f2cfc0f3f18881ba8f0fdf871123c74cbf8fe3eb3e27407cca3b676

See more details on using hashes here.

File details

Details for the file markdown_query-0.2.7-pp39-pypy39_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for markdown_query-0.2.7-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 d715604757f6620c1504bd81fbb33ad81857ec4afd4b4d15e1d9b7d47147e44a
MD5 a5faa42cb1d41d850542045c180c2b92
BLAKE2b-256 9897f99470e14235f2af45e357f1bdb8b9e28c30c0284d6f9fbd6acc6e027e91

See more details on using hashes here.

File details

Details for the file markdown_query-0.2.7-cp313-cp313t-win_amd64.whl.

File metadata

File hashes

Hashes for markdown_query-0.2.7-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 698b16b847bb201448822af4ed60308519bb687aca1f21c2adea3bbf1b8fe225
MD5 b6cfe91d8d69e2a35cd02b8d7acdc66a
BLAKE2b-256 c2db2a25a5ed4bed218fc69804cfaca4066067217484ace612ff6d5f02ab6341

See more details on using hashes here.

File details

Details for the file markdown_query-0.2.7-cp39-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for markdown_query-0.2.7-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 8f45752ba6f7fa89190c52d72bfed3ba762558edbe4eeec0c3190acee7c4b2ba
MD5 2fbe9284986e4f26f8bfbacc1bef3142
BLAKE2b-256 c4c656a0265c0b5411846c2137e7057968b01da638660887134042081e6dc957

See more details on using hashes here.

File details

Details for the file markdown_query-0.2.7-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for markdown_query-0.2.7-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a16c519238c536fa03c937dd4f4c370f8ad7ea5666bf0310ebd2402d5f650e4f
MD5 c26152a2975734584d3cd934be5c391e
BLAKE2b-256 93104928ff7046edbbfd7036fb64dad123abdbbd48ab4a345e34de2f02b770ba

See more details on using hashes here.

File details

Details for the file markdown_query-0.2.7-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for markdown_query-0.2.7-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e72fd234a5333dd0dc34a3126d065d87169366d7595cd164f6d202dc173dd171
MD5 404980090e7e071334d7bd08de118766
BLAKE2b-256 b9cb7b79793af83844eb11a803a6ad90b119566ce87d3d4c41111bd9f1ac1c63

See more details on using hashes here.

File details

Details for the file markdown_query-0.2.7-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for markdown_query-0.2.7-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 78a1ddf5ca57ea5be9d806d02f12fdb568c222a1a59c4fbdfa25368dc6e9dcd8
MD5 e68e60483d2ef1f3eee09e7977b7303b
BLAKE2b-256 19abb62782833c6074f3a04403b5a71ba53bf08d989c1e9cf941ea2adef9ea75

See more details on using hashes here.

File details

Details for the file markdown_query-0.2.7-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for markdown_query-0.2.7-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a9aeefc272ab5ec1c65c594aafd83c9dc9163379af13815f4402710d9b36c4ac
MD5 d3807d885e4c3106b8abd8d09d54d210
BLAKE2b-256 8567db52454dd017d99a407545ee588f97b9bec9537f6f645256a76af67376b7

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