New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

diff2html

Package Overview
Dependencies
Maintainers
1
Versions
210
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

diff2html - npm Package Compare versions

Comparing version 0.2.5-1 to 0.2.6-1

22

lib/fakeRequire.js

@@ -1,4 +0,20 @@

var global = this;
/*
* Hack to allow nodejs require("package/file") in the browser
* How?
* Since every require is used as an object:
* `require("./utils.js").Utils` // (notice the `.Utils`)
*
* We can say that when there is no require method
* we use the global object in which the `Utils`
* object was already injected.
*/
var $globalHolder = (typeof module !== 'undefined' && module.exports) ||
(typeof exports !== 'undefined' && exports) ||
(typeof window !== 'undefined' && window) ||
(typeof self !== 'undefined' && self) ||
(typeof this !== 'undefined' && this) ||
Function('return this')();
function require() {
return global;
}
return $globalHolder;
}

4

package.json
{
"name": "diff2html",
"version": "0.2.5-1",
"homepage": "https://www.github.com/rtfpessoa/diff2html",
"version": "0.2.6-1",
"homepage": "http://rtfpessoa.github.io/diff2html/",
"description": "Fast Diff to colorized HTML",

@@ -6,0 +6,0 @@ "keywords": [

# Diff to Html by [rtfpessoa](https://github.com/rtfpessoa)
Diff to Html generates pretty HTML diffs from git word diff output.
Diff to Html generates pretty HTML diffs from git diff output.

@@ -15,2 +15,4 @@ ## Features

* Code syntax highlight
## Online Example

@@ -28,2 +30,4 @@

* [Node CLI](https://www.npmjs.org/package/diff2html-cli)
* Manually download and import `dist/diff2html.min.js` into your page

@@ -55,2 +59,49 @@

## Sintax Hightlight
> Add the dependencies.
Choose one color scheme, and add the main highlight code.
If your favourite language is not included in the default package also add its javascript highlight file.
```html
<!-- Stylesheet -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/styles/github.min.css">
<!-- Javascripts -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/languages/scala.min.js"></script>
```
> Invoke the highlightjs plugin
```js
document.addEventListener("DOMContentLoaded", function () {
// parse the diff to json
var diffJson = Diff2Html.getJsonFromDiff(lineDiffExample);
// collect all the file extensions in the json
var allFileLanguages = diffJson.map(function (line) {
return line.language;
});
// remove duplicated languages
var distinctLanguages = allFileLanguages.filter(function (v, i) {
return allFileLanguages.indexOf(v) == i;
});
// pass the languages to the highlightjs plugin
hljs.configure({languages: distinctLanguages});
// generate and inject the diff HTML into the desired place
document.getElementById("line-by-line").innerHTML = Diff2Html.getPrettyHtmlFromJson(diffJson);
document.getElementById("side-by-side").innerHTML = Diff2Html.getPrettySideBySideHtmlFromJson(diffJson);
// collect all the code lines and execute the highlight on them
var codeLines = document.getElementsByClassName("d2h-code-line-ctn");
[].forEach.call(codeLines, function (line) {
hljs.highlightBlock(line);
});
});
```
## Contributions

@@ -60,3 +111,3 @@

To contribute just send a pull request with your feature,fix,... and it will be reviewed asap.
To contribute just send a pull request with your changes and I will review it asap.

@@ -63,0 +114,0 @@ ## License

@@ -8,3 +8,3 @@ /*

(function (global, undefined) {
(function (ctx, undefined) {

@@ -217,8 +217,10 @@ var utils = require("./utils.js").Utils;

if (typeof module !== 'undefined' && module.exports) {
module.exports.DiffParser = new DiffParser();
} else if (typeof global.DiffParser === 'undefined') {
global.DiffParser = new DiffParser();
}
// expose this module
((typeof module !== 'undefined' && module.exports) ||
(typeof exports !== 'undefined' && exports) ||
(typeof window !== 'undefined' && window) ||
(typeof self !== 'undefined' && self) ||
(typeof $this !== 'undefined' && $this) ||
Function('return this')())["DiffParser"] = new DiffParser();
})(this);

@@ -6,7 +6,5 @@ /*

*
* Diff commands:
* git diff
*/
(function (global, undefined) {
(function (ctx, undefined) {

@@ -20,9 +18,8 @@ var diffParser = require("./diff-parser.js").DiffParser;

/*
* config
* {
* "wordByWord" : true (default)
* OR
* "charByChar" : true
* }
*
* Line diff type configuration
var config = {
"wordByWord": true, // (default)
// OR
"charByChar": true
};
*/

@@ -72,8 +69,10 @@

if (typeof module !== 'undefined' && module.exports) {
module.exports.Diff2Html = new Diff2Html();
} else if (typeof global.Diff2Html === 'undefined') {
global.Diff2Html = new Diff2Html();
}
// expose this module
((typeof module !== 'undefined' && module.exports) ||
(typeof exports !== 'undefined' && exports) ||
(typeof window !== 'undefined' && window) ||
(typeof self !== 'undefined' && self) ||
(typeof $this !== 'undefined' && $this) ||
Function('return this')())["Diff2Html"] = new Diff2Html();
})(this);

@@ -8,3 +8,3 @@ /*

(function (global, undefined) {
(function (ctx, undefined) {

@@ -21,8 +21,10 @@ var lineByLinePrinter = require("./line-by-line-printer.js").LineByLinePrinter;

if (typeof module !== 'undefined' && module.exports) {
module.exports.HtmlPrinter = new HtmlPrinter();
} else if (typeof global.HtmlPrinter === 'undefined') {
global.HtmlPrinter = new HtmlPrinter();
}
// expose this module
((typeof module !== 'undefined' && module.exports) ||
(typeof exports !== 'undefined' && exports) ||
(typeof window !== 'undefined' && window) ||
(typeof self !== 'undefined' && self) ||
(typeof $this !== 'undefined' && $this) ||
Function('return this')())["HtmlPrinter"] = new HtmlPrinter();
})(this);

@@ -8,3 +8,3 @@ /*

(function (global, undefined) {
(function (ctx, undefined) {

@@ -154,8 +154,10 @@ var diffParser = require("./diff-parser.js").DiffParser;

if (typeof module !== 'undefined' && module.exports) {
module.exports.LineByLinePrinter = new LineByLinePrinter();
} else if (typeof global.LineByLinePrinter === 'undefined') {
global.LineByLinePrinter = new LineByLinePrinter();
}
// expose this module
((typeof module !== 'undefined' && module.exports) ||
(typeof exports !== 'undefined' && exports) ||
(typeof window !== 'undefined' && window) ||
(typeof self !== 'undefined' && self) ||
(typeof $this !== 'undefined' && $this) ||
Function('return this')())["LineByLinePrinter"] = new LineByLinePrinter();
})(this);

@@ -8,8 +8,6 @@ /*

(function (global, undefined) {
(function (ctx, undefined) {
// dirty hack for browser compatibility
var jsDiff = (typeof JsDiff !== "undefined" && JsDiff) ||
require("diff") ||
require("../lib/diff.js");
var jsDiff = (typeof JsDiff !== "undefined" && JsDiff) || require("diff");
var utils = require("./utils.js").Utils;

@@ -88,8 +86,10 @@

if (typeof module !== 'undefined' && module.exports) {
module.exports.PrinterUtils = new PrinterUtils();
} else if (typeof global.PrinterUtils === 'undefined') {
global.PrinterUtils = new PrinterUtils();
}
// expose this module
((typeof module !== 'undefined' && module.exports) ||
(typeof exports !== 'undefined' && exports) ||
(typeof window !== 'undefined' && window) ||
(typeof self !== 'undefined' && self) ||
(typeof $this !== 'undefined' && $this) ||
Function('return this')())["PrinterUtils"] = new PrinterUtils();
})(this);

@@ -8,3 +8,3 @@ /*

(function (global, undefined) {
(function (ctx, undefined) {

@@ -190,8 +190,10 @@ var diffParser = require("./diff-parser.js").DiffParser;

if (typeof module !== 'undefined' && module.exports) {
module.exports.SideBySidePrinter = new SideBySidePrinter();
} else if (typeof global.SideBySidePrinter === 'undefined') {
global.SideBySidePrinter = new SideBySidePrinter();
}
// expose this module
((typeof module !== 'undefined' && module.exports) ||
(typeof exports !== 'undefined' && exports) ||
(typeof window !== 'undefined' && window) ||
(typeof self !== 'undefined' && self) ||
(typeof $this !== 'undefined' && $this) ||
Function('return this')())["SideBySidePrinter"] = new SideBySidePrinter();
})(this);

@@ -8,3 +8,3 @@ /*

(function (global, undefined) {
(function (ctx, undefined) {

@@ -30,8 +30,10 @@ function Utils() {

if (typeof module !== 'undefined' && module.exports) {
module.exports.Utils = new Utils();
} else if (typeof global.Utils === 'undefined') {
global.Utils = new Utils();
}
// expose this module
((typeof module !== 'undefined' && module.exports) ||
(typeof exports !== 'undefined' && exports) ||
(typeof window !== 'undefined' && window) ||
(typeof self !== 'undefined' && self) ||
(typeof $this !== 'undefined' && $this) ||
Function('return this')())["Utils"] = new Utils();
})(this);
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc