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

Uploaded PyPyWindows x86-64

markdown_query-0.1.4-pp310-pypy310_pp73-win_amd64.whl (1.3 MB view details)

Uploaded PyPyWindows x86-64

markdown_query-0.1.4-pp39-pypy39_pp73-win_amd64.whl (1.3 MB view details)

Uploaded PyPyWindows x86-64

markdown_query-0.1.4-cp313-cp313t-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.13tWindows x86-64

markdown_query-0.1.4-cp39-abi3-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.9+Windows x86-64

markdown_query-0.1.4-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

markdown_query-0.1.4-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

markdown_query-0.1.4-cp39-abi3-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.1.4-cp39-abi3-macosx_10_12_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file markdown_query-0.1.4-pp311-pypy311_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for markdown_query-0.1.4-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 fa89fbfa496c36bba6240c03fda92e9d91dbaed869a3521f6e3618f4040d3e92
MD5 fbfc6a022a3b306878d4bec4af4a5f2f
BLAKE2b-256 a7882b9ad469ec19db261ac3a9a5d65999ed8500d6c5bb8131842959ad1df9b7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.1.4-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 7d4e9d7180f2689532116a38269b8328bbb1b986bcf8e366dd96bae3f67b6b66
MD5 2da1944b1c972f8fcc6e947076e1c5f3
BLAKE2b-256 f9f0c20d66fca4b657f33cb2b9bc8d7f3da848032f8cffb30f4d693cf377b727

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.1.4-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 b5b6a7a06ba219f496a5a57eb950af41f530f8f776d1429d526afac401ecd26d
MD5 b9e330ab42f56d942b46ae73b8c19ad4
BLAKE2b-256 b8d289f6f5c1241732327301fedc86c2bbcad544a20af117240c54b9e8ec1ceb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.1.4-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 53b762b31cdc00d9291934f3274acdd5cb9c7925ccd2fe1410043e07f97b9b1d
MD5 b5a7354a72557fd016d5def98455caac
BLAKE2b-256 e6d0904cae0cbcfbdde48824c3053c760d82ed12255cba65ceeb62626f5040e5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.1.4-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 7428a4361c423064d6920d8c714f895d6d5ecafc8b9687f1f718e4a48539bcf0
MD5 eec30b21d513d44c18a1a74916d330d5
BLAKE2b-256 15a2cc6a0770ee592a46f132a179dea1598941ce3230aa40f4f5c518ed11eb6d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.1.4-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8ec360058d8736330b2178894ca2280514ca372bb514f7af0ded976229927952
MD5 7f788b8d67f37fcb14267eb321a7d738
BLAKE2b-256 9bfca8f7c5faee9d8853bcdc79f5ca2cab6daa8e02887b8961b36b8d7daf1551

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.1.4-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 322ba86edef495c453b622fbc1975a7c6da78227b3c970f946929ffd5a87987c
MD5 52a1a88622ba6356a82ca348ae3dbce9
BLAKE2b-256 daae487f240a9b853a6d08facede3cd4a3e6fb5fd3ec329909b3c884aa330f9c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.1.4-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 08e2d13ae3ff3304a2b6a9bc5822a5b7dd83816c48ad45b546f6dcf0443922ec
MD5 739b40fe9e6d36bec0b3a46f0a3db5bb
BLAKE2b-256 2d4df437eaf3fc3606e7e23d005c43565143b9d906edacb71403c76b522ea8e9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.1.4-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8c63785abeae22ff6e1034e39cabe1fd5740182b2e9ae4be502f9bf40d8d593d
MD5 d08c90739b33778a2321c3d1058cd91b
BLAKE2b-256 5dd8023e66d83e139ce35904579507c3d672f754c774d1876f730f551eecc430

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