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

Uploaded PyPyWindows x86-64

markdown_query-0.2.4-pp310-pypy310_pp73-win_amd64.whl (836.4 kB view details)

Uploaded PyPyWindows x86-64

markdown_query-0.2.4-pp39-pypy39_pp73-win_amd64.whl (836.2 kB view details)

Uploaded PyPyWindows x86-64

markdown_query-0.2.4-cp313-cp313t-win_amd64.whl (833.2 kB view details)

Uploaded CPython 3.13tWindows x86-64

markdown_query-0.2.4-cp39-abi3-win_amd64.whl (836.4 kB view details)

Uploaded CPython 3.9+Windows x86-64

markdown_query-0.2.4-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (821.3 kB view details)

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

markdown_query-0.2.4-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (769.3 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

markdown_query-0.2.4-cp39-abi3-macosx_11_0_arm64.whl (749.4 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

markdown_query-0.2.4-cp39-abi3-macosx_10_12_x86_64.whl (822.9 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.4-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 f3eff687b4dc556f3c017da9a09104d7f2cf093e68b31ea9bbae8f9c2bd0b21a
MD5 e31b17fe87ad79c056aff9914f807892
BLAKE2b-256 336a03fd3bbfc3dce88ee7845797cacb613ec839672f69c771fa23352b846388

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.4-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 2df31fd4c05d805a77378b619048eb0c475263ec5ec6dae7dfcdcf5bb81c8fbc
MD5 c42ac2c0f6aa26d7b56a8f8ded001bd2
BLAKE2b-256 50dc77beff14402a143030e55ff1d2243dbf5b2a0017377818d75d76219c08c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.4-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 e8a1ce2aa4773e7da8ef49eca4ebb3c40e9c07e6d3c0453ac08cc646da64bf5b
MD5 e7d96e012e56d2fc0ef44bb61ff7c95c
BLAKE2b-256 b5cec5f7f712a1271a60eaca6fe32b8626f8a92e5641c9e584fd6e97e975ff8d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.4-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 9324883bcd2f37ace9004bd3a24dd45e5c570316ed53025763fbba541a52a248
MD5 accb63c32de8f54748e399afee08949f
BLAKE2b-256 a1bd0a8d26c0d3078df903080c1f95d4df529994d7209092b0911d9a69004ef3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.4-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 666d2a429c322d0086706c460607f2080e3bfc09be702fc9a3d8da2670cb8bc8
MD5 52193fb7593ee9d1f6a2f4b23dc11e60
BLAKE2b-256 328870de123932efffbf2909d1016d146f0293ec935a78980d07b636d0ca7ace

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.4-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e751238b774bcd397579bdc566b677b39d07eb9367abfb3d707075277873ef4b
MD5 48f983699036b84c1f3a4993ca9fdc9a
BLAKE2b-256 d33233ae34a59295c9ff7c94811efd57e353a664cc54fd5c0f8ae4fd242f8ed4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.4-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 25baea1c1a9e70907c44e64b76673353a464b27a8bff1d8480115ae3150accd9
MD5 7d5a89d047848146c332cd43f3864b34
BLAKE2b-256 a37f2de4d3e8806eba06260b96a6a318038519709f7c22bc1308060ee676768f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.4-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 85ba200c211b526f3b7cb1523d3d6aa54b6c7b7cc75e0f7a68350a514eff80bc
MD5 7bece741cafa4dc92d95107df5ee1d0a
BLAKE2b-256 43cffba5ec13b0a43216212b694abb5d3d9b5d070a2a2748955f62577c7e9951

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_query-0.2.4-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6d7c351270fed48e239fae2561545fda9ac89b0242652fb2e5e6e8e3502c6eb5
MD5 e45e53bf420fb4cb711bcbb1bcd86a09
BLAKE2b-256 209ac3868980692018db3c620f692ac98fcecd808510703cc98ce63f87f8b2e2

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