diff --git a/.circleci/config.yml b/.circleci/config.yml
index e29e513..c7f95d4 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -8,13 +8,13 @@ jobs:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "yarn.lock" }}
- - run: npm install
+ - run: yarn
- save_cache:
key: dependency-cache-{{ checksum "yarn.lock" }}
paths:
- ./node_modules
- - run: npm run coverage
- - run: npm run check-coverage
+ - run: yarn run build
+ - run: yarn run coverage
build-latest: &latest-build
docker:
@@ -29,6 +29,7 @@ jobs:
key: dependency-cache-{{ checksum "yarn.lock" }}
paths:
- ./node_modules
+ - run: yarn run build
- run: yarn run lint
- run: yarn run coverage
- run: yarn run codacy
@@ -38,40 +39,25 @@ jobs:
- docs
- build
- build-node_4:
- <<: *common-build
- docker:
- - image: node:4
-
- build-node_5:
- <<: *common-build
- docker:
- - image: node:5
-
- build-node_6:
- <<: *common-build
- docker:
- - image: node:6
-
- build-node_7:
- <<: *common-build
- docker:
- - image: node:7
-
build-node_8:
<<: *common-build
docker:
- image: node:8
- build-node_9:
+ build-node_10:
<<: *common-build
docker:
- - image: node:9
+ - image: node:10
- build-node_10:
+ build-node_11:
+ <<: *common-build
+ docker:
+ - image: node:11
+
+ build-node_12:
<<: *latest-build
docker:
- - image: node:10
+ - image: node:12
deploy:
machine:
@@ -89,16 +75,13 @@ workflows:
version: 2
build:
jobs:
- - build-node_4
- - build-node_5
- - build-node_6
- - build-node_7
- build-node_8
- - build-node_9
- build-node_10
+ - build-node_11
+ - build-node_12
- deploy:
requires:
- - build-node_10
+ - build-node_12
filters:
branches:
only: master
diff --git a/.eslintrc.json b/.eslintrc.json
index 2ab5590..a20ab3b 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -12,14 +12,7 @@
"es6": true,
"node": true,
"browser": true,
- "commonjs": true,
- "jquery": true,
- "phantomjs": true,
- "jasmine": true,
- "mocha": true,
- "amd": true,
- "worker": true,
- "qunit": true
+ "commonjs": true
},
"plugins": ["standard", "node", "import", "promise", "@typescript-eslint", "jest"],
"globals": {
diff --git a/README.md b/README.md
index 01022db..5b6cee4 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,8 @@
# diff2html
-[](https://www.codacy.com/app/rtfpessoa/diff2html?utm_source=github.com&utm_medium=referral&utm_content=rtfpessoa/diff2html&utm_campaign=Badge_Grade)
+[](https://www.codacy.com/app/rtfpessoa/diff2html?utm_source=github.com&utm_medium=referral&utm_content=rtfpessoa/diff2html&utm_campaign=Badge_Grade)
[](https://www.codacy.com/app/rtfpessoa/diff2html?utm_source=github.com&utm_medium=referral&utm_content=rtfpessoa/diff2html&utm_campaign=Badge_Coverage)
[](https://circleci.com/gh/rtfpessoa/diff2html)
-[](https://dependencyci.com/github/rtfpessoa/diff2html)
[](https://www.npmjs.com/package/diff2html)
[](https://david-dm.org/rtfpessoa/diff2html)
@@ -22,21 +21,21 @@ diff2html generates pretty HTML diffs from git or unified diff output.
## Features
-* Supports git and unified diffs
+- Supports git and unified diffs
-* Line by line and Side by side diff
+- Line by line and Side by side diff
-* New and old line numbers
+- New and old line numbers
-* Inserted and removed lines
+- Inserted and removed lines
-* GitHub like style
+- GitHub like style
-* Code syntax highlight
+- Code syntax highlight
-* Line similarity matching
+- Line similarity matching
-* Easy code selection
+- Easy code selection
## Online Example
@@ -44,15 +43,15 @@ diff2html generates pretty HTML diffs from git or unified diff output.
## Distributions
-* [WebJar](http://www.webjars.org/)
-
-* [Node Module](https://www.npmjs.org/package/diff2html)
-
-* [Bower Package](http://bower.io/search/?q=diff2html)
-
-* [Node CLI](https://www.npmjs.org/package/diff2html-cli)
-
-* Manually download and import [dist/diff2html.min.js](./dist/diff2html.min.js) into your page
+- [WebJar](http://www.webjars.org/)
+- [Node Module](https://www.npmjs.org/package/diff2html)
+- [Node CLI](https://www.npmjs.org/package/diff2html-cli)
+- Manually download and import:
+ - Browser
+ - [build/browser/diff2html.min.js](./build/browser/diff2html.min.js) - includes the diff parser and html generator
+ - [build/browser/diff2html-ui.min.js](./build/browser/diff2html-ui.min.js) - includes the wrapper of diff2html that adds highlight, synchronized scroll, and other nice features
+ - Node.js
+ - [build/commonjs-node/diff2html.js](./build/commonjs-node/diff2html.js) - includes the diff parser and html generator
## How to use
@@ -62,7 +61,7 @@ Import the stylesheet
```html
-
+
```
You can also refer to it from a CDN like [CDNJS](https://cdnjs.com/libraries/diff2html).
@@ -73,37 +72,41 @@ Import the stylesheet and the library code
```html
-
+
-
+
```
-It will now be available as a global variable named `Diff2Html`.
+It will now be available as a global variable named `global.Diff2Html`.
```js
-var diffHtml = Diff2Html.getPrettyHtml(
- '',
- {inputFormat: 'diff', showFiles: true, matching: 'lines', outputFormat: 'side-by-side'}
-);
-document.getElementById("destination-elem-id").innerHTML = diffHtml;
+document.addEventListener("DOMContentLoaded", () => {
+ var diffHtml = global.Diff2Html.html("", {
+ drawFileList: true,
+ matching: "lines",
+ outputFormat: "side-by-side"
+ });
+ document.getElementById("destination-elem-id").innerHTML = diffHtml;
+});
```
### Node Module
```js
-let diff2html = require("diff2html").Diff2Html
+const Diff2html = require("diff2html");
+const diffJson = Diff2html.parse("");
+const diffHtml = Diff2html.html(diffJson, { drawFileList: true });
+document.getElementById("destination-elem-id").innerHTML = diffHtml;
```
### Angular
-* Typescript
+- Typescript
```typescript
-// import diff2html
-import {Diff2Html} from 'diff2html'
-import {Component, OnInit} from '@angular/core';
-
+import * as Diff2Html from "diff2html";
+import { Component, OnInit } from "@angular/core";
export class AppDiffComponent implements OnInit {
outputHtml: string;
@@ -111,18 +114,18 @@ export class AppDiffComponent implements OnInit {
this.init();
}
- ngOnInit() {
- }
+ ngOnInit() {}
init() {
- let strInput = "--- a/server/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go\n+++ b/server/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go\n@@ -1035,6 +1035,17 @@ func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (\n \n // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n \n+func Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {\n+\tr0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)))\n+\tn = int(r0)\n+\tif e1 != 0 {\n+\t\terr = errnoErr(e1)\n+\t}\n+\treturn\n+}\n+\n+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n+\n func read(fd int, p []byte) (n int, err error) {\n \tvar _p0 unsafe.Pointer\n \tif len(p) > 0 {\n";
- let outputHtml = Diff2Html.getPrettyHtml(strInput, {inputFormat: 'diff', showFiles: true, matching: 'lines'});
+ let strInput =
+ "--- a/server/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go\n+++ b/server/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go\n@@ -1035,6 +1035,17 @@ func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (\n \n // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n \n+func Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {\n+\tr0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)))\n+\tn = int(r0)\n+\tif e1 != 0 {\n+\t\terr = errnoErr(e1)\n+\t}\n+\treturn\n+}\n+\n+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n+\n func read(fd int, p []byte) (n int, err error) {\n \tvar _p0 unsafe.Pointer\n \tif len(p) > 0 {\n";
+ let outputHtml = Diff2Html.html(strInput, { drawFileList: true, matching: "lines" });
this.outputHtml = outputHtml;
}
}
```
-* HTML
+- HTML
```html
@@ -136,7 +139,7 @@ export class AppDiffComponent implements OnInit {