diff --git a/README.md b/README.md index 9760114..63c24da 100644 --- a/README.md +++ b/README.md @@ -201,7 +201,7 @@ diff2htmlUi.draw(); ```html - + @@ -227,6 +227,21 @@ document.addEventListener('DOMContentLoaded', () => { }); ``` +When using the `auto` color scheme, you will need to specify both the light and dark themes for highlight.js to use. + +```html + + +``` + #### Collapsable File Summary List > Add the dependencies. @@ -386,6 +401,8 @@ The HTML output accepts a Javascript object with configuration. Possible options > [src/templates](https://github.com/rtfpessoa/diff2html/tree/master/src/templates) - `highlightLanguages`: Map of extension to language name, used for highlighting. This overrides the default language detection based on file extensions. +- `colorScheme`: color scheme to use for the diff, default is `light`. Possible values are `light`, `dark`, and `auto` + which will use the browser's preferred color scheme. ### Diff2Html Browser diff --git a/src/__tests__/diff2html-tests.ts b/src/__tests__/diff2html-tests.ts index dbf78ab..d9e4e8c 100644 --- a/src/__tests__/diff2html-tests.ts +++ b/src/__tests__/diff2html-tests.ts @@ -1,7 +1,7 @@ import fs from 'fs'; import { parse, html } from '../diff2html'; -import { DiffFile, LineType, OutputFormatType } from '../types'; +import { ColorSchemeType, DiffFile, LineType, OutputFormatType } from '../types'; const diffExample1 = 'diff --git a/sample b/sample\n' + @@ -205,7 +205,7 @@ describe('Diff2Html', () => { it('should generate pretty line by line html from diff', () => { const result = html(diffExample1, { drawFileList: false }); expect(result).toMatchInlineSnapshot(` - "
| + |
+ @@ -1 +1 @@
+ |
+
|
+ 1
+
+ |
+
+
+ -
+
+ |
+
|
+
+ 1
+ |
+
+
+ +
+ test1
+
+ |
+
| + |
+ @@ -1 +1 @@
+ |
+
|
+ 1
+
+ |
+
+
+ -
+
+ |
+
|
+
+ 1
+ |
+
+
+ +
+ test1
+
+ |
+
| + |
+ @@ -1 +1 @@
+ |
+
|
+ 1
+
+ |
+
+
+ -
+
+ |
+
|
+
+ 1
+ |
+
+
+ +
+ test1
+
+ |
+
| + |
+ @@ -1 +1 @@
+ |
+
|
+ 1
+
+ |
+
+
+ -
+
+ |
+
|
+
+ 1
+ |
+
+
+ +
+ test1
+
+ |
+