shiki-cedar-rego
v0.1.0
Published
Cedar and Rego TextMate grammars for Shiki syntax highlighting
Maintainers
Readme
shiki-cedar-rego
TextMate grammar definitions for Cedar (AWS Verified Permissions) and Rego (Open Policy Agent) to use with Shiki.
Install
npm install shiki-cedar-rego shikiBasic usage
Add cedarRegoLangs to your createHighlighter call. Optionally use the JavaScript regex engine when you want highlighting without bundling the Oniguruma WASM binary:
import { createHighlighter } from 'shiki'
import { createJavaScriptRegexEngine } from 'shiki/engine/javascript'
import { cedarRegoLangs } from 'shiki-cedar-rego'
const highlighter = await createHighlighter({
themes: ['github-dark'],
langs: [...cedarRegoLangs, 'typescript'],
engine: createJavaScriptRegexEngine({ forgiving: true }),
})
const html = highlighter.codeToHtml('permit (...);', { lang: 'cedar', theme: 'github-dark' })Helper: createCedarRegoHighlighter
Convenience wrapper that loads Cedar/Rego with the same engine defaults:
import { createCedarRegoHighlighter } from 'shiki-cedar-rego'
const highlighter = await createCedarRegoHighlighter({
themes: ['github-light', 'github-dark'],
langs: ['json'],
})Language helpers
import { isCedarRegoLang, CEDAR_REGO_LANG_IDS } from 'shiki-cedar-rego'
if (isCedarRegoLang(lang)) {
// narrows to 'cedar' | 'rego'
}If you use Streamdown, MDX, or another wrapper, implement a bridge to your highlighter API in your app. This package only provides the Shiki language payloads.
Grammar sources
Development
npm install
npm run buildThe prepublishOnly script builds before npm publish.
Releasing (CI)
- Add an npm access token as repo secret
NPM_TOKEN(npm tokens). - Bump
versioninpackage.json, commit, and push tomain. - Create a tag that matches that version, e.g.
git tag v0.1.0 && git push origin v0.1.0.
Pushing tag v* runs publish workflow: it checks the tag matches package.json, runs npm ci / npm run build, then npm publish.
License
MIT
