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, CSS, and Fluent embedded in its template, js, css, and messages 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. It also highlights message IDs, variables, selectors, and comments in a component's Fluent messages block.

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>
    """

    messages = """
      welcome-title = Welcome
    """
```

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, and messages 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 Fluent messages, terms, variables, attributes, selectors, and comments in messages.

Standalone Fluent fences also work through the fluent and ftl aliases registered by the package's Fluent lexer dependency.

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

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.2.0
File Size Uploaded
pygments_citry-0.2.0.tar.gz 21.2 kB Details

Built distribution (wheel)

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

Total release size: 33.9 kB

Release files / pygments_citry-0.2.0.tar.gz

Download URL pygments_citry-0.2.0.tar.gz
Size 21.2 kB
Tags Source
SHA-256 checksum
How to use checksums
3e35a097cf45150fe841c798a4154835bdf9ef3132c580cb4537702e27511193
BLAKE2b-256 checksum
How to use checksums
2ce22e185876f31babf71220e7a2647912190737deb5fe997aa9dfc06223c8c4
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 19, 2026.

Transparency log

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

Download URL pygments_citry-0.2.0-py3-none-any.whl
Size 12.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a8b0a53e60b3d3c0821363555ec4f8990658a74bcc81557d4708a0b9ba01d272
BLAKE2b-256 checksum
How to use checksums
25df6467a04d835c30080c66bdd824dc72e49e49c4e0f6757bc9bf0525e939e9
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 19, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.2

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