Skip to main content

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-ins c-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-props and Alpine attributes such as x-data, x-show, @click, and :class. The server-dynamic forms such as c-$c-props and c-@click remain 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-ignore framework marker.
  • {{ ... }} interpolation, whose body is a Python expression.
  • {# ... #} template comments.
  • The JavaScript in js and the CSS in css.

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.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pygments-citry 0.1.2
File Size Uploaded
pygments_citry-0.1.2.tar.gz 17.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pygments-citry 0.1.2
File Interpreter ABI Platform
pygments_citry-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 29.0 kB

Release files / pygments_citry-0.1.2.tar.gz

Download URL pygments_citry-0.1.2.tar.gz
Size 17.3 kB
Tags Source
SHA-256 checksum
How to use checksums
84f43e358aa25b4038f118e54500d60890329bc4ea576541385808d180bc5468
BLAKE2b-256 checksum
How to use checksums
c9623cd27aa08560f9d480a911323dd085555e6b68ec5bd643d69d2d36f728af
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 Aug 7, 2026.

Transparency log

Release files / pygments_citry-0.1.2-py3-none-any.whl

Download URL pygments_citry-0.1.2-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d37fc85130abfbaf34a97a2a41d44a022f23e997cca3ad902d984c29bef3fce2
BLAKE2b-256 checksum
How to use checksums
3f1bf406b0d3071d29516d1b7c2edd11d006b77c8e7538be6b449181b962fbcb
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 Aug 7, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.0

2 release files

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page