Shiki is a beautiful Syntax Highlighter that uses monstrous TextMate grammar rules for a textbook for chains. The rules of the format are used to adjust the strings and colors of icons that contain VS icon topics. In short, HTML Shiki generates just like your code in VS icon and works great in your fixed website generator.
Shiki
uses TextMate’s grammar to encode strings, and colors the tokens via VS Code themes. In short, Shiki generates HTML that looks exactly like your code in VS Code and works great in your static website builder (or your dynamic website).
There is no RegEx meant to be preserved, no CSS meant to be preserved, and no HTML meant to be preserved. And as your favorite languages and themes in VS Code evolve – syntax highlighting will, too.
Custom display of code blocks
You will use the default function to display the codeToHtml
code blocks from the Highlighter instance.
If you want to convert emoticons into an emoticon yourself, Shiki offers two main ways to do so.
codeToThemedTokens
takes a string of code and a language identifier and returns an array of tokens. A token is one piece of code, for example, a keyword, string, comment, etc.renderToHTML
takes an array of tokens and returns an HTML string representing the rendered code.
Multiple Shiki instances on the same page
If you want to use Shiki in a browser multiple times on the same page, you have to make sure that there is only one Highlighter
instance. Use cases are for example markdown editor and preview or wrapping Shiki inside a web component.
Common scenarios are using the observed pattern, or using a singleton pattern.
In either case, you must ensure that the Highlighter is only instantiated once and that it is booted asynchronously before any of the exposed functions are called.
Must Read: JavaScript Library To Syntax Highlighting Code In Notepad++ | CodeHighlighter
How to make use of it:
1. Install the shiki.js
package deal managers.
# Yarn $ yarn add shiki # NPM $ npm install shiki --save
2. Import the shiki.js library.
const shiki = require('shiki')
// or <script src="dist/index.iife.js"></script>
3. Create a container to carry the Syntax Highlighter.
<div id="output"></div>
4. Initialize the shiki.js and insert the source code to be highlighted.
shiki .getHighlighter({ theme: 'nord' }) .then(highlighter => { // codeToHtml(code, language) const code = highlighter.codeToHtml(`console.log('shiki');`, 'js') document.getElementById('output').innerHTML = code })
Seen
- Shiki Docs: https://shiki.matsu.io
- Interactive Demo on CodeSandbox (with Next.js): https://codesandbox.io/s/shiki-next-js-cir0y
- VS Code website, such as on the Notebook API page.
- TypeScript website, such as on the Basic Types documentation page.
- Markdown Preview Shiki Highlighting, a VS Code plugin to use Shiki’s highlighting in Markdown preview.
- Fatih Kalifa’s website
- Blockstack Documentation
- Torchlight, a syntax highlighting API powered by the Shiki tokenizer.
- CodeChalk, A neat terminal code highlighting tool powered by Shiki tokenizer and Chalk.
- Code Hike, is a collection of components and mods for MDX code blocks.
See Demo And Download

Official Website(shikijs): Click Here
This superior jQuery/javascript plugin is developed by shikijs. For extra Advanced Usage, please go to the official website.