diff --git a/README.md b/README.md index 896cf7a..bb76ca7 100644 --- a/README.md +++ b/README.md @@ -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` | diff --git a/src/cli.ts b/src/cli.ts index 72a0b67..e206de0 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -37,6 +37,7 @@ function prepareHTML(diffHTMLContent: string, config: Configuration): string { .replace("", ``) .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("", diffHTMLContent); } diff --git a/src/configuration.ts b/src/configuration.ts index 9356ee2..958c051 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -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, diff --git a/src/types.ts b/src/types.ts index 9fa8502..09f9276 100644 --- a/src/types.ts +++ b/src/types.ts @@ -6,9 +6,10 @@ 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; @@ -16,4 +17,4 @@ export interface Configuration { diffyType?: DiffyType; htmlWrapperTemplate: string; ignore: string[]; -} +}; diff --git a/src/yargs.ts b/src/yargs.ts index b54fdbd..79135a5 100644 --- a/src/yargs.ts +++ b/src/yargs.ts @@ -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; @@ -17,7 +18,7 @@ export interface Argv { htmlWrapperTemplate?: string; ignore?: string[]; extraArguments: string[]; -} +}; export function setup(): Argv { const currentYear = new Date().getFullYear(); @@ -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", @@ -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, diff --git a/template.html b/template.html index 12c0916..0318981 100644 --- a/template.html +++ b/template.html @@ -25,7 +25,7 @@ var diff2htmlUi = new Diff2HtmlUI(); //diff2html-fileListCloseable //diff2html-synchronisedScroll - diff2htmlUi.highlightCode("#diff"); + //diff2html-highlightCode });