{"id":18341877,"url":"https://github.com/pabluk/pygments-promql","last_synced_at":"2026-04-14T06:07:50.957Z","repository":{"id":43858570,"uuid":"284826556","full_name":"pabluk/pygments-promql","owner":"pabluk","description":"A PromQL lexer for Pygments","archived":false,"fork":false,"pushed_at":"2024-04-03T19:16:08.000Z","size":324,"stargazers_count":8,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-03T08:59:10.011Z","etag":null,"topics":["promql","pygments-lexer"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pabluk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-03T23:12:27.000Z","updated_at":"2024-03-01T20:17:48.000Z","dependencies_parsed_at":"2024-06-11T21:40:20.693Z","dependency_job_id":"1b2159b9-6057-4ecb-a3e9-836181180a7f","html_url":"https://github.com/pabluk/pygments-promql","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/pabluk/pygments-promql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pabluk%2Fpygments-promql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pabluk%2Fpygments-promql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pabluk%2Fpygments-promql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pabluk%2Fpygments-promql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pabluk","download_url":"https://codeload.github.com/pabluk/pygments-promql/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pabluk%2Fpygments-promql/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267802750,"owners_count":24146509,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["promql","pygments-lexer"],"created_at":"2024-11-05T20:28:49.904Z","updated_at":"2026-04-14T06:07:45.927Z","avatar_url":"https://github.com/pabluk.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pygments-promql\n\n[![Python package](https://github.com/pabluk/pygments-promql/workflows/Python%20package/badge.svg)](https://github.com/pabluk/pygments-promql/actions)\n[![PyPI](https://img.shields.io/pypi/v/pygments-promql)](https://pypi.org/project/pygments-promql/)\n[![PyPI - License](https://img.shields.io/pypi/l/pygments-promql)](https://raw.githubusercontent.com/pabluk/pygments-promql/master/LICENSE)\n\nA PromQL lexer for Pygments.\n\nThis Python package provides a [Pygments](https://pygments.org/) lexer for the [Prometheus Query Language](https://prometheus.io/docs/prometheus/latest/querying/basics/). It allows Pygments and other tools ([Sphinx](https://sphinx-doc.org/), [Chroma](https://github.com/alecthomas/chroma), etc) to highlight PromQL queries.\n\n![PromQL syntax highlighted](https://raw.githubusercontent.com/pabluk/pygments-promql/master/tests/example.png)\n\n# Installation\n\n## Using pip\n\nTo get the latest version from pypi.org:\n\n```console\npip install pygments-promql\n```\n\n# Usage\n\n## Command-line\n\nIn a terminal you can echo and pipe a query directly from stdin:\n\n```console\necho 'prometheus_http_requests_total{code=\"200\"}' | pygmentize -l promql\n```\n\nOr use a file, for example, create the `example.promql` file with queries from\n[tests/example.promql](https://github.com/pabluk/pygments-promql/blob/master/tests/example.promql).\nIn this case the option `-l promql` is not needed because the lexer will be\ndetected based on the file extension.\n\nShowing colorized output in a terminal:\n\n```console\npygmentize example.promql\n```\n\nTo generate a PNG file:\n\n```console\npygmentize -f png -O \"line_numbers=False,style=monokai\" -o example.png example.promql\n```\n\n## Python code\n\nThe following example:\n\n```python\nfrom pygments import highlight\nfrom pygments.formatters import HtmlFormatter\nfrom pygments_promql import PromQLLexer\n\nquery = 'http_requests_total{handler=\"/api/comments\"}'\nprint(highlight(query, PromQLLexer(), HtmlFormatter()))\n```\n\nWill generate this HTML output:\n\n```html\n\u003cdiv class=\"highlight\"\u003e\n    \u003cpre\u003e\n        \u003cspan\u003e\u003c/span\u003e\n\t\u003cspan class=\"nv\"\u003ehttp_requests_total\u003c/span\u003e\n\t\u003cspan class=\"p\"\u003e{\u003c/span\u003e\n\t\u003cspan class=\"nl\"\u003ehandler\u003c/span\u003e\n\t\u003cspan class=\"o\"\u003e=\u003c/span\u003e\n\t\u003cspan class=\"s\"\u003e\u0026quot;/api/comments\u0026quot;\u003c/span\u003e\n\t\u003cspan class=\"p\"\u003e}\u003c/span\u003e\n\t\u003cspan class=\"w\"\u003e\u003c/span\u003e\n    \u003c/pre\u003e\n\u003c/div\u003e\n```\n\nUse `HtmlFormatter(noclasses=True)` to include CSS inline styles on every `\u003cspan\u003e` tag.\n\n## Sphinx\n\nIn order to highlight PromQL syntax in your [Sphinx documentation site](https://www.sphinx-doc.org/en/1.8/index.html)\nyou just need to add this 3 lines of Python code at the end of your site's `conf.py` file:\n\n```python\nfrom sphinx.highlighting import lexers\nfrom pygments_promql import PromQLLexer\nlexers['promql'] = PromQLLexer()\n```\n\nThen you will be able to use it like this:\n\n```rst\nHere's a PromQL example:\n\n.. code-block:: promql\n\n\t# A metric with label filtering\n\tgo_gc_duration_seconds{instance=\"localhost:9090\"}\n\n```\n\n# Testing\n\nIf you want to test, play or contribute to this repo:\n\n```console\ngit clone https://github.com/pabluk/pygments-promql.git\ncd pygments-promql/\npip install -r requirements.txt\npip install -e .\npytest -v\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpabluk%2Fpygments-promql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpabluk%2Fpygments-promql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpabluk%2Fpygments-promql/lists"}