Just see the following example:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/src/styles/darkMode.css" />
</head>
<body>
<div class="language-zig nice-code-block">
const zilite:[]const u8 = "Syntax Highlighter";
</div>
<script type="module">
import { highlightElements } from "https://cdn.jsdelivr.net/npm/[email protected]";
import {zig } from "https://cdn.jsdelivr.net/npm/[email protected]/src/language/zig.js";
highlightElements(zig, "language-zig");
</script>
</body>
</html>
npm i zilite
And then use it in a file like index.html:
import * as hl from "higherlight";
import { zig } from "higherlight/src/language/zig";
const highlightedCode = hl.highlight(zig, "const x = 'asdf';");
console.log(highlightedCode);
Understood? Or still confused? Create a new issue here and clear your doubts.
Please ⭐️ this repo, create pull requests, issues, etc.