Jac — a language grammar for highlight.js
Jac is the primary programming language of the Jaseci runtime, featuring Python-compatible syntax extended with Object-Spatial Programming constructs — walkers, nodes, and edges — for building agentic AI applications.
Highlights all Jac language constructs including:
- Archetype declarations:
walker,node,edge,obj,class,enum - Ability declarations:
can,def - Access modifiers:
pub,priv,protect,static,override,abs - Object-Spatial keywords:
visit,disengage,report,spawn,here,visitor,root - Property declarations:
has,glob - Single-line
#and block#* ... *#comments - f-strings, triple-quoted strings, raw strings, bytes
- Numeric literals with underscores, hex, binary, octal
npm install highlightjs-jac<script src="https://unpkg.com/highlightjs-jac/dist/jac.min.js"></script>Load after highlight.js — the grammar self-registers via the CDN build.
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/styles/github.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/highlight.min.js"></script>
<script src="https://unpkg.com/highlightjs-jac/dist/jac.min.js"></script>
<script>hljs.highlightAll();</script>Then mark your code blocks with the jac language class:
<pre><code class="language-jac">
walker MyWalker {
can walk with `root entry {
visit [-->];
}
}
</code></pre>import hljs from 'highlight.js/lib/core';
import jac from 'highlightjs-jac';
hljs.registerLanguage('jac', jac);
const result = hljs.highlight('walker Foo { can walk; }', { language: 'jac' });
console.log(result.value);import:py from math { sqrt }
node Person {
has name: str;
has age: int = 0;
}
edge Knows {
has since: int = 2020;
}
walker Greeter {
can greet with Person entry {
:g: msg = f"Hello, {here.name}!";
report msg;
}
can travel with `root entry {
visit [-->];
disengage;
}
}This package follows the highlight.js third-party language contribution guide.
To develop locally:
git clone https://github.com/jaseci-labs/highlightjs-jac
cd highlightjs-jac
npm install
npm run buildTo run fixture tests with the highlight.js test harness, clone this repository inside a local
highlight.js checkout under extra/highlightjs-jac and execute the highlight.js test commands.
BSD 3-Clause © Jaseci Labs