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 Vue attributes such as v-show, @click, and :class. Server-dynamic forms such as 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 a Vue/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 1.0.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 1.0.0
File Size Uploaded Provenance Actions
pygments_citry-1.0.0.tar.gz 22.1 kB With provenance Details for pygments_citry-1.0.0.tar.gz

Built distribution (wheel)

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

Total release size: 34.9 kB

Release files / pygments_citry-1.0.0.tar.gz

Download URL pygments_citry-1.0.0.tar.gz
Size 22.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6fbdca5aedb6b43b64098a016db5f6da88e2f284c25aa2026924fcb8acab7a6a
BLAKE2b-256 checksum
How to use checksums
c0e8e480f681aec492b8a8b048c56ae5555a68cc143cc6f3926561d803ee8f01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 15, 2026.

Transparency log

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

Download URL pygments_citry-1.0.0-py3-none-any.whl
Size 12.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
41b9dd82af133480de477e9e417cd65a394fd26ea0db40f5730291f798e046b9
BLAKE2b-256 checksum
How to use checksums
5a1da5998b219642532631739d81f74ad412ff1484ccd03559755fd6d3b00af0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 15, 2026.

Transparency log

Security for pygments-citry 1.0.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pygments_citry-1.0.0.tar.gz

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 Nov 15, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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