Skip to content

Commit

Permalink
feat: accept shiki theme option (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocavue authored Jun 21, 2024
1 parent 3a38dc0 commit fbfbfc9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/shiki.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { Decoration } from 'prosemirror-view'
import { type BundledLanguage, type Highlighter } from 'shiki'
import type { BundledLanguage, BundledTheme, Highlighter } from 'shiki'

import type { Parser } from './types'

export type { Parser }

export function createParser(highlighter: Highlighter): Parser {
export function createParser(
highlighter: Highlighter,
options?: { theme?: BundledTheme },
): Parser {
return function parser({ content, language, pos }) {
const decorations: Decoration[] = []

const tokens = highlighter.codeToTokensBase(content, {
lang: language as BundledLanguage,
theme: options?.theme,
})

let from = pos + 1
Expand Down

0 comments on commit fbfbfc9

Please sign in to comment.