highlightjs-fson is a highlight.js language definition for FSON. It colours fson fenced code blocks anywhere highlight.js runs — and it is what paints the FSON blocks on this site. **highlightjs-ffsmd`** does the same for FFS-MD.

What it highlights

FSON constructhighlight.js scope
// and nested /* … */ commentscomment
bare and quoted keysattr
string values, `\`-block stringsstring
escapes (\n, \xHH, \uHHHH, …)char.escape
numbers, hex, Infinity, NaN, .5, 5.number
true / false / nullliteral
%include, askeyword
-- disabled members / directives / `\`-linesdeletion

The bare-key grammar follows FSON's narrow name production, not JSON5's — $foo, _x, name_, a__b are treated as ordinary text.

npm

npm install highlight.js @ffs/highlightjs-fson

The npm scope may change to @fedem/… before the first publish to match

the Marketplace publisher — check the package page.

import hljs from 'highlight.js';
import fson from '@ffs/highlightjs-fson';

hljs.registerLanguage('fson', fson);
hljs.highlightAll();               // colours <pre><code class="language-fson">

CommonJS: hljs.registerLanguage('fson', require('@ffs/highlightjs-fson').default).

Browser — self-registering bundle

ffs-lang-tools/scripts/build-browser.sh produces dist/fson.min.js: a minified IIFE that calls hljs.registerLanguage('fson', …) itself. Drop it in after highlight.js and nothing else is needed:

<script src="/highlight.min.js"></script>
<script src="/fson.min.js"></script>   <!-- registers 'fson' on load -->

That file is on this site at /static/js/fson.hljs.min.js — loaded from the tenant's wt_config.xml, which is why every fson ` block you see in the notation, the User Guide and the blog is coloured.

Tarballs

The packaged npm tarballs (.tgz) are on the Downloads page for offline installs (npm install ./ffs-highlightjs-fson-*.tgz).