File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
src/components/content/PrismDiffCode Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -32,18 +32,26 @@ export function PrismDiffCode({
3232 ...props
3333} : PrismDiffCodeProps ) {
3434 // Generate the diff string
35- const diff = diffLines ( original , modified , { newlineIsToken : true } ) ;
35+ const diff = diffLines ( original , modified ) ;
36+
3637 const diffString = diff
3738 . map ( ( part ) => {
39+ const value = part . value . trimEnd ( ) ;
40+
3841 if ( part . added ) {
39- return `+${ part . value . trimEnd ( ) } ` ;
42+ return `+${ value } ` ;
4043 }
4144 if ( part . removed ) {
42- return `-${ part . value . trimEnd ( ) } ` ;
45+ return `-${ value } ` ;
4346 }
44- return ` ${ part . value . trimEnd ( ) } ` ;
47+
48+ return value
49+ . split ( '\n' )
50+ . map ( ( val ) => {
51+ return val ? ` ${ val } ` : '' ;
52+ } )
53+ . join ( '\n' ) ;
4554 } )
46- . filter ( ( s ) => s . trim ( ) )
4755 . join ( '\n' ) ;
4856
4957 return < PrismCode code = { diffString } { ...props } /> ;
You can’t perform that action at this time.
0 commit comments