@@ -27,29 +27,32 @@ export const Highlight = component$(
27
27
} : HighlightProps ) => {
28
28
const codeSig = useSignal ( '' ) ;
29
29
30
- useVisibleTask$ ( async function createHighlightedCode ( ) {
31
- const highlighter = await ( window as any ) . shikiji ;
32
- let modifiedCode : string = code ;
30
+ useVisibleTask$ (
31
+ async function createHighlightedCode ( ) {
32
+ const highlighter = await ( window as any ) . shikiji ;
33
+ let modifiedCode : string = code ;
33
34
34
- let partsOfCode = modifiedCode . split ( splitCommentStart ) ;
35
- if ( partsOfCode . length > 1 ) {
36
- modifiedCode = partsOfCode [ 1 ] ;
37
- }
35
+ let partsOfCode = modifiedCode . split ( splitCommentStart ) ;
36
+ if ( partsOfCode . length > 1 ) {
37
+ modifiedCode = partsOfCode [ 1 ] ;
38
+ }
38
39
39
- partsOfCode = modifiedCode . split ( splitCommentEnd ) ;
40
- if ( partsOfCode . length > 1 ) {
41
- modifiedCode = partsOfCode [ 0 ] ;
42
- }
40
+ partsOfCode = modifiedCode . split ( splitCommentEnd ) ;
41
+ if ( partsOfCode . length > 1 ) {
42
+ modifiedCode = partsOfCode [ 0 ] ;
43
+ }
43
44
44
- const str = await highlighter . codeToHtml ( modifiedCode , {
45
- lang : language ,
46
- themes : {
47
- light : 'github-dark' ,
48
- dark : 'github-dark' ,
49
- } ,
50
- } ) ;
51
- codeSig . value = str . toString ( ) ;
52
- } ) ;
45
+ const str = await highlighter . codeToHtml ( modifiedCode , {
46
+ lang : language ,
47
+ themes : {
48
+ light : 'github-dark' ,
49
+ dark : 'github-dark' ,
50
+ } ,
51
+ } ) ;
52
+ codeSig . value = str . toString ( ) ;
53
+ } ,
54
+ { strategy : 'document-idle' } ,
55
+ ) ;
53
56
54
57
return (
55
58
< div class = "code-example relative max-h-[31.25rem] rounded-b-xl" >
0 commit comments