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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded CPython 3.13tWindows x86-64

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

Uploaded CPython 3.9+Windows x86-64

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

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.2.16-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.16-pp311-pypy311_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for markdown_query-0.2.16-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 f94b784286aea92e634d8d7e0313e1fa07b15fcb8ddef17c826ed98ede377356
MD5 03f7ec09d6d87cd801c639aacba12424
BLAKE2b-256 e1ea95b68ec4f03567aaf0db789655087f5c20b66113aea8e396918ce8c892cf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.16-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 76352d0176ccd1612fb312dd0dcd1559f7cd21c55fbc067b7510a47b127a1c6b
MD5 78225740db6ec0a4e46a653a32093408
BLAKE2b-256 a1edd58d38cc314f450955bceb295d5801ef7f661d29423c2ebc6dd429511bce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.16-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 8150e3d27d3cb9649acdd312486fc94887eb1f6f4a6755a97fb22584e365b913
MD5 d284b371262c3a4dc4d68047a43e7704
BLAKE2b-256 fcbe5050aa5941d21a3dc7df14c93e378f963a4d37599bcd885a874584e0786f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.16-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 bca4f2b6cac7a35f41f60525352cd9cc415333dd51a46d7647dd0331002d8b38
MD5 5610d3e780bdfc71f865b42df8c5a34e
BLAKE2b-256 9b200c71d43086cda8976f880c20ba9c714d8a1ba28d32af4d5f7232f1db14d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.16-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 c44c71e650dcd5027a7320a45e12bf80d07891244061811509d3fee0993c6f36
MD5 4863a08efb6f65b14ef981700743772d
BLAKE2b-256 e7691824a052f65e7c88fa822aec39e9475f40a3cc0aec10d2cdc0b86dfcf1f2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.16-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e04e58db7145d4abaf3ebcf1fd535686eafcc851e1cc014d4d25a2e24633ebd9
MD5 04b9c69fadb5d1f1df180dddce812a6e
BLAKE2b-256 c3b5bdda8e0829d2ef87f8b9c8c6ff4193b41a33f0afbe3f8d4eb24057e6a4a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.16-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 edc56e208b0a08c7d4c5039d29f949ab805d1d5f9f0e050e4d92be7a4eecafd5
MD5 57939b7e41df8ef07f56025751cb193e
BLAKE2b-256 b91943336620d5b9aa90d3e10092573b6cc178b2719459f1456fd24f301b01b7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.16-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 25aaa19c64b93b2ac28a772f91258bc5a330afba3e19dc8a69e886b0c5826129
MD5 900a33cd7f407c50e38ee1ee800c0520
BLAKE2b-256 82f1dcbee62b4e7f882822d00b693944e6e5385b2ebd19cf188a1afcb4ff410f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.16-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c6a8914a6b7864f333f3048c7e58c6cc4a9b9e70b61b0584b3f90990773608ea
MD5 3a05907bf919dea69cd774654e7ed231
BLAKE2b-256 f9b2bdb7a065a25c9198413dc6d814cd0a775ae212a42e7089f6e1b20fd9d0c1

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