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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded CPython 3.13tWindows x86-64

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

Uploaded CPython 3.9+Windows x86-64

markdown_query-0.2.13-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.13-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.13-cp39-abi3-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.2.13-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.13-pp311-pypy311_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for markdown_query-0.2.13-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 2c2da22c565b5daff76bada7c7d21fcf64b6bbfb4ea8e6fd18b1993de6cd6cd6
MD5 5fa9a60c51334a3f6639ea86d0b0fe93
BLAKE2b-256 f19beeb2146b77759999c58df53e57f88cf7bffe909307b08801dee0ee50172c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.13-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 bdcea43965dbd346d71c91f8da5a2f3b6725c80a8e47e3ee1f85f207f200df6f
MD5 dfee8d668363b21fa692c3ea83e0c6a1
BLAKE2b-256 18c564ec3d406b854f63826df10982fa2a6bb160be8832a4f967918ecf5c0a20

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.13-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 5efbb6b585b42ceed6159e3de31d904580f8330f775c0415a1571c1eaed4bb2f
MD5 8f604c462ca60ab9f14bf894403850a6
BLAKE2b-256 b7aed044f169f19cb5e3333a1150c3176321dda1e2f0b90ad3deb609a3d611d9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.13-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 d64305ac211270cbba9a361400d9a4d4ed205e704917a10e0f6fd5d0f5bee4a8
MD5 57be41c737fd77ad54d1e09c992af90e
BLAKE2b-256 ffc2932d827e1c5c78491ec5d447aa4b4e5ae09c941f3167ee75363b7fec5391

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.13-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 da280822ca31eb161cc3097a2f88ed5af475c37de96227345ed4a479ca6b47e3
MD5 0dcad63c85a532b8d5b5f84fc844fbdd
BLAKE2b-256 56beafb56cfa962b37346fd22836ef558c159b2fff43444054a475d2fcb13fa9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.13-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3273ba30a7ceaf06d050c90e86507ea1878c309c26d756c98b94cc6f06e43d36
MD5 8e2de51dcd84d581be1051982b0d279f
BLAKE2b-256 e43ce6d53af6b6be3d33e8e663b4a6993c23425f50801d154f7711f57ab7b5eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.13-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5cc6e61e5affb2f631d581de78fff00e93091482fe73d2fbc463c680b31572e3
MD5 46cef842401bb64422344f136a02b1b9
BLAKE2b-256 4ca861164c9a475b2bd05e8d4bee49d56b159e438300ad26cee26d3d05ee1dd0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.13-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8a6f22592cdf43d32337dcb3cca237aec596cde3a9967a989b2317bf6aba7ff1
MD5 154e59bd92850ee4a2bba56c96552ab6
BLAKE2b-256 3a93a26e68505dfaea93db153284ed783e0982580e6ad351c5d34e0d71844c75

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.13-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 06366f081508d9fa1b150a3394f47dc4ae705c188744a27ce9411307b4b09cde
MD5 ae4e5fb41dc94515a9dfc5c15ea751a8
BLAKE2b-256 22c5d94b057af99b61017b230cf4c2d342ad1574849edfe4363237fdd3e95e8f

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