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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded CPython 3.13tWindows x86-64

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

Uploaded CPython 3.9+Windows x86-64

markdown_query-0.4.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.4.0-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.0-cp39-abi3-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.4.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.4.0-pp311-pypy311_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for markdown_query-0.4.0-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 30bcd1fe14c50fd1389828a3a2dfb52747b67eb8884de4f017cab4e4e359df90
MD5 f78b7b3e6b133b2c1eddb2a9e78e7cff
BLAKE2b-256 e39c9638e1e7beb6cdecf3b08e53b9d9d5f08831f87b7513c702340de72603ec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.0-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 ed5537b8eb876bd4e72dbdb92a13bb34bec1b359ae8241f29aa9dd4b57102b91
MD5 0bad35bed2fdca7ff2b99ae94ab71034
BLAKE2b-256 bf92c01cbff4910c798f45d26d769c87b8a516d1fc3e1fb443ce90ecd55f7acd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.0-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 4f7533f841d47eda4f7937ae697bbc4bc401907619a8aa034526b13be3a48aea
MD5 ef96e70c0d6c73ac74b09c141a569e8b
BLAKE2b-256 6fcf18317160f7eed1ce563f0c4c87b14d0afb15fb325e05586942745a8678ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.0-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 4894063a5edac349ddf1b4f60dbbea8d34bb148d5c5ddec46de8ab6bb2c07ef9
MD5 28de7fd90c8c6160e12a02c71b2b2699
BLAKE2b-256 aea9e5ae2962e5173ae21b8cb74874b5e35f9b63e217ab5a2cb45a286aa07ed0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 80cc1a61afea4511db57eecdea59e03edfe271fba9ac90231cd4574fffc3b17e
MD5 3fc6d9239e49a6facc5e81909d478c0e
BLAKE2b-256 a81efe0cc066c67bcb1fcade2db28500c21be81fad7f530f90b56a51e2ea560b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 01d1620e7c9c4fc10ac2b5ee2e935f03de76fd1037c3c6d371e03264d510c838
MD5 56baf2f52c48b4d3172569b4be1346de
BLAKE2b-256 4dc19fd95946444c00f405543b7267ab7f5e6a9fccdf3e6c95aca44afd95d201

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9e35f2ba8e3ab1a84675b6f3cdfcfe96cfbea77d7fd1cde3d1f43c15350d03b7
MD5 6261fac76548f49edb8ff13f2862db53
BLAKE2b-256 9c6b2ef85174f458d78c579b7d946de81c37d29076e45190dacc442e5b83278d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d16d0be54e1730922bec6368694d503b782ff084be3a231b93ab42482fb1aecf
MD5 9af2b2c97b27005009a691b40b9af7d3
BLAKE2b-256 68892e2fa589955d4ac7b3c5f511f2ac50f1581c96ffd460eae2b628e1895ed2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 262bd9ee0c9707c0991645889390d595e9056699305c6171ef077e7504c3ec17
MD5 4babfbb52254d01e08ac124fcc4d415f
BLAKE2b-256 102774bd5260c7c9bf384384d6838798017449bbb4044e918f478fd0891f708f

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