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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded PyPyWindows x86-64

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

Uploaded CPython 3.13tWindows x86-64

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

Uploaded CPython 3.9+Windows x86-64

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

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.2.14-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.14-pp311-pypy311_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for markdown_query-0.2.14-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 541c69d9913b67e8de89f2ff17d0a749cb1a1d91855c7f544f7cb0dbc6dffabf
MD5 1b211d1b3757cc8cde20383fe85f07f0
BLAKE2b-256 b61eee53cc6bf10c67c1d1840ee591e262665c6b26ec50cf4fd09c9f0637fcb2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.14-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 e3065a37809d08fce19db89b987717d68819754717563ac0f2c091f003a27bd8
MD5 e1add5cbe4ae6bc1c9cbc0a438445822
BLAKE2b-256 945c4ef5f185d4ca9ce4a285775c522705547d44121724e7e28d8c819c34677d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.14-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 30cd74d212c41b94fa98985cda5ee03447c43baa5256c5bc5e7a60ac543a3090
MD5 217f955f86d869013dbb14cb704b69c6
BLAKE2b-256 29fd021b236ed1066b8ae5fafba5684f600e416783a72000ccb833e638d30d9d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.14-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 9e114dff0c7a71145e3744fa6774a7c25ffa2af9cef6ab0033aa1ccf6c8bd04c
MD5 f5cd4be3aee387839a020fb115bc260f
BLAKE2b-256 292ac78b6b52124b2b1b1d90ecee41b74918a4bc8a97ac990edfa4b7ba7212f4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.14-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 20b4cc4aa825880a2996c2c285ee9dbe3b5fed7cc45e28189a18b4fa890e9dc9
MD5 fa01a5f9395253fb0db126fc88b4376e
BLAKE2b-256 1218e2d191af29ad33691cae25e198a012139e632171a347b83695dfa8e433d9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.14-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ecabcd6daeff8c22d4484407a7d16d2bbcb25db2b361f33808ee3dc0e5607ec1
MD5 1b5aba8d989de230a2e9abf2ab68b9d2
BLAKE2b-256 54a81e082d291001a12a8cfa51fc5c22bddb9aee03cbb6fc02390637e31cacfd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.14-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d5b5b34a166f4ff7f8ad58e97369c6073d6413449e7370e26e82cc82434174ff
MD5 6ae252c23e94de636390e50c909ae818
BLAKE2b-256 56efef7148d066df735613e676dd1f576b2a41c255f672c4b0ca116290ed38e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.14-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ce4be07fa27883b4de292a29759a38d22d0138a182e3ad20a51e760f73c9d68a
MD5 d0c1e145abf13a1dd6a0d0f14c2ea10d
BLAKE2b-256 c3693987937ff824ac749c092d50afcbada18f52b94845ad20f8d68728039069

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.14-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 527a301b35d61ecc1d36d7bf28269301b8e239c0d44d6eb31dd0362dae60dd48
MD5 5f510abff21e92a791d76b4fb210fe29
BLAKE2b-256 3ac2253971b75c5986efee1dcc5701a165462e6f731a503a2478af3a4a15c395

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