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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded CPython 3.13tWindows x86-64

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

Uploaded CPython 3.9+Windows x86-64

markdown_query-0.2.23-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.23-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.23-cp39-abi3-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.2.23-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.23-pp311-pypy311_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for markdown_query-0.2.23-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 4fd7fec7231e73d0f107f92315d73093bdb8408d9fb8d699ddcee195e15b83db
MD5 abe2846e22228f30ee45dc3fab92ed42
BLAKE2b-256 93c2b446708aa29ba193a4a3f2ea45d4f9ad2bbe90239ab4f6fbbd4def7d1ad1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.23-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 afffa6021609b8978caea6c731c4c407c7b3cda69353fa81c099d01aba471f08
MD5 aaf4805f901a7aaa7223f0a3fe5ecf87
BLAKE2b-256 6ddf484b8af22efe1dae7d86e9a7b98ea933920789f3486a5405fdf1739d3f8a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.23-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 379f0f52868358ad3d47855ff09531618a996511c3cf48b5956c75110716eaf0
MD5 a9d6944204b4cedf818fba5611189ddf
BLAKE2b-256 74591930b75945f417ce1a34d63d74d8d43055dde76bdd85729ee1787ea9cccb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.23-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 2f870603881f7470ee33ba537b59c62f4f17c141db5546308c38e465f7bd9bb3
MD5 97a33fde51173e3166a0d6c8ea55e301
BLAKE2b-256 6b5355772280e77b9c88ec0dd1020922ce4aa39f6404f0b62a8f496d30b16043

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.23-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 7a81fd003a8f1e52502cfa72eb64aadb5bd8a5640bb5a808150cc3e68d3cd302
MD5 49d02c0fa830d892b5427739da5b0be9
BLAKE2b-256 a05f6572cd393e011c0ef776d271beb35694c059e81be4e360051fee8c7eb693

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.23-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8f2a6e2fe35b0c87ed9dd735f1498c5d8d8a93c3a2a4977abe501648347130bf
MD5 440c312e6dded8fe3ed2eedd0cf37111
BLAKE2b-256 c743c968ae95d803857eaa258c03f6e7d8e529da438120b87ffa2ba3e8f99f8b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.23-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 202a4a18fc781a34cdb8256365c3d09e60aad5b7f1005ea7d8aa16fdf25ed958
MD5 45c9c1b9a207d1d381c70fd228972c13
BLAKE2b-256 bb04435236fd10c3c631399263014705fec62f1457568f9259f8c10041777e5e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.23-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b070d3d4d27216ce0a0df8b3216abac5fd9d85ae3eba2a213819c1a652c41a64
MD5 7167a4e361146a27541ce0dea741c68a
BLAKE2b-256 f0ab43ef2693418e20fb876ad53ce61e4b394ff5bc2301dae4ca0eb2dfc475aa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.23-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4f1dd17c83384cb1b7b0ed71b82e7f8accddd3e77ed3513b6e796a76e583f531
MD5 20fff46c70037992638a213004d73848
BLAKE2b-256 6ccc51c1e6c42d11dd512b8fbf9eda1bacc50fbdd0d38d3d7137910eb7b5db74

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