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

Uploaded PyPyWindows x86-64

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

Uploaded CPython 3.13tWindows x86-64

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

Uploaded CPython 3.9+Windows x86-64

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

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.5.0-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.0-pp311-pypy311_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for markdown_query-0.5.0-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 637ea0e6c0cf557ba78a68f0370529eb2b7aea906a6142db3d0f7c27f0059a8d
MD5 77517a461f094209fc08c520ceffb2b6
BLAKE2b-256 9e43b21d811cfa5fe99f300873cd00c78a25aadf4bb3d5e77850596ccc28e021

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.5.0-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 1f0abfd72943f9e2e55d148293744684a5bbb3e907d27b5af0b43cc48c7a8e8f
MD5 63c2740c329f6ccab08e81d8b03b3ca1
BLAKE2b-256 5aabced51f4f9ec45657deceb49ce9f798d311578c1d0b9c6a4702cc50931059

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.5.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 77d662411c87ef852ca22e944de25e2ed6cc8926a9b778fab44042979c898916
MD5 72dbeea795cf96075567fc041f06841f
BLAKE2b-256 0c118264e85065d42f3009b85e59b524edc8994f5422bef2bda39f9398161a40

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.5.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 268f158db0dd514ff0c229732dd8506ff06d1538ba3fc474c63c4868be4adcea
MD5 b45c2ed07e47b91a75c4d031d79fb30b
BLAKE2b-256 b85179626ded10ccaa2b86b092b2989af916a675dc2c0ac2551a5e7b06dcb11f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.5.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 02ca337fde8c103d67b7c00c565c374064732cf109e94b0e2bd4203660270947
MD5 bbf31b03d4fc65610ae807ffafb9f8e9
BLAKE2b-256 8b77921717a857e7f28afff0a3917720bfc6cb6e91f6290853216e22736200c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.5.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5b912b5223b3ac02f9cd45dd7e766accf5a5c88caf7a58020540f833074dabd1
MD5 2fc002f4ea50a5d465f1f43d040d47f2
BLAKE2b-256 6811163f7734fff9f53b974c9946045c6a2a55cae3502ae492c9e3f2faecfeec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.5.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6edc0e222f0263158377c5b4bf6de28ff51cc44998d22828c77e79b2e9d3bb7e
MD5 61883134b14b21a37ce3f3027799bcc6
BLAKE2b-256 9a5fd1eb24accc5245f1b4fec1135210139cd622dbccba532829e7809171f144

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