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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded CPython 3.13tWindows x86-64

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

Uploaded CPython 3.9+Windows x86-64

markdown_query-0.2.5-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.5-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.5-cp39-abi3-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.2.5-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.5-pp311-pypy311_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for markdown_query-0.2.5-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 d7e3b7832696deb3737a2093b322981806bb92c0a85192c29eed888573f1cec0
MD5 16dbb576a33f903fe9c0991d1a98fbf7
BLAKE2b-256 d9a5f340f792fc3df6e50ea925bc18c4899b50007edec5dc4290d829232b937d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.5-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 3d2275936f98a01d23bc690cbe0ac67102aed21c40b3ab755ca7027b3688e605
MD5 dc0e93927be87597c9c30ae564e19cac
BLAKE2b-256 ce5925b3401125ae1834bd322a592b1c6706f8caeee140a0dcab08ee75a56472

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.5-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 873681bc7f72172509b5bbdfae998e0a80e84dfd0a701e6acfce646e239b4abd
MD5 61fba7633f8d3920626ca3d7dad4dda2
BLAKE2b-256 2c744c27d02054c4b8e647eb523e7d62b38a9bbde3bcae9286d383e98ee34f6d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.5-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 100d3df05894079cfeabdbdc6449ba0d93a6ac32a061e14124dd000fb0593a34
MD5 810a36ec53f8f40e5ad83ed5e56ea772
BLAKE2b-256 938ea0b3733e17a8f1ba41ce245a32250b3b6d7cfca29296496150665045bb0a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.5-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 190837d1dce127ff0863685fb7c79993bd6dc3c1a81926ec043761cec789e06a
MD5 d78628980dd23dcf1e2ede882828f6ea
BLAKE2b-256 ee322b6cb88b027b50c4d8b6121d40f8426c343f2b7ed2ba820de847e6c0e6b7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.5-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6d21bbeeb5c918035a19e0abb273a8732ee86fa779a6f2f7ce3ff9bba258fb59
MD5 f08cd745babde23413adf64f87150f13
BLAKE2b-256 13c84ff9f0f60111b26bfde303256b4e6792ae51f6c5dc14daeda866276d50c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.5-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c9d03711bb63a7c349b85cb89ef23b3782259e2c03fb810539d6af5f933206bd
MD5 fb8dda825aecb69a6886d4452ec4fc87
BLAKE2b-256 fe965d92784e87e46eb16a96732c8f3962788d73f76701a1dc300fc0f9ca7bf6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.5-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7170daacc2ee8ee8372fb3fd77c860b2617a758e5a62d28ca4828999b709569d
MD5 1d710bf1da2444374aaf67d2864cc16d
BLAKE2b-256 e5c3c9e5819a5867850ddb1bd2d5f0c88b3a5fc7e68f55ee0f2dd7b59d02089b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.5-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 22fe8339e8b835d15ade43734aeaa2640178d3e0fce62195dfda52871632770f
MD5 2bfa17561689ade1994f916e659e86a0
BLAKE2b-256 71e565e08a7d6ff993608a021cb9750427c49992faa243a8c13c17ff49476e1e

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