Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Usage: diff2html [options] -- [diff args]
| --- | --- | --- | --- | --- |
| -s | --style | Output style | `line`, `side` | `line` |
| --sc | --synchronisedScroll | Synchronised horizontal scroll | `true`, `false` | `true` |
| --hc | --highlightCode | Highlight code | `true`, `false` | `true` |
| --su | --summary | Show files summary | `closed`, `open`, `hidden` | `closed` |
| --lm | --matching | Diff line matching type | `lines`, `words`, `none` | `none` |
| --lmt | --matchWordsThreshold | Diff line matching word threshold | | `0.25` |
Expand Down
1 change: 1 addition & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function prepareHTML(diffHTMLContent: string, config: Configuration): string {
.replace("<!--diff2html-js-ui-->", `<script>\n${jsUiContent}\n</script>`)
.replace("//diff2html-fileListCloseable", `diff2htmlUi.fileListCloseable("#diff", ${config.showFilesOpen});`)
.replace("//diff2html-synchronisedScroll", `diff2htmlUi.synchronisedScroll("#diff", ${config.synchronisedScroll});`)
.replace("//diff2html-highlightCode", config.highlightCode ? `diff2htmlUi.highlightCode("#diff");` : "")
.replace("<!--diff2html-diff-->", diffHTMLContent);
}

Expand Down
1 change: 1 addition & 0 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function parseArgv(argv: Argv): [Diff2Html.Options, Configuration] {
const configuration: Configuration = {
showFilesOpen: argv.summary === "open" || false,
synchronisedScroll: argv.synchronisedScroll,
highlightCode: argv.highlightCode,
formatType: argv.format,
outputDestinationType: argv.output,
outputDestinationFile: argv.file,
Expand Down
5 changes: 3 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ export type InputType = "file" | "command" | "stdin";
export type OutputType = "preview" | "stdout";
export type DiffyType = "browser" | "pbcopy" | "print";

export interface Configuration {
export type Configuration = {
synchronisedScroll: boolean;
showFilesOpen: boolean;
highlightCode: boolean;
formatType: FormatType;
outputDestinationType: OutputType;
outputDestinationFile?: string;
inputSource: InputType;
diffyType?: DiffyType;
htmlWrapperTemplate: string;
ignore: string[];
}
};
15 changes: 12 additions & 3 deletions src/yargs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import * as yargs from "yargs";

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

export interface Argv {
export type Argv = {
style: StyleType;
synchronisedScroll: boolean;
highlightCode: boolean;
summary: SummaryType;
matching: LineMatchingType;
matchWordsThreshold: number;
Expand All @@ -17,7 +18,7 @@ export interface Argv {
htmlWrapperTemplate?: string;
ignore?: string[];
extraArguments: string[];
}
};

export function setup(): Argv {
const currentYear = new Date().getFullYear();
Expand Down Expand Up @@ -50,6 +51,14 @@ export function setup(): Argv {
default: true
}
})
.options({
highlightCode: {
alias: "hc",
describe: "Highlight Code",
type: "boolean",
default: true
}
})
.options({
summary: {
alias: "su",
Expand Down Expand Up @@ -170,7 +179,7 @@ export function setup(): Argv {
.strict(true)
.recommendCommands().argv;

// HACK: Forcing conversions to better types here, since choices types are enforced in the beggining
// HACK: Forcing conversions to better types here, since choices types are enforced in the beginning
return {
...argv,
style: argv.style as StyleType,
Expand Down
2 changes: 1 addition & 1 deletion template.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
var diff2htmlUi = new Diff2HtmlUI();
//diff2html-fileListCloseable
//diff2html-synchronisedScroll
diff2htmlUi.highlightCode("#diff");
//diff2html-highlightCode
});
</script>
</head>
Expand Down