1.2.0 • Published 9 months ago

highlightjs-cedar v1.2.0

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
9 months ago

highlightjs-cedar

npm version build

Highlight.js syntax for Cedar

Use in browser

Get hljs-cedar.min.js from latest release or build hljs-cedar.min.js with:

yarn build

Include in HTML page:

<pre>
  <code class="language-cedar">
    Cedar code...
  </code>
</pre>
...
<link rel="stylesheet" href="path/to/theme.css" />
<script src="path/to/highlight.min.js"></script>
<script src="path/to/hljs-cedar.min.js"></script>
<script>
  hljs.registerLanguage("cedar", hljsCedar);
  hljs.highlightAll();
</script>

Use in Node

Install packages:

npm install highlight.js
npm install highlightjs-cedar

Import modules in Node:

const hljs = require("highlight.js");
const hljsCedar = require("highlightjs-cedar");

const code = `
// Users can edit their own info, admins can edit anyone's info
permit (
    principal,
    action,
    resource in HealthCareApp::InfoType::"accountinfo"
)
when {
    resource.subject == principal ||
    principal in HealthCareApp::Role::"admin"
};

//A patient may create an appointment for themselves, or an administrator can do it
permit (
    principal,
    action == HealthCareApp::Action::"createAppointment",
    resource
)
when {
    (context.referrer in HealthCareApp::Role::"doctor"  && resource.patient == principal) ||
    principal in HealthCareApp::Role::"admin"
};
`;

hljs.registerLanguage("cedar", hljsCedar);
const result = hljs.highlight(code, {
  language: "cedar",
});
1.2.0

9 months ago

1.1.0

9 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago