Skip to main content

Pygments lexer for the Cedar policy language

Project description

pygments-cedar

A Pygments lexer plugin for the Cedar policy language by AWS.

Installation

pip install pygments-cedar

Usage

Once installed, the lexer registers itself as a Pygments plugin. It is automatically available anywhere Pygments is used.

Command line

pygmentize -l cedar policy.cedar

Python

from pygments import highlight
from pygments.formatters import HtmlFormatter
from pygments.lexers import get_lexer_by_name

lexer = get_lexer_by_name("cedar")
code = '''
permit(
  principal == User::"alice",
  action == Action::"view",
  resource == Photo::"VacationPhoto94.jpg"
);
'''
print(highlight(code, lexer, HtmlFormatter()))

Markdown (e.g. MkDocs, Sphinx)

Use the cedar language identifier in fenced code blocks:

```cedar
permit(
  principal == User::"alice",
  action == Action::"view",
  resource == Photo::"VacationPhoto94.jpg"
);
```

Supported syntax

  • Policy effects: permit, forbid
  • Scope keywords: principal, action, resource, context
  • Condition clauses: when, unless
  • Operators: in, has, like, is, if/then/else, logical (&&, ||, !), comparison (==, !=, <, >, <=, >=)
  • Entity references: Namespace::Type::"id"
  • Strings with escape sequences
  • Integer literals (including negative)
  • Line comments (//)
  • Function/method calls

Development

Requires Python 3.13+ and uv.

uv sync
uv run pytest tests/ -v

License

BSD 2-Clause. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygments_cedar-2026.5.13.post0.tar.gz (2.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygments_cedar-2026.5.13.post0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file pygments_cedar-2026.5.13.post0.tar.gz.

File metadata

  • Download URL: pygments_cedar-2026.5.13.post0.tar.gz
  • Upload date:
  • Size: 2.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pygments_cedar-2026.5.13.post0.tar.gz
Algorithm Hash digest
SHA256 e0ae9365f6cd74cce020650be81ef73b6d655301c8776856c6c5e07ebba3d95b
MD5 9bc1e605c64259896be0180c885c9f1f
BLAKE2b-256 4d5dfa9ae17cce82a0de9763e8bb2a175a81492f09b62cc51ff784cc329054e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygments_cedar-2026.5.13.post0.tar.gz:

Publisher: build.yaml on chalbersma/pygments-cedar

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pygments_cedar-2026.5.13.post0-py3-none-any.whl.

File metadata

File hashes

Hashes for pygments_cedar-2026.5.13.post0-py3-none-any.whl
Algorithm Hash digest
SHA256 a34cc0f86388887b20341629a58b32c6167bbae881e78ad7598622fba5ee7f75
MD5 584c2798b00136350e549889f11e2c9d
BLAKE2b-256 2d80e3cfbca7c7a64f11b631aa4cb5eb534758ed25c088bf8a7d3035b79981a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygments_cedar-2026.5.13.post0-py3-none-any.whl:

Publisher: build.yaml on chalbersma/pygments-cedar

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page