11import path from 'node:path' ;
2+ import { execFileSync } from 'node:child_process' ;
23import { defineUserConfig } from '@vuepress/cli' ;
34import { gitPlugin } from '@vuepress/plugin-git' ;
45import { feedPlugin } from '@vuepress/plugin-feed' ;
@@ -10,6 +11,7 @@ import { copyCodePlugin } from '@vuepress/plugin-copy-code';
1011import { docsearchPlugin } from '@vuepress/plugin-docsearch' ;
1112import { backToTopPlugin } from '@vuepress/plugin-back-to-top' ;
1213import { mediumZoomPlugin } from '@vuepress/plugin-medium-zoom' ;
14+ import { transformerRenderWhitespace } from '@shikijs/transformers' ;
1315
1416import {
1517 navbarDe ,
@@ -194,18 +196,46 @@ export default defineUserConfig({
194196 shikiPlugin ( {
195197 themes : {
196198 dark : 'dark-plus' ,
197- vitessedark : 'vitesse -dark' , // pre-load vitesse -dark for ansi code blocks
199+ onedarkpro : 'one -dark-pro ' , // pre-load one -dark-pro for ansi code blocks
198200 } ,
199201 lineNumbers : 10 ,
200202 transformers : [
203+ transformerRenderWhitespace ( ) ,
204+ {
205+ // highlight nushell code blocks with nu-highlight
206+ preprocess ( code , options ) {
207+ if ( this . options . lang != 'nushell' && this . options . lang != 'nu' ) {
208+ return code ;
209+ }
210+
211+ this . options . defaultColor = 'onedarkpro' ;
212+ // this doesn't work at the top-level for some reason
213+ this . options . colorReplacements = {
214+ // make one-dark-pro background color the same as dark-plus
215+ '#282c34' : '#1e1e1e' ,
216+ // HACK: change color of comments, since nu-highlight can't highlight them
217+ '#abb2bf' : '#80858f' ,
218+ } ;
219+
220+ // switch language to ansi, and highlight code blocks with nu-highlight
221+ this . options . lang = 'ansi' ;
222+ let result = execFileSync ( 'nu' , [ '--stdin' , 'tools/highlight.nu' ] , {
223+ input : code ,
224+ } ) ;
225+ return result . toString ( ) . trimEnd ( ) ;
226+ } ,
227+ } ,
228+ // use one-dark-pro theme for ansi code blocks
201229 {
202230 preprocess ( code , options ) {
203231 if ( options . lang == 'ansi' ) {
204- this . options . defaultColor = 'vitessedark ' ;
232+ this . options . defaultColor = 'onedarkpro ' ;
205233 // this doesn't work at the top-level for some reason
206234 this . options . colorReplacements = {
207- // make vitesse-dark background color the same as dark-plus
208- '#121212' : '#1e1e1e' ,
235+ // make one-dark-pro background color the same as dark-plus
236+ '#282c34' : '#1e1e1e' ,
237+ // HACK: change color of comments, since nu-highlight can't highlight them
238+ '#abb2bf' : '#80858f' ,
209239 } ;
210240 }
211241 return code ;
0 commit comments