Skip to content
Source
Sign inSign up
TanStack/highlight
Open History to see the last commit

react.ts

40 lines777 Bytes

1import type {
2 Highlighter,
3 HighlightDecoration,
4 RenderedCodeBlockData,
5} from './core.js'
6​
7export type HighlightedCodeBlockProps = RenderedCodeBlockData & {
8 className?: string
9}
10​
11export type CreateHighlightedCodeBlockPropsOptions = {
12 className?: string
13 code: string
14 decorations?: ReadonlyArray<HighlightDecoration>
15 highlighter: Highlighter
16 lang?: string
17 lineNumbers?: boolean
18 title?: string
20​
21export function createHighlightedCodeBlockProps({
22 className,
23 code,
24 decorations,
25 highlighter,
26 lang,
27 lineNumbers,
28 title,
29}: CreateHighlightedCodeBlockPropsOptions): HighlightedCodeBlockProps {
30 return {
31 ...highlighter.renderCodeBlockData({
32 code,
33 decorations,
34 lang,
35 lineNumbers,
36 title,
37 }),
38 className,
39 }