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

Uploaded PyPyWindows x86-64

markdown_query-0.1.3-pp310-pypy310_pp73-win_amd64.whl (1.4 MB view details)

Uploaded PyPyWindows x86-64

markdown_query-0.1.3-pp39-pypy39_pp73-win_amd64.whl (1.4 MB view details)

Uploaded PyPyWindows x86-64

markdown_query-0.1.3-cp313-cp313t-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.13tWindows x86-64

markdown_query-0.1.3-cp39-abi3-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.9+Windows x86-64

markdown_query-0.1.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view details)

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

markdown_query-0.1.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.3 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

markdown_query-0.1.3-cp39-abi3-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.1.3-cp39-abi3-macosx_10_12_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

File hashes

Hashes for markdown_query-0.1.3-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 ba81fd61147f85ea32c4084b6b812258f3fff8669a6aaf4f4bca06ff9646168c
MD5 6ca17e7e9e6d16d9061ee16b33b45432
BLAKE2b-256 c8be26a867920f61ba6cf99bcd03bba8faf909fc401369831a45a74b30c6a63f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.1.3-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 d083936b4341e12d1b704744a8a5eb06b18b64cb7f3fa4f7cef60bbc54eb309d
MD5 31e7854bf31feeb4294fa909a0301045
BLAKE2b-256 6ca68dc21ddb44f21bbda841124350ada9cf2a6a01d790b161ea194d4a119e16

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.1.3-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 688663af6c55ca5e96db42eed365a5cc21f3b0ae0d39522501bd01dd3e378716
MD5 19fa21e6c00e98e732e598e68ec43108
BLAKE2b-256 e80a351f1f32b382d45a636c1fa9bca00bd7239425338a3504009ca15fa17b0d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.1.3-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 12bf94f238b620290b49aa52540f4f2032ed5b351194103256fce752100352f6
MD5 4a3948964c59b0426a5e23a238e7e251
BLAKE2b-256 899e957619e484a84a2de16bf558b1b9c8f8714e2cee463a29d256aac4dc3f57

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.1.3-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 25546ced22462b6096169f2b23264845aa7c6ec1a71a492aa1b22c1c3ba896e8
MD5 1a8476c72b345a57d0512955c44a2fa2
BLAKE2b-256 4a60d338b6cf7b5cc021e96ded40681a17c83fde03b0e976db48fdc0ba9366a0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.1.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8bc4501bc6f8868e7c1476125ad167cd072d2667e40c4f29276e8a180baffaae
MD5 611329d99e5512527f49c071dc49d6ad
BLAKE2b-256 025a3f3bcc31bee29f9ba077edcf5246df1b22518b40187684fdb6b294242318

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.1.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4814eb2fa918a41ddb62607c45da7db06bd25073e0d93d7dd94abc079ff6f721
MD5 b6bcd3d30a3690ca194792131879e134
BLAKE2b-256 17429705e3cfb70b0a4cda19b0126d9ea484e86e8128c66f2377385edf6ed030

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.1.3-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c7eea0725d1aa88c8055b6309f98e0d637d97c46ba967f883815e8b85c129861
MD5 f3341190a8f6c10dec86f637578b3a06
BLAKE2b-256 d0b7b7094e5c6f541ba11053e35b721938538e9d47ae4b5e7eab9fb70950b0e3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.1.3-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 affc49ab661d3e39c8d7bc43c898f68141ae3506d4f992e5bbf37b923d4e85a5
MD5 3b4379b2d0750c8d9dfca6399e72a70d
BLAKE2b-256 1bd058c2230df2f769de9ceb9ad7e04256b3c5982033791a5ec9cd4ec50555c8

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