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

Uploaded PyPyWindows x86-64

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

Uploaded CPython 3.13tWindows x86-64

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

Uploaded CPython 3.9+Windows x86-64

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

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.5.1-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.5.1-pp311-pypy311_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for markdown_query-0.5.1-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 073911be7850b635c9b75c78d5c117e4e4e3dfb9e48cf7aeedbadd2b69e9ee38
MD5 e02fb744e1bc93b116c9884d1c6be004
BLAKE2b-256 cb72802c13627e0bea121c850f76a14bc13060850a8c7a1f4656ec2f7963f236

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.5.1-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 9663cda3f097da17051eb9494135746fd59eb9cbbeafe375f530d3cb355cb06f
MD5 d386a3128f832e5d83f2770a86db6fa7
BLAKE2b-256 0c1ecc4aa3bb1e0390ab495ac840485e106ff50663f64e6be38c3a6db4aa1878

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.5.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 da36cfd8daadf9b1a6e7c8294666517903d967df2713b0864e59475ff6b18962
MD5 9dba92f4eda8d72ad2e0809994bd69e9
BLAKE2b-256 5a94eaa69985c8697dfe5d89ed4c4590b0ce94d8af9f465dc406d464680b9d9e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.5.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 144a200af2ed26901a2f49e624b39fdca9f891f88915131b0482de3e92ca808a
MD5 eb50089ba15fcd74384a1fefd9c86d5e
BLAKE2b-256 e7d3093a33f4bc5f74bf39d04c5b2409e0d6cc3b796508d3a8346c9bb4377ce3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.5.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7f59a0bb08b3e9e57ed76b47fb478b894744a19223fd25f1748719b9ba0508a0
MD5 bf53b1fa0fbbaf685bc1a7c5fb4c31f0
BLAKE2b-256 4f67d0a4f72022d1b0b970b4e76c3992ec7d875b397fddbccc9e603cb6f18394

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.5.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0a3be0514e0c23fb66101948edeefbac7b6c1786cde22e5805fc52a44d83c230
MD5 93b090b5b330658fb333e37f37ac69e7
BLAKE2b-256 4a2b39c00c0e70161e46578c63366c299138b6decd9aa1b5a8a6be411218ba0d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.5.1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9f4e59e878767379681a001aad9dcb532fbf3129c5d6043aeb049857ca9c7aef
MD5 4ac2258cc1fa7dd286cb3ea18d86a368
BLAKE2b-256 ce957fa0aaf0c51908d0d117644b6c63623fec4adb13426b5a17ae471c31fe60

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