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

Uploaded PyPyWindows x86-64

markdown_query-0.2.8-pp310-pypy310_pp73-win_amd64.whl (1.5 MB view details)

Uploaded PyPyWindows x86-64

markdown_query-0.2.8-pp39-pypy39_pp73-win_amd64.whl (1.5 MB view details)

Uploaded PyPyWindows x86-64

markdown_query-0.2.8-cp313-cp313t-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.13tWindows x86-64

markdown_query-0.2.8-cp39-abi3-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.9+Windows x86-64

markdown_query-0.2.8-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

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

markdown_query-0.2.8-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.4 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

markdown_query-0.2.8-cp39-abi3-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.2.8-cp39-abi3-macosx_10_12_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.8-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 160b2773ac98b50d395194c1762a0dfe4b4043825122d96876505cd339a1ddeb
MD5 5c1e7ab5889f2e9407a78a4f93503424
BLAKE2b-256 12e32b72a833f141748c983d4dae21f916325a8b007a7fe89b13d3a8c821c84b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.8-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 43c8fe990fc8f4cac4335670c7c89b3b8c1b019854b10a3010475e36cff6459c
MD5 fe6bd9844ec7e17885579f1043b5ea5a
BLAKE2b-256 580704af8ee13b64d07c1f17040c82055a3445a38c1a2ed07a945e56ec7840e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.8-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 6d584b2e0f600f68534db5effb3db3e945ce1c1fba7100bdef52b202a6b9d39b
MD5 19d961679d4a8f60bafda647d2d42ed3
BLAKE2b-256 0cfaf5af4455c31b9c8f6a2d69be3538016cbf8e724376d97a4ae3c1709eede9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.8-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 09d1d37a7a2cd074a3871964eedac2556e83e5573a66ed376ffcf7bbd147dfeb
MD5 f2984b79a816ecfe7c610c003397aaac
BLAKE2b-256 028481612c2fd328b7a10fad74c7530070dc01f5c34839312938a8e39cb8538a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.8-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 6d55b32f4a4fbb43572ab5c3914070e2edfebe0f1928bc9f553387bbe744fb78
MD5 cab126eabd341a81da6132f0692b0abd
BLAKE2b-256 faf83ca667034a3f1ae9fcfe3fbe1e15826c44b29129f7592dacd81898ae9883

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.8-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 641f6241a48b280ef2c17202286c420e4335e631fa6ebad87996ad8774094943
MD5 7b4fa36e0a0407e4527cf0a3da32c61b
BLAKE2b-256 8394d8d754ec8908ff4fae057e239f1bddb430e12495eb632b0ff51cc17869ec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.8-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 787e4958ab6987b09002ffa0780fc2f08ee0c25b3bcc5d155edfb60db39a81ca
MD5 8f1197b9c88b03fd359bede09c2bad0c
BLAKE2b-256 8174a60c6378d1dcf9e033864d8158fe5214b5013cf0ee956f76cbde294f19d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.8-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 15a201f05ca5390264b54f1e1e3d3f8f161f6f6a84f0c63a538844674b55ff0b
MD5 3c274edd584ccb48ae68449a596bbf82
BLAKE2b-256 3bd68eba9e39dc3e688b7e41389569a7e99e32c3f38d95b22534baa7925fc5f8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.8-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5426661ec1e4870880084c91ca59a4b4b72f04cc40feb6be36c2aa29825b80ba
MD5 5e2e2ff6e9b7b4ead5fb696a203d789c
BLAKE2b-256 bf98a42a9711462d0a7490762121e37e103f988c7bc5fd6e0eca02d5af5c29e7

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