Prepare for release 2.0.0-beta2
This commit is contained in:
parent
e64ac60b98
commit
64c1e827b7
4 changed files with 37 additions and 16 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "diff2html",
|
"name": "diff2html",
|
||||||
"version": "2.0.0-beta1",
|
"version": "2.0.0-beta2",
|
||||||
"homepage": "http://rtfpessoa.github.io/diff2html/",
|
"homepage": "http://rtfpessoa.github.io/diff2html/",
|
||||||
"description": "Fast Diff to colorized HTML",
|
"description": "Fast Diff to colorized HTML",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|
|
||||||
42
dist/diff2html.js
vendored
42
dist/diff2html.js
vendored
|
|
@ -72,8 +72,9 @@
|
||||||
/*
|
/*
|
||||||
* Generates json object from string diff input
|
* Generates json object from string diff input
|
||||||
*/
|
*/
|
||||||
Diff2Html.prototype.getJsonFromDiff = function(diffInput) {
|
Diff2Html.prototype.getJsonFromDiff = function(diffInput, config) {
|
||||||
return diffParser.generateDiffJson(diffInput);
|
var configOrEmpty = config || {};
|
||||||
|
return diffParser.generateDiffJson(diffInput, configOrEmpty);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -84,7 +85,7 @@
|
||||||
|
|
||||||
var diffJson = diffInput;
|
var diffJson = diffInput;
|
||||||
if (!configOrEmpty.inputFormat || configOrEmpty.inputFormat === 'diff') {
|
if (!configOrEmpty.inputFormat || configOrEmpty.inputFormat === 'diff') {
|
||||||
diffJson = diffParser.generateDiffJson(diffInput);
|
diffJson = diffParser.generateDiffJson(diffInput, configOrEmpty);
|
||||||
}
|
}
|
||||||
|
|
||||||
var fileList = '';
|
var fileList = '';
|
||||||
|
|
@ -186,7 +187,7 @@
|
||||||
|
|
||||||
DiffParser.prototype.LINE_TYPE = LINE_TYPE;
|
DiffParser.prototype.LINE_TYPE = LINE_TYPE;
|
||||||
|
|
||||||
DiffParser.prototype.generateDiffJson = function(diffInput) {
|
DiffParser.prototype.generateDiffJson = function(diffInput, config) {
|
||||||
var files = [];
|
var files = [];
|
||||||
var currentFile = null;
|
var currentFile = null;
|
||||||
var currentBlock = null;
|
var currentBlock = null;
|
||||||
|
|
@ -296,11 +297,11 @@
|
||||||
var deletedFileMode = /^deleted file mode (\d{6})/;
|
var deletedFileMode = /^deleted file mode (\d{6})/;
|
||||||
var newFileMode = /^new file mode (\d{6})/;
|
var newFileMode = /^new file mode (\d{6})/;
|
||||||
|
|
||||||
var copyFrom = /^copy from (.+)/;
|
var copyFrom = /^copy from "?(.+?)"?/;
|
||||||
var copyTo = /^copy to (.+)/;
|
var copyTo = /^copy to "?(.+?)"?/;
|
||||||
|
|
||||||
var renameFrom = /^rename from (.+)/;
|
var renameFrom = /^rename from "?(.+?)"?/;
|
||||||
var renameTo = /^rename to (.+)/;
|
var renameTo = /^rename to "?(.+?)"?/;
|
||||||
|
|
||||||
var similarityIndex = /^similarity index (\d+)%/;
|
var similarityIndex = /^similarity index (\d+)%/;
|
||||||
var dissimilarityIndex = /^dissimilarity index (\d+)%/;
|
var dissimilarityIndex = /^dissimilarity index (\d+)%/;
|
||||||
|
|
@ -323,10 +324,10 @@
|
||||||
var values = [];
|
var values = [];
|
||||||
if (utils.startsWith(line, 'diff')) {
|
if (utils.startsWith(line, 'diff')) {
|
||||||
startFile();
|
startFile();
|
||||||
} else if (currentFile && !currentFile.oldName && (values = /^--- [aiwco]\/(.+)$/.exec(line))) {
|
} else if (currentFile && !currentFile.oldName && (values = getSrcFilename(line, config))) {
|
||||||
currentFile.oldName = values[1];
|
currentFile.oldName = values[1];
|
||||||
currentFile.language = getExtension(currentFile.oldName, currentFile.language);
|
currentFile.language = getExtension(currentFile.oldName, currentFile.language);
|
||||||
} else if (currentFile && !currentFile.newName && (values = /^\+\+\+ [biwco]?\/(.+)$/.exec(line))) {
|
} else if (currentFile && !currentFile.newName && (values = getDstFilename(line, config))) {
|
||||||
currentFile.newName = values[1];
|
currentFile.newName = values[1];
|
||||||
currentFile.language = getExtension(currentFile.newName, currentFile.language);
|
currentFile.language = getExtension(currentFile.newName, currentFile.language);
|
||||||
} else if (currentFile && utils.startsWith(line, '@@')) {
|
} else if (currentFile && utils.startsWith(line, '@@')) {
|
||||||
|
|
@ -389,6 +390,27 @@
|
||||||
return language;
|
return language;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getSrcFilename(line, cfg) {
|
||||||
|
var prefixes = ["a\\/", "i\\/", "w\\/", "c\\/", "o\\/"];
|
||||||
|
|
||||||
|
if (cfg.srcPrefix) prefixes.push(cfg.srcPrefix);
|
||||||
|
|
||||||
|
return _getFilename('---', line, prefixes);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDstFilename(line, cfg) {
|
||||||
|
var prefixes = ["b\\/", "i\\/", "w\\/", "c\\/", "o\\/"];
|
||||||
|
|
||||||
|
if (cfg.dstPrefix) prefixes.push(cfg.dstPrefix);
|
||||||
|
|
||||||
|
return _getFilename('\\+\\+\\+', line, prefixes);
|
||||||
|
}
|
||||||
|
|
||||||
|
function _getFilename(linePrefix, line, prefixes) {
|
||||||
|
var prefixesStr = prefixes.join("|");
|
||||||
|
return new RegExp('^' + linePrefix + ' "?(?:' + prefixesStr + ')(.+?)"?$').exec(line);
|
||||||
|
}
|
||||||
|
|
||||||
module.exports.DiffParser = new DiffParser();
|
module.exports.DiffParser = new DiffParser();
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
7
dist/diff2html.min.js
vendored
7
dist/diff2html.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "diff2html",
|
"name": "diff2html",
|
||||||
"version": "2.0.0-beta1",
|
"version": "2.0.0-beta2",
|
||||||
"homepage": "http://rtfpessoa.github.io/diff2html/",
|
"homepage": "http://rtfpessoa.github.io/diff2html/",
|
||||||
"description": "Fast Diff to colorized HTML",
|
"description": "Fast Diff to colorized HTML",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue