pygments-citry
A Pygments lexer for Citry
components. It highlights a component the way an editor would: the Python class,
plus the HTML, JavaScript, and CSS embedded in its template, js, and css
string attributes, each in its own language.
Without it, a Citry component in a ```python block renders the template,
JS script, and CSS stylesheet as flat string literals. With it, a ```citry
block colours the <c-*> tags, the {{ ... }} interpolation, the embedded
stylesheet, and the embedded script.
Install
pip install pygments-citry
The package registers a citry lexer as a Pygments plugin, so any tool that
resolves lexers by name picks it up once it is installed.
Use it
On the command line:
pygmentize -l citry my_component.py
In Python:
from pygments import highlight
from pygments.formatters import HtmlFormatter
from pygments.lexers import get_lexer_by_name
lexer = get_lexer_by_name("citry")
html = highlight(source, lexer, HtmlFormatter())
In a Markdown site (mkdocs with pymdownx.highlight / pymdownx.superfences,
or any python-markdown setup that resolves Pygments lexers by name), tag the
fence with citry:
```citry
from citry import Component
class Welcome(Component):
template = """
<div class="card">
<h1>{{ title }}</h1>
<p c-if="count">You have {{ count }} new messages.</p>
</div>
"""
```
No superfences custom_fences entry is needed: once the package is installed,
citry resolves like any other Pygments lexer.
What it highlights
A citry block is highlighted as Python, and the following Citry constructs
inside the template / js / css attributes are highlighted in their own
language:
- The HTML in
template, including the<c-*>component and control-flow tags (the built-insc-if,c-for,c-slot,<c-raw>, and so on). - Server-side Python in
c-*dynamic attributes and#c-key, including a nested Citry template used as a dynamic attribute value. - Browser-side JavaScript in
$c-propsand Alpine attributes such asx-data,x-show,@click, and:class. The server-dynamic forms such asc-$c-propsandc-@clickremain Python. - Server handler references in Events attributes such as
@c-click="save"and:c-query.debounce.300ms="refresh". An optional parenthesized argument on an@c-*handler is highlighted as an Alpine/JavaScript expression. - The bare
#c-ignoreframework marker. {{ ... }}interpolation, whose body is a Python expression.{# ... #}template comments.- The JavaScript in
jsand the CSS incss.
The <c-raw>...</c-raw> element is treated as verbatim text, matching the
engine: {{ }} and tags inside it are not interpreted.
The lexer also keeps useful language coloring for common unfinished forms, including an interpolation or quoted dynamic attribute that is still being typed. It highlights source but does not validate whether a directive is allowed on a particular element or component.
Template-only blocks: citry-html
For a fenced block that shows only a template, with no surrounding Python (just
<c-*> tags, {{ ... }}, and {# ... #}), tag it citry-html:
```citry-html
<c-for each="item in items">
<li c-if="item.visible">{{ item.label }}</li>
</c-for>
```
citry expects full component code (Python with embedded strings), so a bare
template belongs in a citry-html block instead.
License
MIT. Part of the Citry project.
Metadata
Release files for pygments-citry 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pygments_citry-0.1.1.tar.gz | 17.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pygments_citry-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 28.6 kB
Release files / pygments_citry-0.1.1.tar.gz
| Download URL | pygments_citry-0.1.1.tar.gz |
|---|---|
| Size | 17.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e96baadf720f9aa272cdbda4620cd775d1f18126c77702ac035bc16c8346e8e9
|
|
BLAKE2b-256 checksum How to use checksums |
aaf06ae8d8db75af5ed1eaea07e4692e92f91417904d84c3aaa1e4f22d82eeab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 30, 2026.
Transparency logRelease files / pygments_citry-0.1.1-py3-none-any.whl
| Download URL | pygments_citry-0.1.1-py3-none-any.whl |
|---|---|
| Size | 11.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
31ffc521ca1b6f3dc31d6918897e390d099e78e32fd322696d56314ad9e9beb6
|
|
BLAKE2b-256 checksum How to use checksums |
05853feac3fdbc778e33fa4e9f04655bbf94407b47f527978439ab454283d76f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 30, 2026.
Transparency log