Shiki
Shiki is a beautiful Syntax Highlighter. Demo.
Usage
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>
Seen
- https://shiki.matsu.io
- VS Code website, such as in the Programmatic Language Features page.
- New TypeScript handbook, such as in the everything page.
- Markdown Preview Shiki Highlighting, a VS Code plugin to use Shiki's highlighting in Markdown preview.
Credits
- Shiki uses Onigasm by @NeekSandhu
- A lot of code is based on vscode-textmate
License
MIT © Pine Wu