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 2.0.3 to 2.0.4

10

package.json
{
"name": "diff2html",
"version": "2.0.3",
"version": "2.0.4",
"homepage": "https://diff2html.xyz",

@@ -49,3 +49,3 @@ "description": "Fast Diff to colorized HTML",

"preversion": "npm run release && npm run release-website && npm test",
"version": "npm run release-bower && git add -A src dist package.json bower.json",
"version": "npm run release-bower && git add -A src dist docs package.json bower.json",
"postversion": "git push && git push --tags"

@@ -62,7 +62,7 @@ },

"devDependencies": {
"autoprefixer": "^6.4.0",
"autoprefixer": "^6.4.1",
"browserify": "^13.1.0",
"clean-css": "^3.4.19",
"codacy-coverage": "^2.0.0",
"eslint": "^3.3.1",
"eslint": "^3.5.0",
"eslint-plugin-promise": "^2.0.1",

@@ -75,3 +75,3 @@ "eslint-plugin-standard": "^2.0.0",

"nopt": "^3.0.6",
"postcss-cli": "^2.5.2",
"postcss-cli": "^2.6.0",
"uglifyjs": "^2.4.10"

@@ -78,0 +78,0 @@ },

@@ -123,6 +123,6 @@ /*

processedOldLines +=
that.makeLineHtml(deleteType, oldLine.oldNumber, oldLine.newNumber,
that.makeLineHtml(file.isCombined, deleteType, oldLine.oldNumber, oldLine.newNumber,
diff.first.line, diff.first.prefix);
processedNewLines +=
that.makeLineHtml(insertType, newLine.oldNumber, newLine.newNumber,
that.makeLineHtml(file.isCombined, insertType, newLine.oldNumber, newLine.newNumber,
diff.second.line, diff.second.prefix);

@@ -132,3 +132,3 @@ }

lines += processedOldLines + processedNewLines;
lines += that._processLines(oldLines.slice(common), newLines.slice(common));
lines += that._processLines(file.isCombined, oldLines.slice(common), newLines.slice(common));
});

@@ -150,5 +150,5 @@

if (line.type === diffParser.LINE_TYPE.CONTEXT) {
lines += that.makeLineHtml(line.type, line.oldNumber, line.newNumber, escapedLine);
lines += that.makeLineHtml(file.isCombined, line.type, line.oldNumber, line.newNumber, escapedLine);
} else if (line.type === diffParser.LINE_TYPE.INSERTS && !oldLines.length) {
lines += that.makeLineHtml(line.type, line.oldNumber, line.newNumber, escapedLine);
lines += that.makeLineHtml(file.isCombined, line.type, line.oldNumber, line.newNumber, escapedLine);
} else if (line.type === diffParser.LINE_TYPE.DELETES) {

@@ -170,3 +170,3 @@ oldLines.push(line);

LineByLinePrinter.prototype._processLines = function(oldLines, newLines) {
LineByLinePrinter.prototype._processLines = function(isCombined, oldLines, newLines) {
var lines = '';

@@ -177,3 +177,3 @@

var oldEscapedLine = utils.escape(oldLine.content);
lines += this.makeLineHtml(oldLine.type, oldLine.oldNumber, oldLine.newNumber, oldEscapedLine);
lines += this.makeLineHtml(isCombined, oldLine.type, oldLine.oldNumber, oldLine.newNumber, oldEscapedLine);
}

@@ -184,3 +184,3 @@

var newEscapedLine = utils.escape(newLine.content);
lines += this.makeLineHtml(newLine.type, newLine.oldNumber, newLine.newNumber, newEscapedLine);
lines += this.makeLineHtml(isCombined, newLine.type, newLine.oldNumber, newLine.newNumber, newEscapedLine);
}

@@ -191,3 +191,3 @@

LineByLinePrinter.prototype.makeLineHtml = function(type, oldNumber, newNumber, content, prefix) {
LineByLinePrinter.prototype.makeLineHtml = function(isCombined, type, oldNumber, newNumber, content, possiblePrefix) {
var lineNumberTemplate = hoganUtils.render(baseTemplatesPath, 'numbers', {

@@ -198,2 +198,11 @@ oldNumber: utils.valueOrEmpty(oldNumber),

var lineWithoutPrefix = content;
var prefix = possiblePrefix;
if (!prefix) {
var lineWithPrefix = printerUtils.separatePrefix(isCombined, content);
prefix = lineWithPrefix.prefix;
lineWithoutPrefix = lineWithPrefix.line;
}
return hoganUtils.render(genericTemplatesPath, 'line',

@@ -204,4 +213,4 @@ {

contentClass: 'd2h-code-line',
prefix: prefix && utils.convertWhiteSpaceToNonBreakingSpace(prefix),
content: content && utils.convertWhiteSpaceToNonBreakingSpace(content),
prefix: prefix,
content: lineWithoutPrefix,
lineNumber: lineNumberTemplate

@@ -208,0 +217,0 @@ });

@@ -18,2 +18,20 @@ /*

PrinterUtils.prototype.separatePrefix = function(isCombined, line) {
var prefix;
var lineWithoutPrefix;
if (isCombined) {
prefix = line.substring(0, 2);
lineWithoutPrefix = line.substring(2);
} else {
prefix = line.substring(0, 1);
lineWithoutPrefix = line.substring(1);
}
return {
'prefix': prefix,
'line': lineWithoutPrefix
};
};
PrinterUtils.prototype.getHtmlId = function(file) {

@@ -20,0 +38,0 @@ var hashCode = function(text) {

@@ -125,6 +125,6 @@ /*

fileHtml.left +=
that.generateSingleLineHtml(deleteType, oldLine.oldNumber,
that.generateSingleLineHtml(file.isCombined, deleteType, oldLine.oldNumber,
diff.first.line, diff.first.prefix);
fileHtml.right +=
that.generateSingleLineHtml(insertType, newLine.newNumber,
that.generateSingleLineHtml(file.isCombined, insertType, newLine.newNumber,
diff.second.line, diff.second.prefix);

@@ -137,3 +137,3 @@ }

var tmpHtml = that.processLines(oldSlice, newSlice);
var tmpHtml = that.processLines(file.isCombined, oldSlice, newSlice);
fileHtml.left += tmpHtml.left;

@@ -159,7 +159,7 @@ fileHtml.right += tmpHtml.right;

if (line.type === diffParser.LINE_TYPE.CONTEXT) {
fileHtml.left += that.generateSingleLineHtml(line.type, line.oldNumber, escapedLine, prefix);
fileHtml.right += that.generateSingleLineHtml(line.type, line.newNumber, escapedLine, prefix);
fileHtml.left += that.generateSingleLineHtml(file.isCombined, line.type, line.oldNumber, escapedLine, prefix);
fileHtml.right += that.generateSingleLineHtml(file.isCombined, line.type, line.newNumber, escapedLine, prefix);
} else if (line.type === diffParser.LINE_TYPE.INSERTS && !oldLines.length) {
fileHtml.left += that.generateSingleLineHtml(diffParser.LINE_TYPE.CONTEXT, '', '', '');
fileHtml.right += that.generateSingleLineHtml(line.type, line.newNumber, escapedLine, prefix);
fileHtml.left += that.generateSingleLineHtml(file.isCombined, diffParser.LINE_TYPE.CONTEXT, '', '', '');
fileHtml.right += that.generateSingleLineHtml(file.isCombined, line.type, line.newNumber, escapedLine, prefix);
} else if (line.type === diffParser.LINE_TYPE.DELETES) {

@@ -181,3 +181,3 @@ oldLines.push(line);

SideBySidePrinter.prototype.processLines = function(oldLines, newLines) {
SideBySidePrinter.prototype.processLines = function(isCombined, oldLines, newLines) {
var that = this;

@@ -208,10 +208,10 @@ var fileHtml = {};

if (oldLine && newLine) {
fileHtml.left += that.generateSingleLineHtml(oldLine.type, oldLine.oldNumber, oldContent, oldPrefix);
fileHtml.right += that.generateSingleLineHtml(newLine.type, newLine.newNumber, newContent, newPrefix);
fileHtml.left += that.generateSingleLineHtml(isCombined, oldLine.type, oldLine.oldNumber, oldContent, oldPrefix);
fileHtml.right += that.generateSingleLineHtml(isCombined, newLine.type, newLine.newNumber, newContent, newPrefix);
} else if (oldLine) {
fileHtml.left += that.generateSingleLineHtml(oldLine.type, oldLine.oldNumber, oldContent, oldPrefix);
fileHtml.right += that.generateSingleLineHtml(diffParser.LINE_TYPE.CONTEXT, '', '', '');
fileHtml.left += that.generateSingleLineHtml(isCombined, oldLine.type, oldLine.oldNumber, oldContent, oldPrefix);
fileHtml.right += that.generateSingleLineHtml(isCombined, diffParser.LINE_TYPE.CONTEXT, '', '', '');
} else if (newLine) {
fileHtml.left += that.generateSingleLineHtml(diffParser.LINE_TYPE.CONTEXT, '', '', '');
fileHtml.right += that.generateSingleLineHtml(newLine.type, newLine.newNumber, newContent, newPrefix);
fileHtml.left += that.generateSingleLineHtml(isCombined, diffParser.LINE_TYPE.CONTEXT, '', '', '');
fileHtml.right += that.generateSingleLineHtml(isCombined, newLine.type, newLine.newNumber, newContent, newPrefix);
} else {

@@ -225,3 +225,12 @@ console.error('How did it get here?');

SideBySidePrinter.prototype.generateSingleLineHtml = function(type, number, content, prefix) {
SideBySidePrinter.prototype.generateSingleLineHtml = function(isCombined, type, number, content, possiblePrefix) {
var lineWithoutPrefix = content;
var prefix = possiblePrefix;
if (!prefix) {
var lineWithPrefix = printerUtils.separatePrefix(isCombined, content);
prefix = lineWithPrefix.prefix;
lineWithoutPrefix = lineWithPrefix.line;
}
return hoganUtils.render(genericTemplatesPath, 'line',

@@ -232,4 +241,4 @@ {

contentClass: 'd2h-code-side-line',
prefix: prefix && utils.convertWhiteSpaceToNonBreakingSpace(prefix),
content: content && utils.convertWhiteSpaceToNonBreakingSpace(content),
prefix: prefix,
content: lineWithoutPrefix,
lineNumber: number

@@ -236,0 +245,0 @@ });

@@ -12,6 +12,2 @@ /*

Utils.prototype.convertWhiteSpaceToNonBreakingSpace = function(str) {
return str.slice(0).replace(/ /g, ' ');
};
Utils.prototype.escape = function(str) {

@@ -18,0 +14,0 @@ return str.slice(0)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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