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

Uploaded PyPyWindows x86-64

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

Uploaded CPython 3.13tWindows x86-64

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

Uploaded CPython 3.9+Windows x86-64

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

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.4.3-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.3-pp311-pypy311_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for markdown_query-0.4.3-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 893b84e86964aa0c6a3af6ec95bea7a7049c892328f37f6f53a623c62bc5d740
MD5 8d66340d256a53f22cf818072172061c
BLAKE2b-256 513299eae819868632bc55415a95e4c60e21d7843d4ae50bf9f86676afd6dd83

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.3-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 88c687723f06822759f276e1a30e6de71bdc7cbaffbd3e0b9940d6b06bc0869a
MD5 7995ac15c14724e118ab7fc33f22a8fa
BLAKE2b-256 143d680ec0fe52e9667f71ca9fa4867269bf18c708d22ef0a74c8d303bcdfdd3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.3-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 77f1e541bf283f7d733c07ffc0dc5be0da54bf0cd03b5e066528ac3f6573bc5b
MD5 a92aba4ed8c30bb03ad96aab75507f45
BLAKE2b-256 a051955dd51fad9e8a8c635cb5b128f83d82d1553afb659cccd651593fce0fa8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 159b7fda9b76c7032544190693851f228d9f9a8f07c7e9f0c2b581b4df8f77a8
MD5 4975bbf7be4cfbda554d908a0394c0d2
BLAKE2b-256 6ff28c01e643e0d5e247ecce4e437d7bbf6f09f9ecb0be2b408629f09b2e2874

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 144887f9a78a4b92a3ccb75941c4787ba6a8ff2bc270e8aa428feef03a2acefb
MD5 a8d1fd0cf163723f654720abf15e1a6c
BLAKE2b-256 f9f3238125c68c6770fa9761231e59778a0109f1dfb8f53c94ad7b593102b0b4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.3-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4f455260c0317536d8054ec22e314b1c8b2a09218af3c0c80872a797ac0d8463
MD5 b886a91b7711b48fdbb08a20fead043a
BLAKE2b-256 dce0eb9f394a2bf7a07fd181370a0f77163a79598857510bd6e4645c260af700

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.4.3-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6619b27b19899b2574bc9da5677e7777b06f87477a965c60d03436482a557a39
MD5 a0bfb1a5843b10bf9e3a1cddd9639c6f
BLAKE2b-256 121870c2085b93284507b0af47f7153d6b07f5687ba2140ce8d8eb627359db20

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