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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded CPython 3.13tWindows x86-64

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

Uploaded CPython 3.9+Windows x86-64

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

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.2.12-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.12-pp311-pypy311_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for markdown_query-0.2.12-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 41c8870b78aee3f85b936b23dd3f2535eb51ccdc5c2f8ebe0391c5902f461d26
MD5 08f80d97ed2aad15d22b0294b5f766c4
BLAKE2b-256 f38ecaad675c088ab620a64a867e3c9493668db3e6680f75d9e92dba96a27a69

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.12-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 51758940ba039323403426bf3bd6e66ad3cea17a157b60be293f362d7f3990cf
MD5 9f0b1e75d3908ce98cfbd2fdabfe8bfa
BLAKE2b-256 7f656b91f33ad7b2c01fafb15b298cc8996f0dfbd63f2b8ffbc38b9a24ca1f7b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.12-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 9f53b3f8bdf4576b7019676a081e5f972a6ca57aff70697a17e94b1030565906
MD5 8eb84729d0bc1b159cedaaea80f0c08b
BLAKE2b-256 f5d5ec79db34552ff61d37cc051d116e74f2077140c432ac6de478d02fb0c83e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.12-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 864f7952bb0cdc38fc8fd4997bb0a5022afe9657e40ce7fdde38d9010bbffa55
MD5 c1fc35343a61fccd25d78d91c7d1fac0
BLAKE2b-256 e66e55e5228e4ea7d0da366f5ecf3661879d42e7ccefc30d118c17238bfc7d2a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.12-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 149c3ade140529850049304a7f8f7d4d415af8c0f71c0cd39532e8a9f468ecc1
MD5 69b3381e593e6f6284f75b261ce34c14
BLAKE2b-256 715844e5fa55ad8558bb8279b7c6e932225d8c6027c918fde96c23a5258debcc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.12-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fef632edc106ff49e42134777c3df3a57a0218739c4532223b278a1983896f39
MD5 e94efb6834a30c28df6af620a0b71907
BLAKE2b-256 801179477aafc6171e616fc9b27d4d15d5dee03ca0aef4d07b357c43b5bb53c5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.12-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d7f02883e2b463db810859753072536723eb880de0d463182125547055789ca0
MD5 811cb7174652f20372c0e8470341f502
BLAKE2b-256 a19abd58e889fd8057fd483e50955f33b067f36dc1d17298e6152301391b1e32

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.12-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 097b69f3ef289035d99404aca27c28b439df725f1cdcfd0bb2adff0f17c41815
MD5 d84ed73059f26365cc95fa9d4e8018e9
BLAKE2b-256 c3142a2b71d12ea1c7b8c89111fafa085ed2527072dc12ff969c280b3073a2cd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.12-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 aaca31b07b578aecbe93bf9f003c6030f4b65d3d78eed517c40da41a01c2b709
MD5 5e8fbe9035e49433afe9d64358660a85
BLAKE2b-256 edc7458bcc01b30d61bc51a5ed4eb74327164a62d2995669fd410712c5081499

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