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

Uploaded PyPyWindows x86-64

markdown_query-0.2.18-pp310-pypy310_pp73-win_amd64.whl (1.1 MB view details)

Uploaded PyPyWindows x86-64

markdown_query-0.2.18-pp39-pypy39_pp73-win_amd64.whl (1.1 MB view details)

Uploaded PyPyWindows x86-64

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

Uploaded CPython 3.13tWindows x86-64

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

Uploaded CPython 3.9+Windows x86-64

markdown_query-0.2.18-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.2.18-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.0 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

markdown_query-0.2.18-cp39-abi3-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.2.18-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.2.18-pp311-pypy311_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for markdown_query-0.2.18-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 a956076a8c0fe41171834ed841fcfc7ee005003f76d860c894b54d89c21f17a5
MD5 7075f2f33acb2a6bf36c4976562add38
BLAKE2b-256 6c20ffd6c4ec7e4494951dfe734c9aac363a819502dbc6e3d64cc6f2db2a3691

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.18-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 c5e876249f4effe5a68135adae45f9868eba36f7970669cb2a7a9e8c82160a1d
MD5 9430988eb8d79b1e483d9e9eb951ebd8
BLAKE2b-256 691c50dd91ae632c0044be64a9a3be36faedf27334cf81e18283a38c6c558ca9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.18-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 f039ec6ea2df27c7354f193f0fbe340a5423b5b49b969c25509641fc6e5e223f
MD5 d79961651c168949c210bf2a36d78eb6
BLAKE2b-256 7c1562c4e827e5ca1c385c446861a570cde87ea8f461d3d0a5d34067a3939b4d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.18-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 0d5296232f33cd6c76f05f15077e6b9894a55fa3e66c7d8d8581e011fe992025
MD5 0662296489b4963d0f7285b28e644c38
BLAKE2b-256 1eece7cd469e58a6ab3069f3e9026dfac3b620d95d4a03dab9bac8c73b4242f2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.18-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 701dfa95b827110b23fffa0830f705502d7a3890a402dd870a74a10d50bc89ca
MD5 d51a06aff4f4e05c95f120adee9a9ae8
BLAKE2b-256 9fdb9ba6cfaa7956b7832928ff1986bf6d73bfecaafeb7e2d8dc19b680c06fa6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.18-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 30246dc65f91b3f2307bdf261b4ccf3b1966b249daecee7e4ecb954b12aa1ab8
MD5 bd4fbffa420954b3022efd826d2a9c66
BLAKE2b-256 c5ecbf8fe72ecb65f4971001302181adc4f250bc0a882458f46cea676ae95a35

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.18-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a6b808833573bfd1db0a33e96d3fb437f4c3d6fde94795fafb862c874e557902
MD5 9714506f6d7793e9ee480e1a9671655f
BLAKE2b-256 97f087acad8264d325f3eb55c5d73c92bde8c9b2697aad4c868cb225692d2d39

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.18-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dfc5430d67406b1b6ec67b408414bc7a8b13759d411de3e567f55ebf86c1357e
MD5 03fe97c42617525ea0237f42df05b60b
BLAKE2b-256 c4580b04273f7e023e733546cccb9fceb9470582468e488849af7aca44431c48

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.18-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 bf664bd31d8be73dd651f0b36b8e5778cab0f34590a5368bae490a66c70adac9
MD5 bf3371df4cf1ad312672d5617b7ab0de
BLAKE2b-256 48939f0fa7c8233454f583c67723a6fd2c465d1c6efae523c8fd82b9853118dc

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