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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded CPython 3.13tWindows x86-64

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

Uploaded CPython 3.9+Windows x86-64

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

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.2.10-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.10-pp311-pypy311_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for markdown_query-0.2.10-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 2ff02cdcac5ff37cf6fea15ea1c01394198a7b0d0627ba8b1b6992dfaaa4ac6b
MD5 6f86903b3bc063f7440c01c9292243d3
BLAKE2b-256 180954c05776cec7294faf2a690d75694e1639cd6c8df4e6bde1da3c9a0635f5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.10-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 e3d2779d49cd9e22fde232709ff7ae23837e821e7ac9a0c822942a05f9968ac6
MD5 13a709db7666d6c7e11a77188f1fe61b
BLAKE2b-256 1c6d04175b50ff7dd9132bd734a62dedfd7197055cbb5cecfb92e0c1ed4aaddb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.10-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 0a4cc22fa198f29eb69f0c903497113c178b0a2b5f5cb0544fc83ad0c82adf60
MD5 6a580c82e9f6fc67b78dcaec22ee8420
BLAKE2b-256 0e4047b4d0672026730924e63c1d4415ada9a6f13f2f08114658d888258d717f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.10-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 e9992d4bf6d00d85e73340dfc6ba4280fd4ecd38cf3694c7d97597462802089b
MD5 76c2651bc6f84706b004571a20ec4bc3
BLAKE2b-256 5af1219f2ae9a90b3f5a90fa5c7edc0b50a8cad675999ec15293d18f0e075446

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.10-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1d778ffc6ecf0b941e0203956ef0280201fdc1400f773d223e0b3428e38ebfa2
MD5 2c0d65fc7a44c8a24c8a0b7d1059bbf3
BLAKE2b-256 da921abd736bd73dd2edee1254642602f60e03669f1fd01d873d0aa6b82709b3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.10-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 773dc2e33c79920959cfc5905beadc5ab62fc29ab5eb5e4b989cbb089293027f
MD5 8e4e86763bba7d9ae24d2e9c836d9251
BLAKE2b-256 318950fea329ae511f3bd5da0197c656b25458290befc763a1f7b5470d6731e5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.10-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d6b1bcfb861bea652f269b845e71d26a39ebe9ddb9217427762b3a9991623c9e
MD5 7091a88331eb307c4001900abe061d7e
BLAKE2b-256 f73b473209895c9637287e9da29bcbf563bc1e03df8097735fab75cb552694af

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.10-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f548c26da409afd7f6c422467e518da1f2c8b77675ba15c27cc9d52f35b65ccf
MD5 6e34ea57398878551f67e4fdb36334a8
BLAKE2b-256 b5bd1910eae30c035175c4bdf4d59e1e6dcaec7245d341dcab52d4ad89959946

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.10-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b59af59b35a7ea5925470f5991321d643e42d47830fb6b6e091a72198974c9f6
MD5 e3260194831640a61ab34ea7e6c04d7e
BLAKE2b-256 14f816569ddb9e2d2d08bd4826755ebfcf404d897f10b83051fd2d8ecc7e9b21

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