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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded CPython 3.13tWindows x86-64

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

Uploaded CPython 3.9+Windows x86-64

markdown_query-0.4.2-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.4.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.1 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.4.2-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.4.2-pp311-pypy311_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for markdown_query-0.4.2-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 fca586533efdcc4442fbe23da80570bc9324bd73f201491c90523e82a5b9194a
MD5 b777a128675f8ebf4fe54fa07e703b0a
BLAKE2b-256 e1b895b18680cf296331af05028d4a872e3cab562b091432b5c6679fca0fafa1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.2-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 6c7a34ece52cbbffaf375e8978440429932f606c1f6eda8930881ca038029259
MD5 c7889ffb35a66176df897ff50f5792dd
BLAKE2b-256 47311cdc572f03c9f8fc72a3eec319a1048c99c7795c9b8ed456342108ab961a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.2-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 c685415663b998d07ce9fbebcc6cd68a1dd9b28f1b72fa90d481c2944fa42fee
MD5 6a8329ad1106a43152957b5b85d146e6
BLAKE2b-256 5910c0856308e81bffb52ba39228e6a4c6141ada8678f14bcdd27a4590f65067

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.2-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 2ef40d56aa95f7e99626d1cf34ccdbcb51a712583c6ad2ea624c87eeb7b84ffa
MD5 95a8b511104b7ad98125361d45af5847
BLAKE2b-256 3c5e18c30be378351068f0444725e65c0f2c41882d03cac0e4574b8a43f23ec2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.2-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 3bb5415dee2b17e7c0b6a3ce82f969dbecc490a5639d1ca305d1a61f25e5ed33
MD5 096074a9a28215467405a4bc1fe900d8
BLAKE2b-256 3aa841ebeca3f35ae7138b4e4cf07a7be489a7b8c3c9c88a7e539f56dfa1100a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 075049b125a769ae3cfde580bfc89fe4ceb083a450878a7f0736b1504afb6992
MD5 6cbf29bcdf9772bbee218d2252f64628
BLAKE2b-256 21e7afc1839c5524718934006ff9aec5e7bb1bd21de7b725645acb37ca5a7554

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 bbd26213875bd0a086d6aec5efb911120e8b3df7ea0adc28541bc821d18e8568
MD5 6bbe7618a43c94813a0f6ddf8c772baa
BLAKE2b-256 73f9edca7c1eaebfac6f014d7a32982ea4ddc0ec0684b2e426d9437a96164c10

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.2-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8c0b0a4b0b605be400cb6c8190f9fd28ecdf81f11893e4e649c8d5fa642c48b3
MD5 d92b33ed7e2616bab8374a4a328bfff1
BLAKE2b-256 344fb423d3b862363c4be5b654bdeeb0680eaef4ea271439f390d8f1d6dfee1d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.2-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 78f7812e6d1b24391dac5e8eb605f4e91ad66293ec0e618874afe28047a473a2
MD5 8ebe3f82b0b4a5756a42bf7c33ee3bd0
BLAKE2b-256 3cee9d080c5ffa5410db47f66cc65098c6fd0d047429fc591eba0ded009471ca

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