shiki-codegen | Shiki

ID: 1755https://shiki.matsu.io/packages/codegen
Source

shiki-codegen

NPM version
NPM downloads
GitHub

Codegen for Shiki to create optimized bundles dedicated for your usage.

Usage

CLI

npx shiki-codegen \
  --langs typescript,javascript,vue \
  --themes light-plus,dark-plus \
  --engine javascript \
  ./shiki.bundle.ts

shiki.bundle.ts will be created with the code that you can use in your project.

import { codeToHtml } from './shiki.bundle'

const html = await codeToHtml(code, {
  lang: 'typescript',
  theme: 'light-plus',
})

Programmatic

You can also use shiki-codegen programmatically, and write the generated code to a file:

import { codegen } from 'shiki-codegen'

const { code } = await codegen({
  langs: ['typescript', 'javascript', 'vue'],
  themes: ['light-plus', 'dark-plus'],
  engine: 'javascript',
  typescript: true,
})

// Write the code to a file

Edit this page on GitHub: Suggest changes to this page