JSONata language grammar for Highlight.js
JSONata is a lightweight query and transformation language for JSON data. To learn more, visit jsonata.org
Include the highlight.js library in your webpage or Node app, then load this module.
If using with Node, install the package by running
npm i highlightjs-jsonata
- Load the module after loading Highlight.js
- Use the minified version found in the dist directory.
<script type="text/javascript" src="/path/to/highlight.min.js"></script>
<script type="text/javascript" charset="UTF-8"
src="/path/to/highlightjs-jsonata/dist/jsonata.min.js"></script>
<script type="text/javascript">
hljs.highlightAll();
</script>
- Once loaded, mark the code you want to highlight with the class.
<pre><code class="language-jsonata">...</code></pre>
var hljs = require('highlightjs');
var hljsJsonata = require('highlightjs-jsonata');
hljs.registerLanguage("jsonata", hljsJsonata);
hljs.highlightAll();
import fs from "fs";
import matter from "gray-matter";
import remarkGfm from "remark-gfm";
import rehypeSanitize from "rehype-sanitize";
import rehypeHighlight from "rehype-highlight";
import { unified } from "unified";
import remarkParse from "remark-parse";
import remarkRehype from "remark-rehype";
import rehypeStringify from "rehype-stringify";
import { common } from "lowlight";
import hljsJsonata from "highlightjs-jsonata";
const file = fs.readFileSync("./full/path/to/file.md", "utf8");
const mdToHtml = await unified()
.use(remarkParse, { fragment: true })
.use(remarkGfm)
.use(remarkRehype)
.use(rehypeSanitize)
.use(rehypeHighlight, { languages: {...common, hljsJsonata} })
.use(rehypeStringify)
.process(matter(file).content);
```jsonata
$a := 1 + 2
...
highlightjs-jsonata is released under the CC0 1.0 License. See LICENSE file for details.
Vlad Dimov devdimov@proton.me
The official site for the Highlight.js library is https://highlightjs.org. The Highlight.js GitHub project: https://github.com/highlightjs/highlight.js