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

Uploaded PyPyWindows x86-64

markdown_query-0.2.2-pp310-pypy310_pp73-win_amd64.whl (836.2 kB view details)

Uploaded PyPyWindows x86-64

markdown_query-0.2.2-pp39-pypy39_pp73-win_amd64.whl (835.7 kB view details)

Uploaded PyPyWindows x86-64

markdown_query-0.2.2-cp313-cp313t-win_amd64.whl (832.5 kB view details)

Uploaded CPython 3.13tWindows x86-64

markdown_query-0.2.2-cp39-abi3-win_amd64.whl (835.9 kB view details)

Uploaded CPython 3.9+Windows x86-64

markdown_query-0.2.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (820.8 kB view details)

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

markdown_query-0.2.2-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.2-cp39-abi3-macosx_11_0_arm64.whl (749.7 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.2.2-cp39-abi3-macosx_10_12_x86_64.whl (823.0 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.2-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 c94edbf0805f3622d3cc96befb39021262811ca7977a2fb7473d8b82b3d7ab49
MD5 42b9c4fe8864818ded05c0abaa0c56e6
BLAKE2b-256 007f890e20039bf5a517659dcdf83b5439ce746a8a06a18445a59c3d079f58ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.2-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 40fc1e4ef60e6afd661b9bc0fe5785dc2ad116f9e757fc270a6c324429421a96
MD5 d49d0c122a46bf0bd1b59ec2db08eacc
BLAKE2b-256 1bae0452feb963de363c233856cda5d72effd4914f86c9546771a1f11d306d8d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.2-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 a3426479c53869f00c95ad66f96459c69da563c16ca45718fe335496b2c99469
MD5 71cd4af11a723c1f69bc44903b276204
BLAKE2b-256 c333e6d51530319e48754dd48505752f7919505e4b64649e6f358db03f071750

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.2-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 87f3d7a72cb22818587140f6b8a1e170c8986693fd905c24237784ef1b5cefe1
MD5 7eb8044f0e0f1a89b9ddac302e1e76bc
BLAKE2b-256 d95681fdec393d409243dca0b957673123ea4d8ae1561622acdb090d0570385a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.2-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 db4f0b3f29b0f3fe5af84a600f0a1f97985337aba1ea30c7cf4500b77316e1ef
MD5 0cf79f27d4102f79fa475c5daeaa7dd9
BLAKE2b-256 ad2957fc2a45f2929b552c145d1f07f0a7267f3f5a2d95a190d358c5e6d6f89e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 659c6001223c10b2eb10ff41a1b22620819e622dbecea185171e095df8c86246
MD5 ed345abf44ea18bb35502026a50b0215
BLAKE2b-256 a53650faa96903c5fa14cd2f18faf0639e309481dbff09d5632971126e889165

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ede1939f8e2246ff6078f5e2edfad48c35fa2665bd19bab03fc3fc383773ec8d
MD5 613dfcddf3b3363f28a2799566b8a153
BLAKE2b-256 22a5c92cdb9f3911495026273b2e94c267331052bf99d51c1a16f968f3cc2494

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.2-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f6a6b5919afe78726a9262c4ed2b639ef184f6c562d205e9d51c61f4491f7347
MD5 77f2fffbc0092402a8af231e337a19d8
BLAKE2b-256 996d0524cc6c9a7e14471441f1a2c9f853166d1bbb64b7277693bf8d86c219d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.2-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0a72dda1292860941e9dde74b997054fd735eebaca07c67ff0e7347e5cadc788
MD5 e60423ac28c459bee9d0cf318d6123dc
BLAKE2b-256 1cc96253fcfdbaff5133de23d823f7ddd3f8ff03fcdba874f2430a672bb926f4

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