File tree 1 file changed +16
-24
lines changed
src/node/markdown/plugins
1 file changed +16
-24
lines changed Original file line number Diff line number Diff line change 6
6
createRangeProcessor ,
7
7
getHighlighter ,
8
8
Processor ,
9
- addClass ,
10
9
defineProcessor
11
10
} from 'shiki-processor'
12
11
import type { ThemeOptions } from '../markdown'
@@ -69,7 +68,8 @@ export async function highlight(
69
68
processors
70
69
} )
71
70
72
- const styleRE = / < p r e .* ( s t y l e = " .* " ) > < c o d e > /
71
+ const classRE = / < p r e [ ^ > ] * c l a s s = " ( .* ?) " /
72
+ const styleRE = / < p r e [ ^ > ] * ( s t y l e = " .* ?" ) /
73
73
const preRE = / ^ < p r e ( .* ?) > /
74
74
const vueRE = / - v u e $ /
75
75
@@ -93,29 +93,21 @@ export async function highlight(
93
93
)
94
94
}
95
95
96
- const dark = addClass (
97
- cleanup (
98
- highlighter . codeToHtml ( str , {
99
- lang,
100
- lineOptions,
101
- theme : getThemeName ( theme . dark )
102
- } )
103
- ) ,
104
- 'vp-code-dark' ,
105
- 'pre'
106
- )
96
+ const dark = cleanup (
97
+ highlighter . codeToHtml ( str , {
98
+ lang,
99
+ lineOptions,
100
+ theme : getThemeName ( theme . dark )
101
+ } )
102
+ ) . replace ( classRE , ( _ , cls ) => _ . replace ( cls , 'vp-code-dark' ) )
107
103
108
- const light = addClass (
109
- cleanup (
110
- highlighter . codeToHtml ( str , {
111
- lang,
112
- lineOptions,
113
- theme : getThemeName ( theme . light )
114
- } )
115
- ) ,
116
- 'vp-code-light' ,
117
- 'pre'
118
- )
104
+ const light = cleanup (
105
+ highlighter . codeToHtml ( str , {
106
+ lang,
107
+ lineOptions,
108
+ theme : getThemeName ( theme . light )
109
+ } )
110
+ ) . replace ( classRE , ( _ , cls ) => _ . replace ( cls , 'vp-code-light' ) )
119
111
120
112
return dark + light
121
113
}
You can’t perform that action at this time.
0 commit comments