@@ -24,7 +24,7 @@ export interface ShikiOptions {
2424
2525let highlighter : Highlighter | null = null
2626let highlighterPromise : Promise < Highlighter > | null = null
27- let loadedThemes : Set < string > = new Set ( )
27+ const loadedThemes : Set < string > = new Set ( )
2828
2929/**
3030 * Get or create the Shiki highlighter instance
@@ -107,44 +107,42 @@ export async function highlightCode(
107107
108108 // Use codeToTokens to get raw tokens
109109 const result = hl . codeToTokens ( code , {
110- lang : language ,
110+ lang : language as BundledLanguage ,
111111 theme : theme as BundledTheme | string ,
112112 } )
113113
114- console . log ( result . tokens )
115114 // Build minimark nodes from tokens (flatten all lines)
116115 const allTokens : MinimarkNode [ ] = [ ]
117-
116+
118117 for ( let i = 0 ; i < result . tokens . length ; i ++ ) {
119118 const lineTokens = result . tokens [ i ]
120119
121120 const lineTokensNodes : MinimarkNode [ ] = [ ]
122121 for ( const token of lineTokens ) {
123122 const style = colorToStyle ( token . color )
124-
123+
125124 // Create a span with style for colored tokens
126125 // Note: we always wrap in spans if there's a style, even for whitespace
127126 // because the whitespace may be part of the styled token
128127 if ( style ) {
129128 lineTokensNodes . push ( [ 'span' , { style } , token . content ] as MinimarkNode )
130- } else {
129+ }
130+ else {
131131 // Plain text token (no style)
132132 lineTokensNodes . push ( token . content )
133133 }
134134 }
135135
136-
137136 allTokens . push ( [ 'span' , { class : 'line' } , ...lineTokensNodes ] )
138137
139138 // Add newline between lines (except for last line)
140139 if ( i < result . tokens . length - 1 ) {
141140 allTokens . push ( '\n' )
142141 }
143-
144142 }
145143
146- return {
147- nodes : allTokens ,
144+ return {
145+ nodes : allTokens ,
148146 language,
149147 bgColor : result . bg ,
150148 fgColor : result . fg ,
@@ -176,29 +174,29 @@ export async function highlightCodeBlocks(
176174
177175 // Check if this is a pre > code structure
178176 if ( Array . isArray ( node ) && node [ 0 ] === 'pre' ) {
179- const [ tag , attrs , ...children ] = node
177+ const [ _tag , attrs , ...children ] = node
180178
181179 // Look for code element as child
182180 if ( children . length > 0 && Array . isArray ( children [ 0 ] ) && children [ 0 ] [ 0 ] === 'code' ) {
183181 const codeNode = children [ 0 ]
184182 const [ , codeAttrs , content ] = codeNode
185183
186184 // Extract language from attributes
187- const language = ( attrs as any ) ?. language ||
188- ( ( codeAttrs as any ) ?. class as string ) ?. replace ( 'language-' , '' ) ||
189- 'text'
185+ const language = ( attrs as any ) ?. language
186+ || ( ( codeAttrs as any ) ?. class as string ) ?. replace ( 'language-' , '' )
187+ || 'text'
190188
191189 if ( typeof content === 'string' ) {
192190 try {
193191 const { nodes, bgColor, fgColor } = await highlightCode ( content , language , options )
194192
195193 // Build pre attributes with Shiki styling
196- const newPreAttrs : any = {
194+ const newPreAttrs : any = {
197195 ...attrs ,
198196 class : `shiki ${ options . theme || 'github-dark' } ` ,
199197 tabindex : '0' ,
200198 }
201-
199+
202200 if ( bgColor || fgColor ) {
203201 const styles : string [ ] = [ ]
204202 if ( bgColor ) styles . push ( `background-color:${ bgColor } ` )
0 commit comments