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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded CPython 3.13tWindows x86-64

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

Uploaded CPython 3.9+Windows x86-64

markdown_query-0.2.17-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.17-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.17-cp39-abi3-macosx_11_0_arm64.whl (998.9 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.2.17-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.17-pp311-pypy311_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for markdown_query-0.2.17-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 209526fb5a745beaca14716e9569464397e88c1f191f5a95110e603e02c1277a
MD5 0d7649f6c81a9c2b590cdbf8b335eff8
BLAKE2b-256 a97dbf043486550f208eb121c2e73d5f54d0079d2fe12811bf0b935299cf1f85

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.17-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 3f823b0d537021e000e6244dab852377c2ab249a79b6230594c67a1a411dbf5a
MD5 122ad193b925a1b09faa927263ebb199
BLAKE2b-256 fb59514257a22db2ecf6f1cf0e6c1113e5f0258be224ce175acc4699c6913750

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.17-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 3b051a527f2dac683de4cee14dd8b0763869754664f7e2400f2d5bba4f937fd5
MD5 7dcb18e044c25b50becdbae700fb2e19
BLAKE2b-256 05c4b9fffa4f84099bd80bdb276b5faf07561a3b0ee981c88829c6392980338e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.17-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 f6a3b46b06195cec6eae24a303b4e8228c5cc17ab70b598662be0682bfc4e4bd
MD5 d4689bcc850da1d09e95cc040a81fc29
BLAKE2b-256 5f3bdf36560440183fdc23d4f94cfde0486dc3472313bbda47e4ca6507138dfd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.17-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9e06fe82b52c4325ee32229f5ca2492034272d7755a5fb18f2e51a3c7f6c251f
MD5 f22fb8d8f951e5296f71645cbe1e5bd4
BLAKE2b-256 c3f373401b693ba1ff3487e02ab9375fb050e5be58e56ea0fa589d2abded2ca8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.17-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 718c548801b70fae89ad33fab11faa79455645c049ca63d338145ec48a77c4a9
MD5 d0a8c635b5d39aaf5ae99ea9c8ab2430
BLAKE2b-256 1f296a7224ec4f26db2a9b3cd014ca082a8b5c603f1aa1b40b4220d4e791c488

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.17-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3e9da859d7869923161326706a69f788675699b908045fbb0dd767139b5adc82
MD5 2b01fd2a4c193a598fc180e04bc547d9
BLAKE2b-256 7f7a370868839f88e23e711ee2f1e1090999e322b52fb4cafb3a63834f9e9138

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.17-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 694c37e251ae378dc3d9beb0c504687b1c39a8240029e4d1fca0f0749b7fe092
MD5 1ed3bd385ed66258bf85065c2c3c3936
BLAKE2b-256 73c12f3b271e5041dbe638bbe3bd07e90ed0f499091107b643445fe5a246f3b1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.17-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 17c8e6edf144a652759bb3b1b2d16faa8b04b3cbaba3022beb33e2be3bb46cfe
MD5 51421e00c2cdb76746a7c0a624ad7312
BLAKE2b-256 2f4898b8a25f3559eabbd7bdaa02d9f5e8f14619b05007fc5c518c0aef61adb6

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