From ea37645d08e2e7e34df49569f4bc97f31ca248b3 Mon Sep 17 00:00:00 2001 From: lic Date: Mon, 23 Oct 2017 10:54:53 +0800 Subject: [PATCH 1/3] add Angular4 usage --- README.md | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/README.md b/README.md index 5ab7532..49e0fab 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,8 @@ diff2html generates pretty HTML diffs from git or unified diff output. * Easy code selection +* Support Angular4 + ## Online Example > Go to [diff2html](https://diff2html.xyz/) @@ -71,9 +73,56 @@ It will now be available as a global variable named `Diff2Html`. ### Node Module ```js +// import diff2html let diff2html = require("diff2html").Diff2Html ``` +### Using ing Angular4 + +in typescript file +```typescript +// import diff2html +import {Diff2Html} from 'diff2html' +import {Component, OnInit} from '@angular/core'; + + +export class AppDiffComponent implements OnInit { + outputHtml: string; + constructor() { + this.init(); + } + + ngOnInit() { + + } + + init() { + inputFormat = "--- 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'}); + this.outputHtml = outputHtml; + this. +} + +export class Diff2HtmlOptionsImpl implements Diff2Html.Options { + constructor(public inputFormat: string) { + } +} +``` + in html file + ```html + + +
+ + + ``` + in .angular-cli.json, add styles node in app node. + ```json + "styles": [ + "styles.scss", + "d2h.css" + ] + ``` ## API > Intermediate Json From Git Word Diff Output From 91134088a1b24df3c0e69867d24b0a034cb6be5c Mon Sep 17 00:00:00 2001 From: lic Date: Mon, 23 Oct 2017 11:02:25 +0800 Subject: [PATCH 2/3] update --- README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.md b/README.md index 49e0fab..8ac0544 100644 --- a/README.md +++ b/README.md @@ -102,11 +102,6 @@ export class AppDiffComponent implements OnInit { this.outputHtml = outputHtml; this. } - -export class Diff2HtmlOptionsImpl implements Diff2Html.Options { - constructor(public inputFormat: string) { - } -} ``` in html file ```html From 70b2d5620fe24046daa42ed12a54001c2c008f43 Mon Sep 17 00:00:00 2001 From: lic Date: Mon, 23 Oct 2017 11:12:09 +0800 Subject: [PATCH 3/3] update --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 8ac0544..8c9c340 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,6 @@ export class AppDiffComponent implements OnInit { inputFormat = "--- 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'}); this.outputHtml = outputHtml; - this. } ``` in html file