Language Support
This feature allows users to specify which languages they want to support for syntax highlighting. The code sample demonstrates how to use the Shiki highlighter with the @shikijs/langs package to highlight JavaScript code.
const { getHighlighter } = require('shiki');
async function highlightCode() {
const highlighter = await getHighlighter({
langs: ['javascript', 'python']
});
const code = 'console.log("Hello, world!")';
const highlightedCode = highlighter.codeToHtml(code, { lang: 'javascript' });
console.log(highlightedCode);
}
highlightCode();