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.22-pp311-pypy311_pp73-win_amd64.whl (1.1 MB view details)

Uploaded PyPyWindows x86-64

markdown_query-0.2.22-pp310-pypy310_pp73-win_amd64.whl (1.1 MB view details)

Uploaded PyPyWindows x86-64

markdown_query-0.2.22-pp39-pypy39_pp73-win_amd64.whl (1.1 MB view details)

Uploaded PyPyWindows x86-64

markdown_query-0.2.22-cp313-cp313t-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.13tWindows x86-64

markdown_query-0.2.22-cp39-abi3-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.9+Windows x86-64

markdown_query-0.2.22-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

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

markdown_query-0.2.22-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.1 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

markdown_query-0.2.22-cp39-abi3-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.2.22-cp39-abi3-macosx_10_12_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.22-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 babff90065d1ad70684adfba22c7db631551fb54badf04fb4d5202e0e3b6b90b
MD5 5604b61be8cbc451ecd6dcca0d44b8ea
BLAKE2b-256 69185732466be1a9ecafefa126e312e5cb04e71553af8a5becd8ce8a433f81ce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.22-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 b748d3caf84c6358ff214bd43cc52d02431e6a969da4dbf837ed8e687ecf64fe
MD5 9e36ffb717a573df40ffe7b8c2f27abe
BLAKE2b-256 653752c33c18f7b87ca7441bf1f5f72237a3745cb2721ad5ea4e35967172c0b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.22-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 370fac28366530ea5bf76150becd51f60203aff3853934a674beaa9ad4a91d2a
MD5 05243ac7fe3d51d95e0c2887908a23a3
BLAKE2b-256 ca7853eec1c6f4b7b7203205b814e53cc911facdfe85eea18db55ec3278e7f50

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.22-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 577f7c57d272153784786c4865291308ed4fd5ef0a078f7b6c33607a94ee1847
MD5 5c0acb78d777de3bab46030d70dcd8a5
BLAKE2b-256 900778ec429008a4c9e1c4ea0415ba612d551670f0d20341b12774a1f3aa35d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.22-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 726e3d238cbbdac30fcec15777792b1300d9c3ea0ea691f43a1d61d80d102c45
MD5 1012ee6c457088c86423b80b12967c65
BLAKE2b-256 0852bbd68f1cafc4e17e713f1d14e07403182961e14e622d9e0a43144dbe0962

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.22-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 20260aaf70e108fca4fe8856c7cd763dd742e5e37ce7625fbb20c4e0b1d11d42
MD5 6d8cb15995a00512fbbba030ddc230c0
BLAKE2b-256 4cb7c15094495c7b1711141e5f426302e91a0902c06929821a761a06b3c13e1f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.22-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a524042002fb67651efd6ccf3fac1ed490363e8a8f6bf99ab36f3e7ce0501168
MD5 5321b95bf5197a8baa61351b760d7b26
BLAKE2b-256 c5cd499679aae1a792d08b8c3a7af938ffb9a26ba47adddcba337e05cb8d70c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.22-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c914c0dbf0cc96ba20e8fb1f367f02e9f99046c1b9677cf85f8e6688337a85be
MD5 acf075778b57b2ce1b4250c05a19a578
BLAKE2b-256 77d1f9f9ba5b8120f50ebec1aac6a074988054e71d63dc3b8dd22227b847122d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.22-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a6ac54c67472cffb3e474e5ce8e19bb6416f71a7b4d16d78390222f87f18a629
MD5 1483cd26b793dacaba535bc6f3eab941
BLAKE2b-256 c2e572044a2fa22fd13b83df999681d7ead2ae8e274bfdb0a4958fde99aabbfb

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