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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded CPython 3.13tWindows x86-64

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

Uploaded CPython 3.9+Windows x86-64

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

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.2.6-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.6-pp311-pypy311_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for markdown_query-0.2.6-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 93cd40fa378f8cfb61f051f2d4fd3b8c9cf1afece52cacaa1e9e504d6d55b6f8
MD5 e55543d0ad35543be3b9e31c4e56990f
BLAKE2b-256 8880e73d5e6ecc6cd54bbd10c9594fa82a5f9bf5d6312c39adfde839784a7299

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.6-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 d0867963e97fabc500eb88ed72bba90d315bbe841ff92b71bd50cad88889acd6
MD5 dda291bd696dc58205e143cdde3c3995
BLAKE2b-256 eedab706b5abb50981130ffc81d6f3f0097085d0933becd8913b4e127a3ad979

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.6-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 be89ab7e9dcc1420262343d90064b8bd4839e787c486d0aa0babbda8a6aff48b
MD5 4ccfe4be312829abb2008c954a41b29a
BLAKE2b-256 39cb88b5f683346fb33f044a34fba425322ab2f4099c8f8dcd3635c9a6abfde2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.6-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 9ec3aca813c5737d46b0030acdc0bd93e30d711e88df9c7031c476ed889d9236
MD5 a01f88e1c1e467d54f93cb0220828a7a
BLAKE2b-256 3e507c542cca2911ee6816ce3009d17f00f3ab57ebda6ef41b5faf88e96fc23c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.6-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 93801ceddce923b526f4681aeac510c6925b0818c9c27e1518bdae12d4f9c1be
MD5 2b1116587e3fb830560b686dd4e54215
BLAKE2b-256 4ebd0147563e6243eda4096b58d6434fd9278b7d76e559cc02dd8769704fd3d3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.6-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5582add36e5f7fc34db70673c9753e472f946199656a0ce04f05c279ab1c8415
MD5 c511deba45012fdf635659771b313e54
BLAKE2b-256 24f5140f67eb37833a42d8ff2d90c6e1c5772e68be2c71011c591d627b6a652a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.6-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 99c42c550e126c1c51bc1a2fc883d8986f457ec919c88b4c3aa0afffd577894c
MD5 694189dc714e463ac10c874125cdc13a
BLAKE2b-256 bc210ded25acc283366d4610b5b96f7386e6435f03a6861577009f9c5f9a9e7c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.6-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e76fb471e9ac2f54d83e683d8b76de9fa07f4936a7294d89f7be6be7267dc12b
MD5 fe17af17ce56597d731cd39928db29bb
BLAKE2b-256 750aba0d1058cbe176b316cdec9aa175d0b8b6740817e8d893790a0763c7fd7a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.6-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7201bc98f93efda645aed2678f9a161b1e9a449ad011075c626ed040c2ef0015
MD5 7f93a0445b6be9d2c93f1f3c2a236d6f
BLAKE2b-256 be3ed5769970a1229c532d1fa7518eae3b86f18ef2dc52dd96455f9a68f76b0a

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