File tree Expand file tree Collapse file tree 1 file changed +33
-2
lines changed Expand file tree Collapse file tree 1 file changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -11,11 +11,42 @@ export class HtmlDiffClient {
11
11
12
12
const unifiedDiff = createTwoFilesPatch ( lhsPath , rhsPath , lhs , rhs ) ;
13
13
14
- this . htmlOutput = Diff2Html . html ( unifiedDiff , {
15
- drawFileList : true ,
14
+ const htmlOutput = Diff2Html . html ( unifiedDiff , {
15
+ drawFileList : false ,
16
16
outputFormat : "side-by-side" ,
17
17
matching : "lines" ,
18
18
} ) ;
19
+
20
+ // Step 4: Dynamically read CSS file
21
+ const diff2htmlCss = fs . readFileSync (
22
+ "./node_modules/diff2html/bundles/css/diff2html.min.css" ,
23
+ "utf8"
24
+ ) ;
25
+
26
+ // Step 5: Embed CSS into the final HTML
27
+ this . htmlOutput = `
28
+ <!DOCTYPE html>
29
+ <html>
30
+ <head>
31
+ <meta charset="UTF-8">
32
+ <title>Diff View</title>
33
+ <style>
34
+ body {
35
+ font-family: Arial, sans-serif;
36
+ margin: 0;
37
+ padding: 0;
38
+ }
39
+ .d2h-wrapper {
40
+ font-size: 14px;
41
+ }
42
+ /* Inline CSS for diff2html */
43
+ ${ diff2htmlCss }
44
+ </style>
45
+ </head>
46
+ <body>
47
+ ${ htmlOutput }
48
+ </body>
49
+ </html>` ;
19
50
}
20
51
21
52
writeOutput ( outputPath : string ) {
You can’t perform that action at this time.
0 commit comments