@@ -18,12 +18,7 @@ import {
1818 DEFAULT_THEMES ,
1919 DEFAULT_LANGS ,
2020} from './shiki-constants.js' ;
21- import {
22- getLanguage ,
23- getLinesToHighlight ,
24- lineHighlightPattern ,
25- LINE_HIGHLIGHT_CLASS ,
26- } from './utils.js' ;
21+ import { getLanguage } from './utils.js' ;
2722
2823export type RehypeSyntaxHighlightingOptions = {
2924 theme ?: ShikiTheme ;
@@ -118,8 +113,6 @@ const traverseNode = (
118113) => {
119114 try {
120115 const code = toString ( node ) ;
121- const lines = code . split ( '\n' ) ;
122- let linesToHighlight = getLinesToHighlight ( node , lines . length ) ;
123116
124117 const hast = highlighter . codeToHast ( code , {
125118 lang : lang ?? DEFAULT_LANG ,
@@ -139,36 +132,11 @@ const traverseNode = (
139132 if ( ! codeElement ) return ;
140133
141134 let lineNumber = 0 ;
142- visit ( codeElement , 'element' , ( span , spanIndex , spanParent ) => {
143- if (
144- ! spanParent ||
145- spanParent . type !== 'element' ||
146- spanParent . tagName !== 'code' ||
147- span . tagName !== 'span' ||
148- ( ! span . children . length && spanIndex === spanParent . children . length - 1 ) ||
149- ( typeof span . properties . class !== 'string' && ! Array . isArray ( span . properties . class ) ) ||
150- ! span . properties . class . includes ( 'line' )
151- ) {
152- return ;
153- }
154-
155- lineNumber ++ ;
156- if ( linesToHighlight . includes ( lineNumber ) ) {
157- if ( typeof span . properties . class === 'string' ) {
158- span . properties . class += ' ' + LINE_HIGHLIGHT_CLASS ;
159- } else {
160- span . properties . class = [ ...span . properties . class , LINE_HIGHLIGHT_CLASS ] ;
161- }
162- }
163- } ) ;
164135
165136 const preChild = codeElement . children [ 0 ] as Element ;
166137 const numberOfLines = lineNumber ;
167138
168139 node . data = node . data ?? { } ;
169- if ( node . data . meta ) {
170- node . data . meta = node . data . meta . replace ( lineHighlightPattern , '' ) . trim ( ) ;
171- }
172140 codeElement . data = node . data ;
173141 codeElement . properties . numberOfLines = numberOfLines ;
174142 if ( preChild ) {
0 commit comments