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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded CPython 3.13tWindows x86-64

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

Uploaded CPython 3.9+Windows x86-64

markdown_query-0.2.19-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.19-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.0 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.2.19-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.19-pp311-pypy311_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for markdown_query-0.2.19-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 f931ce365b9d4696db27f3441a68ad2a610863da7f3b5f51391b8963dbdc8396
MD5 622602fa34c06e3b1dae10d115da7525
BLAKE2b-256 278f64faa8413487c0ca1e06fc10e966dfdb6896272fb3063b3434c04d3d5fbf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.19-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 6c58626dc2020bc338e843648f841f9a7f42c0e6ec89b697a130e4a0e9a8e073
MD5 64b81115697a875b70956c9bb9bb2821
BLAKE2b-256 853a223e33ce1e2b5c8376d3d9d41c0132ecd980a9fc80e9dfcb74fcf937222d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.19-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 e600c6551e0e437ae2fa619307302a70980f85ed534e45c286a924ef28eb09b0
MD5 61f370f2a49c6b25b7c9eb9e067a8c87
BLAKE2b-256 7450cfab6341601bb8eb8d49a198e20f6226195127f7a69ec2ab85792c6e6143

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.19-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 7d86ee14bcc40f29ef6f4c641b734f889493cbf44fa46bf34d787e485e564ce3
MD5 7a409a6efaf5906faead7f563d528391
BLAKE2b-256 557f6e5fb24f80d5b12e9a44f5070522f3e54afd49f12cef6a26ab8dd4fd7099

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.19-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 cb4256dd39b8a1340e1db4dbe834f6a0dc05aff1f1bcc7a8529dcc874855f1e4
MD5 378e144a473e3e0e9a5e65fbb9c806ce
BLAKE2b-256 11e9456fcaf06f908e26bb348f60dc7f1bf95aab53380370a6f38798a1c0b50a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.19-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a61fd1c12134676ae84d892a29840359af94f856d78fe002e770381fe13316a7
MD5 d3ae61778a6c62901e11a3574e2ea575
BLAKE2b-256 5b92388fa5ec09eeaba38f5f867ed60c51d96d8f657142af9310458755378f70

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.19-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 868d6a7694124f3e53d892bbf0f3db139b191abbb4ed6521fac6956bb6f13905
MD5 3909e5c9f986fb537ef29a1191b9dbaa
BLAKE2b-256 7c4cd1e51035768d2701db1a43f535cadeb1c936cc25636ed5172ea4aee5d63e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.19-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 467f7ece34e870926355f773bd1f09a15d8f86ddc831e9ca8d68b5ab618bbd93
MD5 cf1d91bc1150496fadcd4d9f55243345
BLAKE2b-256 24bc8d44bebafab1d7708f0a766a84798225e8bc3d940575a95d13502159e543

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.19-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c634a0f7af02569a5c29fe4aac396b8d1cd344f49f461a18a8e9bf60a5b21d1f
MD5 3c0c041c52274d0ee873d190e76d480b
BLAKE2b-256 07ae84615d877c7b762cbf76b0b43cb395dc30fdf5a177b5f7192262e353f17a

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