{"id":13453693,"url":"https://github.com/rtfpessoa/diff2html-cli","last_synced_at":"2025-04-11T03:29:26.388Z","repository":{"id":30238589,"uuid":"33789762","full_name":"rtfpessoa/diff2html-cli","owner":"rtfpessoa","description":"Pretty diff to html javascript cli (diff2html-cli)","archived":false,"fork":false,"pushed_at":"2024-11-18T22:42:29.000Z","size":1872,"stargazers_count":555,"open_issues_count":11,"forks_count":52,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-02T16:52:43.558Z","etag":null,"topics":["cli","colorized","diff","diff2html","git","hacktoberfest","html","javascript","pretty","syntax-highlighting","typescript","unified","unified-diffs"],"latest_commit_sha":null,"homepage":"https://diff2html.xyz","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rtfpessoa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-04-11T19:45:10.000Z","updated_at":"2025-03-20T13:03:04.000Z","dependencies_parsed_at":"2024-11-28T03:01:26.732Z","dependency_job_id":"ea8b6515-4c28-44dd-9d29-073f9f9b9acc","html_url":"https://github.com/rtfpessoa/diff2html-cli","commit_stats":{"total_commits":254,"total_committers":17,"mean_commits":"14.941176470588236","dds":0.4448818897637795,"last_synced_commit":"18add5d220d624022dd24a303c55f4a63547b65b"},"previous_names":[],"tags_count":81,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtfpessoa%2Fdiff2html-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtfpessoa%2Fdiff2html-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtfpessoa%2Fdiff2html-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtfpessoa%2Fdiff2html-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rtfpessoa","download_url":"https://codeload.github.com/rtfpessoa/diff2html-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248335215,"owners_count":21086538,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","colorized","diff","diff2html","git","hacktoberfest","html","javascript","pretty","syntax-highlighting","typescript","unified","unified-diffs"],"created_at":"2024-07-31T08:00:45.584Z","updated_at":"2025-04-11T03:29:26.361Z","avatar_url":"https://github.com/rtfpessoa.png","language":"TypeScript","readme":"# diff2html-cli\n\n[![npm](https://img.shields.io/npm/v/diff2html-cli)](https://www.npmjs.com/package/diff2html-cli)\n[![node](https://img.shields.io/node/v/diff2html-cli)](https://www.npmjs.com/package/diff2html-cli)\n[![npm](https://img.shields.io/npm/l/diff2html-cli)](https://www.npmjs.com/package/diff2html-cli)\n[![GitHub Actions](https://github.com/rtfpessoa/diff2html-cli/actions/workflows/release.yml/badge.svg)](https://github.com/rtfpessoa/diff2html-cli/actions/workflows/release.yml)\n\n[![npm weekly downloads](https://img.shields.io/npm/dw/diff2html-cli)](https://www.npmjs.com/package/diff2html-cli)\n[![npm monthly downloads](https://img.shields.io/npm/dm/diff2html-cli)](https://www.npmjs.com/package/diff2html-cli)\n[![npm yearly downloads](https://img.shields.io/npm/dy/diff2html-cli)](https://www.npmjs.com/package/diff2html-cli)\n[![npm downloads](https://img.shields.io/npm/dt/diff2html-cli)](https://www.npmjs.com/package/diff2html-cli)\n\nDiff to Html generates pretty HTML diffs from unified and git diff output in your terminal\n\n## Table of Contents\n\n\u003c!-- toc --\u003e\n\n- [Features](#features)\n- [Online Example](#online-example)\n- [Distributions](#distributions)\n- [Setup](#setup)\n- [Usage](#usage)\n  - [Exit Status Codes](#exit-status-codes)\n  - [Custom HTML wrapper template](#custom-html-wrapper-template)\n  - [Examples](#examples)\n- [Contribute](#contribute)\n- [Developing](#developing)\n- [License](#license)\n- [Thanks](#thanks)\n\n\u003c!-- tocstop --\u003e\n\n## Features\n\n- Unified diff and Git diff input\n\n- `line-by-line` and `side-by-side` diff\n\n- new and old line numbers\n\n- inserted and removed lines\n\n- GitHub like style\n\n- Code syntax highlight\n\n- Line similarity matching\n\n## Online Example\n\n\u003e Go to [Diff2HTML](https://diff2html.xyz/)\n\n## Distributions\n\n- [NPM CLI](https://www.npmjs.org/package/diff2html-cli)\n- [NPM / Node.js library [ES5 \u0026 ES6]](https://github.com/rtfpessoa/diff2html)\n- [CDNJS](https://cdnjs.com/libraries/diff2html)\n- [WebJar](http://www.webjars.org/)\n\n## Setup\n\n```sh\nnpm install -g diff2html-cli\n```\n\n## Usage\n\nUsage: diff2html [ flags and/or options ] -- [git diff passthrough flags and options]\n\n| flag  | alias                             | description                                                                                        | choices                      | default   |\n| ----- | --------------------------------- | -------------------------------------------------------------------------------------------------- | ---------------------------- | --------- |\n| -s    | --style                           | Output style                                                                                       | `line`, `side`               | `line`    |\n| --fct | --fileContentToggle               | Adds a viewed checkbox to toggle file content                                                      | `true`, `false`              | `true`    |\n| --sc  | --synchronisedScroll              | Synchronised horizontal scroll                                                                     | `true`, `false`              | `true`    |\n| --hc  | --highlightCode                   | Highlight code                                                                                     | `true`, `false`              | `true`    |\n| --cs  | --colorScheme                     | Color scheme                                                                                       | `auto`, `dark`, `light`      | `auto`    |\n| --su  | --summary                         | Show files summary                                                                                 | `closed`, `open`, `hidden`   | `closed`  |\n| -d    | --diffStyle                       | Diff style                                                                                         | `word`, `char`               | `word`    |\n| --lm  | --matching                        | Diff line matching type                                                                            | `lines`, `words`, `none`     | `none`    |\n| --lmt | --matchWordsThreshold             | Diff line matching word threshold                                                                  |                              | `0.25`    |\n| --lmm | --matchingMaxComparisons          | Diff line matching maximum line comparisons of a block of changes                                  |                              | `2500`    |\n|       | --diffMaxChanges                  | Number of changed lines after which a file diff is deemed as too big and not displayed             |                              |           |\n|       | --diffMaxLineLength               | Number of characters in a diff line after which a file diff is deemed as too big and not displayed |                              |           |\n|       | --renderNothingWhenEmpty          | Render nothing if the diff shows no change in its comparison                                       |                              | `false`   |\n|       | --maxLineSizeInBlockForComparison | Maximum number of characters of the bigger line in a block to apply comparison                     |                              | `200`     |\n|       | --maxLineLengthHighlight          | Maximum number of characters in a line to apply highlight                                          |                              | `10000`   |\n| --hwt | --htmlWrapperTemplate             | Path to custom template to be rendered when using the `html` output format                         | `[string]`                   |\n| -t    | --title                           | Page title for `html` output                                                                       | `[string]`                   |\n| -f    | --format                          | Output format                                                                                      | `html`, `json`               | `html`    |\n| -i    | --input                           | Diff input source                                                                                  | `file`, `command`, `stdin`   | `command` |\n| -o    | --output                          | Output destination                                                                                 | `preview`, `stdout`          | `preview` |\n| -u    | --diffy                           | Upload to diffy.org                                                                                | `browser`, `pbcopy`, `print` |           |\n| -F    | --file                            | Send output to file (overrides output option)                                                      | `[string]`                   |           |\n| --ig  | --ignore                          | Ignore particular files from the diff                                                              | `[string]`                   |           |\n| -v    | --version                         | Show version number                                                                                |                              |           |\n| -h    | --help                            | Show help                                                                                          |                              |           |\n\n### Exit Status Codes\n\n- :tada: 0: Success\n- :dizzy_face: 1: Generic Error\n- :cold_sweat: 3: Input diff is empty\n- :cop: 4: Value of `--hwt | --htmlWrapperTemplate` is not a valid file\n\n### Custom HTML wrapper template\n\nThe template is a very based on a simple replace of several placeholders as coded\nhttps://github.com/rtfpessoa/diff2html-cli/blob/master/src/cli.ts#L40\n\nTo provide a custom template you need to make sure you have the following comments and imports in your HTML, exactly as\nthey are here:\n\n- Inside the `\u003chead\u003e` tag\n\n```html\n\u003clink rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/styles/github.min.css\" /\u003e\n\u003c!--diff2html-css--\u003e\n\u003c!--diff2html-js-ui--\u003e\n\u003cscript\u003e\n  document.addEventListener('DOMContentLoaded', () =\u003e {\n    const targetElement = document.getElementById('diff');\n    const diff2htmlUi = new Diff2HtmlUI(targetElement);\n    //diff2html-fileListToggle\n    //diff2html-synchronisedScroll\n    //diff2html-highlightCode\n  });\n\u003c/script\u003e\n```\n\n- Inside the `\u003cbody\u003e` tag\n\n```html\n\u003cdiv id=\"diff\"\u003e\n  \u003c!--diff2html-diff--\u003e\n\u003c/div\u003e\n```\n\n### Examples\n\n`diff2html -s line -f html -d word -i command -o preview -- -M HEAD~1`\n\n- diff last commit, line by line, word comparison between lines, previewed in the browser and input from git diff\n  command\n\n`diff2html -i file -- my-file-diff.diff`\n\n- reading the input from a file\n\n`diff -u file1.txt file2.txt | diff2html -i stdin`\n\n- reading diff from stdin\n\n`diff2html -f json -o stdout -- -M HEAD~1`\n\n- print json format to stdout\n\n`diff2html -F my-pretty-diff.html -- -M HEAD~1`\n\n- print to file\n\n`diff2html -F my-pretty-diff.html --hwt my-custom-template.html -- -M HEAD~1`\n\n- print to file using custom markup templates can include the following variables\n\n`diff2html --ig package-lock.json --ig yarn.lock`\n\n- Ignore `package-lock.json` and `yarn.lock` from the generated diff\n\n_NOTE_: notice the `--` in the examples\n\n## Contribute\n\nThis is a developer friendly project, all the contributions are welcome. To contribute just send a pull request with\nyour changes following the guidelines described in `CONTRIBUTING.md`. I will try to review them as soon as possible.\n\n## Developing\n\nMake some changes, `yarn build` and then `./bin/diff2html` 😉\n\n## License\n\nCopyright 2014-present Rodrigo Fernandes. Released under the terms of the MIT license.\n\n## Thanks\n\nThis project is inspired in [pretty-diff](https://github.com/scottgonzalez/pretty-diff) by\n[Scott González](https://github.com/scottgonzalez).\n\n---\n","funding_links":[],"categories":["Packages","TypeScript","Development","包","Command-line apps","目录","\u003ca name=\"diff\"\u003e\u003c/a\u003eDiff"],"sub_categories":["Command-line apps","Chat","命令行程序","Web Development","命令行应用"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frtfpessoa%2Fdiff2html-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frtfpessoa%2Fdiff2html-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frtfpessoa%2Fdiff2html-cli/lists"}