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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded CPython 3.13tWindows x86-64

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

Uploaded CPython 3.9+Windows x86-64

markdown_query-0.3.0-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.3.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.0 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.3.0-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.3.0-pp311-pypy311_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for markdown_query-0.3.0-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 ae1c351200068bb7f5826fdfe6d65375c4344dcc8aa4d63df981d3e7ce907413
MD5 86898e97d49e65d5cbd83ca9008f9782
BLAKE2b-256 05eaea6dbfdc65861774fec662ac4e9d62a86c5cbd0c89918a0e952253dedcc0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.3.0-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 0802facc2e3f342564a77430a6fb55bf86feb3e47d7be1ec610b1a438e5cf5be
MD5 e5696826571cfa3350b22d03b0ab672e
BLAKE2b-256 73347c61a7f5767c2580bf72dd2cda5675899ac81cf906479e03f072f3d04854

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.3.0-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 d6864c0f4610227bc7ef53f118ed1edf71697107fff263604dcb6da51f674061
MD5 2852a3e4dd03c3b7fd4d5f4743454572
BLAKE2b-256 72694ed39dcdc74361d61f4ae7abd2602176c865d071140fd864d6ae8d117b00

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.3.0-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 ec09a57d872ee2006f996906b894b411b0c7b3e09314bb35efa359d83bb634d2
MD5 7535b1feeb5ce40d433616b3b4306269
BLAKE2b-256 b0d0e161ce2105ef5c9745f097c221f40c29b04a8ab0e8944943e0fae299478a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.3.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 68a74ef35a62b334ccb5dec09b11dd8640d31e1516428f060900ce4aa472741c
MD5 fdf0602a8911eeaa9eec7e990f56bffa
BLAKE2b-256 0ae3378509e04f2b02dea4bf1d1f95da85190ca33ad0cb9bef99c35c530ba15b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.3.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 27caa39b0b479cd926a8f347223b1b473651717bfa6ce7d28e48b259a263bbcc
MD5 05e59ea2dc65642c1ee0c3d412a0d8d1
BLAKE2b-256 d992252c723d87cefe1a91f9f6690f730a5d2b85989b950fa6852b01c1398070

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.3.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7ec5d5ce9160f72a0d5ac481f549827fad2b99e54d4b42d84348ef76adb5185f
MD5 d6cb3b85f87ce67f37ad7764f38e102b
BLAKE2b-256 c103ef60dd30e90bd5b4a361aa2a61685ab79d82baaf6c8663df16ada87d6b91

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.3.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d94815e0f435b1626950ee6f059fe2bd2d0cf8fb344c91c998a5ad3af60e493f
MD5 39049f247467a1067cc01a36ab4fb9c5
BLAKE2b-256 a278a78f5a5400d3e773c562b1acefda57778ed853088330a50f64e247374b66

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.3.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ed3caf05a94bd8b32d6ae7385b176d828f2d144eecd8db6ce5d65a695890265d
MD5 d9481c19cc54b876a2acfdc7c0daf540
BLAKE2b-256 7db926d0468be7dd64a9165663142e42f8e528c400e7255b38813dc03a11cc6f

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