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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded CPython 3.13tWindows x86-64

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

Uploaded CPython 3.9+Windows x86-64

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

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.2.20-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.20-pp311-pypy311_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for markdown_query-0.2.20-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 d0c7d249b5bf0563f6c1d52f49d92237da5161abfa345833afc3d26f65c5dbf0
MD5 3a2e2e886b89bc6a75d64c619b3adef5
BLAKE2b-256 d69704aa99554bfc336a3634cd6fef76eda59708542b2676456a6a6895f37a2d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.20-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 643e08e07221121e2f82c5358b38d9313856dd4095224431b1bcb37cdea89345
MD5 6be83a85e0395f2861f74d7a44efceab
BLAKE2b-256 893b467c7fe7dadd4f7d0644437130889df27f2d9a9e38c6924056d014acba45

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.20-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 efbeef50b22123d90e1c31c5986685454d1bb903e427b159d82de85ddf464472
MD5 74e16f60f943315425f893b849f8e40f
BLAKE2b-256 15665f173f1704d334c6eb150e594c6b259ee5746d482fdb5cc5f7a9b368a674

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.20-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 5cf2bbc813b20fd553d7bd662a7bec5bc3b301a13f17b6ee323dfd3eb9c24f8c
MD5 e71e9645cdf4dc9f2afc29e7996d6798
BLAKE2b-256 197801d2787a3f015e7aaf944468c12cc36f0cc8b4670fc52893db8ab9eb66e3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.20-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 b99209ac94cd0f9a80612c886ca57302474ff5fa13d3f2c09a7105ed3befc455
MD5 a5eeca408f3327fc8c5a1adbb7cca013
BLAKE2b-256 31b6bd40d9598b365090fca0bac605ef2fbf16a14385e659a831e3cd291f3131

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.20-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b44b90c53eafd6590c49dbcfde43404ee9336a7cb4b7b4b8860175058e9d2882
MD5 d76937f1fd8d7b00264a4b8be6e8bb5a
BLAKE2b-256 ff35791d8e42c69ac64fe56f63152f9e51398caafa2db3aad153380fd56dd6a3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.20-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d120173abc4cefba8da5f0e318b5a61fa78a1604ff6a7cbf0144ab9c2d6e280b
MD5 089bb88940720e04956da4e43fed9313
BLAKE2b-256 b824804ded065e52fbadc572fcff5217f940e5b13b231a1b2a18fb289ee9819e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.20-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8fd389ee34093b63bbcc941ae29c6a6927b97ddda30f5b76673c88d4a8b4afa4
MD5 defba93c187977054c95d0e778eab342
BLAKE2b-256 6e65c0f042d36cbe5e831d66c81b245024a95c95e63687f76080e39ded048ba8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.20-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0d57603fb94b99a5357cc6a57619b6c757634638b7eea8a35f251e2b62c68b05
MD5 39e7d7eccc7edb74fce7d3ffb6a73f3e
BLAKE2b-256 4fd9525ca5029a1b41200fb54084a12d0bdc21aa12541f8afd0db79d5ffeb426

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