@@ -31,51 +31,7 @@ type PositionedToken = ThemedToken & { start: number; end: number };
31
31
* Highlight a code block while preserving inline elements.
32
32
*/
33
33
export async function highlight ( block : DocumentBlockCode ) : Promise < HighlightLine [ ] > {
34
- const langName = block . data . syntax ? getLanguageForSyntax ( block . data . syntax ) : null ;
35
- if ( ! langName ) {
36
- // Language not found, fallback to plain highlighting
37
- return plainHighlighting ( block ) ;
38
- }
39
-
40
- const inlines : InlineIndexed [ ] = [ ] ;
41
- const code = getPlainCodeBlock ( block , inlines ) ;
42
-
43
- inlines . sort ( ( a , b ) => {
44
- return a . start - b . start ;
45
- } ) ;
46
-
47
- const highlighter = await loadHighlighter ( ) ;
48
- await loadHighlighterLanguage ( langName ) ;
49
- const lines = highlighter . codeToTokensBase ( code , {
50
- lang : langName ,
51
- } ) ;
52
- let currentIndex = 0 ;
53
-
54
- return lines . map ( ( tokens , index ) => {
55
- const lineBlock = block . nodes [ index ] ;
56
- const result : HighlightToken [ ] = [ ] ;
57
-
58
- const eatToken = ( ) : PositionedToken | null => {
59
- const token = tokens . shift ( ) ;
60
- if ( token ) {
61
- currentIndex += token . content . length ;
62
- }
63
- return token
64
- ? { ...token , start : currentIndex - token . content . length , end : currentIndex }
65
- : null ;
66
- } ;
67
-
68
- while ( tokens . length > 0 ) {
69
- result . push ( ...matchTokenAndInlines ( eatToken , inlines ) ) ;
70
- }
71
-
72
- currentIndex += 1 ; // for the \n
73
-
74
- return {
75
- highlighted : ! ! lineBlock . data . highlighted ,
76
- tokens : result ,
77
- } ;
78
- } ) ;
34
+ return plainHighlighting ( block ) ;
79
35
}
80
36
81
37
/**
0 commit comments