Skip to content

typlog/shiki-transformers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

545a531 · Jun 9, 2024

History

6 Commits
Jun 8, 2024
Jun 8, 2024
Jun 8, 2024
Jun 8, 2024
Jun 8, 2024
Jun 9, 2024
Jun 8, 2024
Jun 8, 2024
Jun 8, 2024
Jun 8, 2024

Repository files navigation

@typlog/shiki-transformers

Shiki transformers by Typlog.

Install

Install via npm:

npm i @typlog/shiki-transformers

Import from CDN:

<script type="module">
  import { transformerLineHighlight } from 'https://esm.sh/@typlog/shiki-transformers'
</script>

Usage

import { codeToHtml } from 'shiki'
import { transformerLineHighlight } from '@typlog/shiki-transformers'

const code = `console.log('a')
console.log('b')
console.log('c')
console.log('e')
console.log('f')
console.log('g')
console.log('h')
`
const html = await codeToHtml(code, {
  lang: 'ts',
  theme: 'nord',
  transformers: [
    transformerLineHighlight({
      highlight: '1,3-5',
      showLines: true,
    }),
  ],
})

Options

export interface TransformerHighlightOptions {
  /**
   * Lines to be highlighted
   */
  highlight?: string;

  /**
   * Class for highlighted lines
   *
   * @default 'highlighted'
   */
  className?: string;

  /**
   * Line numbers starts from
   *
   * @default 1
   */
  lineStart?: number;

  /**
   * Display line numbers
   *
   * @default false
   */
  showLines?: boolean;
}

License

MIT License

About

Shiki transformers used by Typlog

Resources

License

Stars

Watchers

Forks

Packages

No packages published