Skip to content

Commit 3bc803e

Browse files
authored
Merge pull request #54 from rtfpessoa/allow-disable-highlight
feature: Allow disabling hightlight
2 parents 12ccb50 + 2efdd09 commit 3bc803e

File tree

6 files changed

+19
-6
lines changed

6 files changed

+19
-6
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Usage: diff2html [options] -- [diff args]
5959
| --- | --- | --- | --- | --- |
6060
| -s | --style | Output style | `line`, `side` | `line` |
6161
| --sc | --synchronisedScroll | Synchronised horizontal scroll | `true`, `false` | `true` |
62+
| --hc | --highlightCode | Highlight code | `true`, `false` | `true` |
6263
| --su | --summary | Show files summary | `closed`, `open`, `hidden` | `closed` |
6364
| --lm | --matching | Diff line matching type | `lines`, `words`, `none` | `none` |
6465
| --lmt | --matchWordsThreshold | Diff line matching word threshold | | `0.25` |

src/cli.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ function prepareHTML(diffHTMLContent: string, config: Configuration): string {
3737
.replace("<!--diff2html-js-ui-->", `<script>\n${jsUiContent}\n</script>`)
3838
.replace("//diff2html-fileListCloseable", `diff2htmlUi.fileListCloseable("#diff", ${config.showFilesOpen});`)
3939
.replace("//diff2html-synchronisedScroll", `diff2htmlUi.synchronisedScroll("#diff", ${config.synchronisedScroll});`)
40+
.replace("//diff2html-highlightCode", config.highlightCode ? `diff2htmlUi.highlightCode("#diff");` : "")
4041
.replace("<!--diff2html-diff-->", diffHTMLContent);
4142
}
4243

src/configuration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export function parseArgv(argv: Argv): [Diff2Html.Options, Configuration] {
1717
const configuration: Configuration = {
1818
showFilesOpen: argv.summary === "open" || false,
1919
synchronisedScroll: argv.synchronisedScroll,
20+
highlightCode: argv.highlightCode,
2021
formatType: argv.format,
2122
outputDestinationType: argv.output,
2223
outputDestinationFile: argv.file,

src/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ export type InputType = "file" | "command" | "stdin";
66
export type OutputType = "preview" | "stdout";
77
export type DiffyType = "browser" | "pbcopy" | "print";
88

9-
export interface Configuration {
9+
export type Configuration = {
1010
synchronisedScroll: boolean;
1111
showFilesOpen: boolean;
12+
highlightCode: boolean;
1213
formatType: FormatType;
1314
outputDestinationType: OutputType;
1415
outputDestinationFile?: string;
1516
inputSource: InputType;
1617
diffyType?: DiffyType;
1718
htmlWrapperTemplate: string;
1819
ignore: string[];
19-
}
20+
};

src/yargs.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import * as yargs from "yargs";
22

33
import { StyleType, SummaryType, LineMatchingType, FormatType, InputType, OutputType, DiffyType } from "./types";
44

5-
export interface Argv {
5+
export type Argv = {
66
style: StyleType;
77
synchronisedScroll: boolean;
8+
highlightCode: boolean;
89
summary: SummaryType;
910
matching: LineMatchingType;
1011
matchWordsThreshold: number;
@@ -17,7 +18,7 @@ export interface Argv {
1718
htmlWrapperTemplate?: string;
1819
ignore?: string[];
1920
extraArguments: string[];
20-
}
21+
};
2122

2223
export function setup(): Argv {
2324
const currentYear = new Date().getFullYear();
@@ -50,6 +51,14 @@ export function setup(): Argv {
5051
default: true
5152
}
5253
})
54+
.options({
55+
highlightCode: {
56+
alias: "hc",
57+
describe: "Highlight Code",
58+
type: "boolean",
59+
default: true
60+
}
61+
})
5362
.options({
5463
summary: {
5564
alias: "su",
@@ -170,7 +179,7 @@ export function setup(): Argv {
170179
.strict(true)
171180
.recommendCommands().argv;
172181

173-
// HACK: Forcing conversions to better types here, since choices types are enforced in the beggining
182+
// HACK: Forcing conversions to better types here, since choices types are enforced in the beginning
174183
return {
175184
...argv,
176185
style: argv.style as StyleType,

template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
var diff2htmlUi = new Diff2HtmlUI();
2626
//diff2html-fileListCloseable
2727
//diff2html-synchronisedScroll
28-
diff2htmlUi.highlightCode("#diff");
28+
//diff2html-highlightCode
2929
});
3030
</script>
3131
</head>

0 commit comments

Comments
 (0)