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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded CPython 3.13tWindows x86-64

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

Uploaded CPython 3.9+Windows x86-64

markdown_query-0.4.1-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.4.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.1 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

markdown_query-0.4.1-cp39-abi3-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.4.1-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.4.1-pp311-pypy311_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for markdown_query-0.4.1-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 d8a0cafd1a8fe49e62b9986f98af51b51ccef93133e2478cb96c2a3157a6cbce
MD5 1f116afa0b95498951ed8da0e222e6f9
BLAKE2b-256 082f9e9d0101fc7a7ba582e1db527bcf76da8db7367c9149f34dcf1a73b30e8e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.1-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 c72e436ed091634d25d31b00d9cea5de0f3bbf17aadc4424fc96254b9d10d391
MD5 af7c0d29bb67e36dba927760ff482be8
BLAKE2b-256 a639da9922c81cda20091de1ea2e52ed0e9dd0e83e3b7a547757ebb0ed4532dc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.1-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 bac62cb49b32975b971f582fdb75d1300db5d1911abd66186dd4cb4896a52dc3
MD5 c0ef593afa9584adb38d0b627b11d2b8
BLAKE2b-256 d56bbb155f6e9e35d0035656f908c1fb3c9dee3196f157e24b510ad7720b8723

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.1-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 16e2f35c8ee3b08aac157357e59235df909fb88c2c4d001fa66979404e8a6d02
MD5 410881e24562324d09b8506f043470f7
BLAKE2b-256 fa1667107bb828bf9cc54cbc48872be454a8c329a33c373e3c967bf43f24d667

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 7aa0d6bde9bbb3510dcb59ebb3c33033cb63c0199122bcbc3ab11e30b0fc434a
MD5 a68f3a3988cf2ed786171ce17ba62db8
BLAKE2b-256 2fbbc126a0d06ade2b16ef602d85a6030804a263363717c0b63a730db62ba167

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2b168e259c4e96860e2cb25a4417556bfc52010c8c3a39241f5204dcb40c4170
MD5 9ae5796caf644a6f477f528692234537
BLAKE2b-256 993d4dba4942846467a3e7018546834c36438afc335d3df09e7db354eb05a17b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 dbce58e0e77c1cf6b092062eea03563c33cf7c8813003c15d3fb55948e1291cb
MD5 0d678b55990f9cc173d26855b673ae60
BLAKE2b-256 0a9301b30984ae3a1de138bd7c376a2ca7415311868f4188aa638673b9046e00

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b13047d411d10111cb5bf622d5179c254cac1c21d386fb3a5754ff69ba2dfa8f
MD5 0c0297e6f469fa719c0937c83e5d3ec9
BLAKE2b-256 a43752e8d1151f59fe63e321cdd9a3ea6b6674ff7732419068e6afb64c0694d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 95efd677d14d000802d75c6f1bc93b4da1943c9c44908e744ee284866cb8aaef
MD5 486a86577e890a3494e83c41f2cb3cf4
BLAKE2b-256 f432ec3c6a4cd87b45720af9bbdd0bc41e1181940747f75582e78118f9ee43cd

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