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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded CPython 3.13tWindows x86-64

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

Uploaded CPython 3.9+Windows x86-64

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

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.2.11-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.11-pp311-pypy311_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for markdown_query-0.2.11-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 27cee08b74038a36ad7230bae54d3857855c1dc115c295aa235e1fae121abbc5
MD5 ca48878c296f1604df6ec761b39c4f50
BLAKE2b-256 b3d362771fa44472294dc9570a0ed35cc4804a9f14d079230e0644959ce770a6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.11-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 3a02050988ba55ab585536210f80be911b24727dcd4952da40789d355959dac2
MD5 0da20a33fdef0a9e9e97fdd6c6267d42
BLAKE2b-256 7d81268df00081dbcdab52c4ba02ffdea542e89c65399d724e75ccac0bf67495

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.11-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 41265915c28af82be9755f8353074df7c472cc506eb44cbfaac452a3bc1ffadb
MD5 ea76342136f218b2aa83716e58f94f41
BLAKE2b-256 a14391868bb4bd4a7d3bfb8fdf9cd7fbe311946f8145afd7187524d8f15dfe9e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.11-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 7661b41b452543b4d5a57b5b863c21969af6d4ceca4381bcef059ec29a3b2082
MD5 ca06f8bbcbedde00b103cb7350d5691f
BLAKE2b-256 18a64815c5f9fbbc3f4f5551e28ad74158c47b6f251787f4dc055d1a067e791d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.11-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 eff96b94365dd984a8052bf4516ac06b488ab7ddb6b5db1fe37884f485ea6f22
MD5 723e4d33dac46811bd5ef5161957271b
BLAKE2b-256 6de83bdfeec6a4e2477af840fa8a14b29d59848d863b471a82e6d13aa2ce65eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.11-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f0691e377e42961f588b5a663356983082bfc48736ebee9410abd7468323945a
MD5 d110830facb9bbb4b367bf55cd002468
BLAKE2b-256 1a094b007e274d6c93b7105c384ca664e0b08aaa0bb07bcceac6f11628d82bc0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.11-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c6d9c9f6f2f782bc4f213c7d0d9a0417ec7675f0774a9b68f621e3f9dd65d69f
MD5 36f8a8c9490e8888210b06f0358feacb
BLAKE2b-256 19c721a4dad8c3e3b1f128d6cb0d52ea1801364a8b669731b8aff16fe431ac1a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.11-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2ca90db06fd05571e720d8853708cba0073d4334432072caf1a4f4641cfa64e5
MD5 bc6291ce4255e32b07fd2cbfef463b56
BLAKE2b-256 d825bbe2591ed851b6aaf5e1394fef23be46ad7cd531c19aa9270d580591b643

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.11-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a6ba32ec8cc851154dd8926027d4a07f56a601b78d619b84fba4759abe463d68
MD5 ec6b449189819d8db75ea031523b7c87
BLAKE2b-256 5140f0cc6b353e7bbaf50ae6e90b67616a71491d4e351cfba9a6f5c64ff37456

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