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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0ae9365f6cd74cce020650be81ef73b6d655301c8776856c6c5e07ebba3d95b
|
|
| MD5 |
9bc1e605c64259896be0180c885c9f1f
|
|
| BLAKE2b-256 |
4d5dfa9ae17cce82a0de9763e8bb2a175a81492f09b62cc51ff784cc329054e5
|
Provenance
The following attestation bundles were made for pygments_cedar-2026.5.13.post0.tar.gz:
Publisher:
build.yaml on chalbersma/pygments-cedar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pygments_cedar-2026.5.13.post0.tar.gz -
Subject digest:
e0ae9365f6cd74cce020650be81ef73b6d655301c8776856c6c5e07ebba3d95b - Sigstore transparency entry: 1523288634
- Sigstore integration time:
-
Permalink:
chalbersma/pygments-cedar@b297bb6a0c166ec6cfc6a0915f295582530a5ed7 -
Branch / Tag:
refs/tags/2026.5.13-0 - Owner: https://github.com/chalbersma
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yaml@b297bb6a0c166ec6cfc6a0915f295582530a5ed7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pygments_cedar-2026.5.13.post0-py3-none-any.whl.
File metadata
- Download URL: pygments_cedar-2026.5.13.post0-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a34cc0f86388887b20341629a58b32c6167bbae881e78ad7598622fba5ee7f75
|
|
| MD5 |
584c2798b00136350e549889f11e2c9d
|
|
| BLAKE2b-256 |
2d80e3cfbca7c7a64f11b631aa4cb5eb534758ed25c088bf8a7d3035b79981a9
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pygments_cedar-2026.5.13.post0-py3-none-any.whl -
Subject digest:
a34cc0f86388887b20341629a58b32c6167bbae881e78ad7598622fba5ee7f75 - Sigstore transparency entry: 1523288638
- Sigstore integration time:
-
Permalink:
chalbersma/pygments-cedar@b297bb6a0c166ec6cfc6a0915f295582530a5ed7 -
Branch / Tag:
refs/tags/2026.5.13-0 - Owner: https://github.com/chalbersma
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yaml@b297bb6a0c166ec6cfc6a0915f295582530a5ed7 -
Trigger Event:
release
-
Statement type: