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

Uploaded PyPyWindows x86-64

markdown_query-0.2.3-pp310-pypy310_pp73-win_amd64.whl (836.8 kB view details)

Uploaded PyPyWindows x86-64

markdown_query-0.2.3-pp39-pypy39_pp73-win_amd64.whl (836.6 kB view details)

Uploaded PyPyWindows x86-64

markdown_query-0.2.3-cp313-cp313t-win_amd64.whl (833.7 kB view details)

Uploaded CPython 3.13tWindows x86-64

markdown_query-0.2.3-cp39-abi3-win_amd64.whl (836.8 kB view details)

Uploaded CPython 3.9+Windows x86-64

markdown_query-0.2.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (821.6 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

markdown_query-0.2.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (769.7 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

markdown_query-0.2.3-cp39-abi3-macosx_11_0_arm64.whl (749.8 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.2.3-cp39-abi3-macosx_10_12_x86_64.whl (823.2 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file markdown_query-0.2.3-pp311-pypy311_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for markdown_query-0.2.3-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 0c59a4004a6e111b67d111dbc4543c89f275d8eb81b19ca148902700149b9d8e
MD5 e3807ba716e14dcb8d05c3bbac9a79ba
BLAKE2b-256 c7eca70995d781fefa06fbe17e729897049f2718c4b6bc561675b3ef517954ed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.3-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 13cbf3d24205fb3e2acf4f3a7b770102ff3254041a15241269687d80996d3793
MD5 63f81947008542da850569dd1b372b67
BLAKE2b-256 181b61ec8f4bb2e709c1b694dc54599341188bf540f5acfa062ecc01a008d523

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.3-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 b6586435a0b2bcc08dfcae6e71f30371c1bcee6781c557766c6edda507150af1
MD5 7e80bb4889cf717b3309cd8e4edf8fbe
BLAKE2b-256 79cee834bd075d21dc1d0dbe72e7bc3224f11a6172785499959dbed87a586fb5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.3-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 26939e20f2ea53561c8a6293a237242312b2d8ad4fe56cec456dda82e551e7e3
MD5 8dac0787edc859a79aaaee2719ba1d06
BLAKE2b-256 b5beed28f1d645d22c8e5bf50c438b96dd6dee630203e920fcac952523059f5c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.3-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 c52c1ebc90a23f8a42eb672411f85f346f6f19f62c14d6e322a0ed1b6825746e
MD5 93ee974845302764c63734916c40047e
BLAKE2b-256 488538b1a8bad96e4132eedd79e3249c742ed3f0a0cae495a584ee4ece485d52

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cabb2b13dea8bf8bd70c8331cd9471f7ddc4aa3adcda5bf89982a004d6289b3b
MD5 7d94e47768ba6db786e7196702b6d1b2
BLAKE2b-256 e22dc110928450e3212982f47e5b51b9a718a56a447cba8baf403fc5b913a55e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c6b36e394450750761363a314d413b7c14e7dd38d0c652184e5f3d798fecb338
MD5 41b4542c1b70d1b984520e5c87189b72
BLAKE2b-256 1873add33c3f8a601830b6c095556bc71151875c7c4949fa6074ab4e15be0c84

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.3-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ace128a7899ea201e885bc8d79fb21c36194fd71bf401bd8d2be60f9ae4e8b1e
MD5 51b1f06db9b434849fc529509cacdf10
BLAKE2b-256 6e23b6c1bd63f6e0b53ca88fbacf19bc450ebc06f6f5163565232200d12b4a10

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.3-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 cb8816740c9645d494bdcb5b4fc5b462b4b54eb7c97984a3f54a5c213f2a8cd6
MD5 5c3c1ef5975fff18b02c10cd7d25ab5e
BLAKE2b-256 fb1fd699d21cd2e9f5353a20dde4a73508fdba5923ef08315b86190b46b9f3f0

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