Shiki is a beautiful Syntax Highlighter. Demo.
npm i shiki
# yarn add shiki
const shiki = require('shiki')
shiki.getHighlighter({
theme: 'nord'
}).then(highlighter => {
console.log(highlighter.codeToHtml(`console.log('shiki');`, 'js'))
})
// <pre class="shiki" style="background-color: #2e3440"><code>
// <!-- Highlighted Code -->
// </code></pre>
- Shiki uses Onigasm by @NeekSandhu
- A lot of code is based on vscode-textmate
MIT © Pine Wu