markdown-query


Namemarkdown-query JSON
Version 0.2.15 PyPI version JSON
download
home_pageNone
SummaryPython bindings for mq, a jq-like command-line tool for Markdown processing
upload_time2025-07-27 13:18:47
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT
keywords markdown jq command-line tool
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # mq

[![ci](https://github.com/harehare/mq/actions/workflows/ci.yml/badge.svg)](https://github.com/harehare/mq/actions/workflows/ci.yml)
![GitHub Release](https://img.shields.io/github/v/release/harehare/mq)
[![codecov](https://codecov.io/gh/harehare/mq/graph/badge.svg?token=E4UD7Q9NC3)](https://codecov.io/gh/harehare/mq)
[![CodSpeed Badge](https://img.shields.io/endpoint?url=https://codspeed.io/badge.json)](https://codspeed.io/harehare/mq)

Python bindings for the mq Markdown processor.

## Overview

`markdown-query` provides Python bindings to the [`mq`](https://github.com/harehare/mq), allowing Python developers to use mq's Markdown processing capabilities directly from Python code.

## Installation

```bash
pip install markdown-query
```

## Usage

````python
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](https://github.com/microsoft/markitdown) for even more powerful Markdown processing workflows:

```python
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](https://mqlang.org/book/).

## Playground

An [Online Playground](https://mqlang.org/playground) is available, powered by WebAssembly.

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "markdown-query",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "markdown, jq, command-line, tool",
    "author": null,
    "author_email": "harehare <harehare1110@gmail.com>",
    "download_url": null,
    "platform": null,
    "description": "# mq\n\n[![ci](https://github.com/harehare/mq/actions/workflows/ci.yml/badge.svg)](https://github.com/harehare/mq/actions/workflows/ci.yml)\n![GitHub Release](https://img.shields.io/github/v/release/harehare/mq)\n[![codecov](https://codecov.io/gh/harehare/mq/graph/badge.svg?token=E4UD7Q9NC3)](https://codecov.io/gh/harehare/mq)\n[![CodSpeed Badge](https://img.shields.io/endpoint?url=https://codspeed.io/badge.json)](https://codspeed.io/harehare/mq)\n\nPython bindings for the mq Markdown processor.\n\n## Overview\n\n`markdown-query` provides Python bindings to the [`mq`](https://github.com/harehare/mq), allowing Python developers to use mq's Markdown processing capabilities directly from Python code.\n\n## Installation\n\n```bash\npip install markdown-query\n```\n\n## Usage\n\n````python\nimport mq\n\n# Process a markdown string with an mq query\nmarkdown = '# Hello\\n\\nThis is a paragraph\\n\\n## Section\\n\\nMore text.\\n\\n```js\\nconsole.log(\"code\")\\n```'\n\nprint(mq.run(\"select(or(.h1, .code))\", markdown, None).values)\n# ['# Hello', '```js\\nconsole.log(\"code\")\\n```']\n\nprint(mq.run(\"select(or(.h1, .code)) | to_text()\", markdown, None).values)\n# ['Hello', 'console.log(\"code\")']\n\nprint(mq.run(\"select(or(.h1, .code)) | to_text()\", markdown, None)[0].text)\n# Hello\n\nprint([m for m in mq.run(\"select(or(.h1, .code))\", markdown, None)])\n# MarkdownType.Heading\n\nprint(mq.run(\"select(or(.h1, .code))\", markdown, None)[0].markdown_type)\n# MarkdownType.Heading\n\n# Process a html string with an mq query\nmarkdown = '<h1>Title</h1><p>Paragraph</p>'\n\noptions = mq.Options()\noptions.input_format = mq.InputFormat.HTML\nprint(mq.run(\".h1 | upcase()\", markdown, options).values)\n# ['# TITLE']\n````\n\n### Using with markitdown\n\nYou can combine `mq` with [markitdown](https://github.com/microsoft/markitdown) for even more powerful Markdown processing workflows:\n\n```python\nfrom markitdown import MarkItDown\nimport mq\n\nmarkitdown = MarkItDown()\nresult = markitdown.convert(\"https://github.com/harehare/mq\")\n\nprint(mq.run(\".code | to_text()\", result, None))\nprint(mq.run(\".[] | to_html()\", result, None))\n```\n\nFor more detailed usage and examples, refer to the [documentation](https://mqlang.org/book/).\n\n## Playground\n\nAn [Online Playground](https://mqlang.org/playground) is available, powered by WebAssembly.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python bindings for mq, a jq-like command-line tool for Markdown processing",
    "version": "0.2.15",
    "project_urls": {
        "Documentation": "https://mqlang.org/book/",
        "Homepage": "https://mqlang.org/",
        "Issues": "https://github.com/harehare/mq/issues",
        "Repository": "https://github.com/harehare/mq.git"
    },
    "split_keywords": [
        "markdown",
        " jq",
        " command-line",
        " tool"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "8282dcf1df82209e8d85878c8b660bc55f3a4f7cddf81282ff394bf95c136070",
                "md5": "826bf9c9acbfa7bacd9638998f75ca74",
                "sha256": "252b4ecd52b8cc2cec3876480dcc3df2813e6156648538cdc976634b45de9efc"
            },
            "downloads": -1,
            "filename": "markdown_query-0.2.15-cp313-cp313t-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "826bf9c9acbfa7bacd9638998f75ca74",
            "packagetype": "bdist_wheel",
            "python_version": "cp313",
            "requires_python": ">=3.10",
            "size": 1505035,
            "upload_time": "2025-07-27T13:18:47",
            "upload_time_iso_8601": "2025-07-27T13:18:47.642880Z",
            "url": "https://files.pythonhosted.org/packages/82/82/dcf1df82209e8d85878c8b660bc55f3a4f7cddf81282ff394bf95c136070/markdown_query-0.2.15-cp313-cp313t-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "7ef5f92ae3658bd384aaf88cccbaa6da6e1c0a40a3cbf6950b6e02ac6ad0ca73",
                "md5": "b08b33e897e799e40dd360edb2578388",
                "sha256": "69480dac6d1aeb54e285a57353350f25875804133124388f5452de06b65ad3b1"
            },
            "downloads": -1,
            "filename": "markdown_query-0.2.15-cp39-abi3-macosx_10_12_x86_64.whl",
            "has_sig": false,
            "md5_digest": "b08b33e897e799e40dd360edb2578388",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.10",
            "size": 1498645,
            "upload_time": "2025-07-27T13:18:49",
            "upload_time_iso_8601": "2025-07-27T13:18:49.838994Z",
            "url": "https://files.pythonhosted.org/packages/7e/f5/f92ae3658bd384aaf88cccbaa6da6e1c0a40a3cbf6950b6e02ac6ad0ca73/markdown_query-0.2.15-cp39-abi3-macosx_10_12_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "515e3f778129f7acab23ec0efcec7851146e6154a3a504b7d120d65d32958e09",
                "md5": "c0775bebfed7779140896c62f108ad47",
                "sha256": "ec9c4aad17fc234239d426ec628a95b820cb797c927c5a9b31f7d2fe53b48419"
            },
            "downloads": -1,
            "filename": "markdown_query-0.2.15-cp39-abi3-macosx_11_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "c0775bebfed7779140896c62f108ad47",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.10",
            "size": 1365517,
            "upload_time": "2025-07-27T13:18:51",
            "upload_time_iso_8601": "2025-07-27T13:18:51.041247Z",
            "url": "https://files.pythonhosted.org/packages/51/5e/3f778129f7acab23ec0efcec7851146e6154a3a504b7d120d65d32958e09/markdown_query-0.2.15-cp39-abi3-macosx_11_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "c6b209c40862aa92eb1d119b19eb11463d2d009bbabd54d893a5f3fb7e193dfc",
                "md5": "d549dddb8d435354efff7ec748173ea3",
                "sha256": "533ba30eca2d9d42b25bcebd2526cf60f1f0f78539c8d6a9009e73ffff5ee23b"
            },
            "downloads": -1,
            "filename": "markdown_query-0.2.15-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
            "has_sig": false,
            "md5_digest": "d549dddb8d435354efff7ec748173ea3",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.10",
            "size": 1423489,
            "upload_time": "2025-07-27T13:18:52",
            "upload_time_iso_8601": "2025-07-27T13:18:52.763559Z",
            "url": "https://files.pythonhosted.org/packages/c6/b2/09c40862aa92eb1d119b19eb11463d2d009bbabd54d893a5f3fb7e193dfc/markdown_query-0.2.15-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "25551edde7756b943181ae8d3484a77350083d03b372c55ebe0e2dea2b0bb2ef",
                "md5": "6b817106020d6d5e621ac9af8cec074b",
                "sha256": "0b42923eb1d217492eeb6771b96f80c81e8bd412e5c94d51795b2db66a6159b2"
            },
            "downloads": -1,
            "filename": "markdown_query-0.2.15-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "6b817106020d6d5e621ac9af8cec074b",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.10",
            "size": 1537855,
            "upload_time": "2025-07-27T13:18:54",
            "upload_time_iso_8601": "2025-07-27T13:18:54.382059Z",
            "url": "https://files.pythonhosted.org/packages/25/55/1edde7756b943181ae8d3484a77350083d03b372c55ebe0e2dea2b0bb2ef/markdown_query-0.2.15-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e1c9c605e479ec5da1d840877388860de70c34c63781d8a974c6835af27af841",
                "md5": "5c2c6046a9a03f851a9580e815af0f26",
                "sha256": "c58443ec79c537383de4fbb3021338da04cce50d87b530656a5e9dd01ecefb66"
            },
            "downloads": -1,
            "filename": "markdown_query-0.2.15-cp39-abi3-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "5c2c6046a9a03f851a9580e815af0f26",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.10",
            "size": 1508454,
            "upload_time": "2025-07-27T13:18:55",
            "upload_time_iso_8601": "2025-07-27T13:18:55.675985Z",
            "url": "https://files.pythonhosted.org/packages/e1/c9/c605e479ec5da1d840877388860de70c34c63781d8a974c6835af27af841/markdown_query-0.2.15-cp39-abi3-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2b5c99501c32ebb3d19f22ccacb000aa0776e28660e2905a19849302d89bbf2b",
                "md5": "67c66a0efcc2e8af168e894aa14309e8",
                "sha256": "f25178df592e7fe9127c19eb027220db438fe23206adaf2b5d553c397953cfb3"
            },
            "downloads": -1,
            "filename": "markdown_query-0.2.15-pp310-pypy310_pp73-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "67c66a0efcc2e8af168e894aa14309e8",
            "packagetype": "bdist_wheel",
            "python_version": "pp310",
            "requires_python": ">=3.10",
            "size": 1508629,
            "upload_time": "2025-07-27T13:18:57",
            "upload_time_iso_8601": "2025-07-27T13:18:57.487461Z",
            "url": "https://files.pythonhosted.org/packages/2b/5c/99501c32ebb3d19f22ccacb000aa0776e28660e2905a19849302d89bbf2b/markdown_query-0.2.15-pp310-pypy310_pp73-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d2bd20df38eef12ecb55e8cd627f03db743a97f91cde2f5c3ea2e58a2e9b5e39",
                "md5": "54d20437517617a15e35740c9e61ec2f",
                "sha256": "0f5bb05cd4c5c5353b4cc995df0ff0ff48b99ce99d0e03e1f81f4cb52e6e817d"
            },
            "downloads": -1,
            "filename": "markdown_query-0.2.15-pp311-pypy311_pp73-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "54d20437517617a15e35740c9e61ec2f",
            "packagetype": "bdist_wheel",
            "python_version": "pp311",
            "requires_python": ">=3.10",
            "size": 1507230,
            "upload_time": "2025-07-27T13:18:59",
            "upload_time_iso_8601": "2025-07-27T13:18:59.037501Z",
            "url": "https://files.pythonhosted.org/packages/d2/bd/20df38eef12ecb55e8cd627f03db743a97f91cde2f5c3ea2e58a2e9b5e39/markdown_query-0.2.15-pp311-pypy311_pp73-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "434ffa6f4153c7536dea50416505783b0c65fb3b1a3baffafb16815fd14fbba8",
                "md5": "26b4cff65eb350d62171883d0d145e2f",
                "sha256": "2182469184c706b4713ff5d898680941ddc1c843d1e9d70064dd2efeb60f00b6"
            },
            "downloads": -1,
            "filename": "markdown_query-0.2.15-pp39-pypy39_pp73-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "26b4cff65eb350d62171883d0d145e2f",
            "packagetype": "bdist_wheel",
            "python_version": "pp39",
            "requires_python": ">=3.10",
            "size": 1508499,
            "upload_time": "2025-07-27T13:19:00",
            "upload_time_iso_8601": "2025-07-27T13:19:00.564962Z",
            "url": "https://files.pythonhosted.org/packages/43/4f/fa6f4153c7536dea50416505783b0c65fb3b1a3baffafb16815fd14fbba8/markdown_query-0.2.15-pp39-pypy39_pp73-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-27 13:18:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "harehare",
    "github_project": "mq",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "markdown-query"
}
        
Elapsed time: 1.59242s