Simply load the grammar after loading Highlight.js:
<link rel="stylesheet" href="/path/to/styles/default.min.css">
<script src="/path/to/highlight.min.js"></script>
<script src="/path/to/riscvasm.min.js">
<script>hljs.highlightAll();</script>
You also can import it as a module:
<link rel="stylesheet" href="/path/to/styles/default.min.css">
<script type="module">
import hljs from '/path/to/highlight.min.js';
import riscvasm from '/path/to/riscvasm.es.min.js';
hljs.registerLanguage('riscv', riscvasm); // register it.
hljs.highlightAll();
</script>
Your html may look like:
<pre><code class="language-riscv">
...
</code></pre>
It can be imported as a module, then register it. CommonJS also works in the same way.
import hljs from 'highlight.js';
import riscvasm from 'highlightjs-riscvasm';
hljs.registerLanguage("riscv", riscvasm);
hljs.highlightAll();
Your html may look like:
<pre><code class="language-riscv">
...
</code></pre>