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 0.2.1

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.1
File Size Uploaded Provenance
pygments_citry-0.2.1.tar.gz 22.0 kB With provenance Details

Built distribution (wheel)

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

Total release size: 34.7 kB

Release files / pygments_citry-0.2.1.tar.gz

Download URL pygments_citry-0.2.1.tar.gz
Size 22.0 kB
Tags Source
SHA-256 checksum
How to use checksums
01097161a18eba421119216beae814404335355688aa7cd0c5de395695a94ac8
BLAKE2b-256 checksum
How to use checksums
471f939254c6652633d718a5270a0a0d8094aa557ef1b7c73a0358f496380998
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 Oct 19, 2026.

Transparency log

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

Download URL pygments_citry-0.2.1-py3-none-any.whl
Size 12.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
83045b58d7e40b0a0a90f6b39abddc19ccc1623f0113b7953636fdbac988052a
BLAKE2b-256 checksum
How to use checksums
e1eda2e5b65b33f5d141a3991e4096fcd302b26cf7bfcac52fa2e3395774b47b
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 Oct 19, 2026.

Transparency log

Security for pygments-citry 0.2.1

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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pygments_citry-0.2.1.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 Oct 19, 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.

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