diff2html
Advanced tools
Comparing version 3.4.7 to 3.4.8-bumpdependencies.1.6572b68
@@ -1,4 +0,4 @@ | ||
import * as HighlightJS from 'highlight.js/lib/core'; | ||
import { Diff2HtmlConfig } from '../../diff2html'; | ||
import { DiffFile } from '../../types'; | ||
import { HLJSApi } from 'highlight.js'; | ||
export interface Diff2HtmlUIConfig extends Diff2HtmlConfig { | ||
@@ -33,5 +33,5 @@ synchronisedScroll?: boolean; | ||
readonly targetElement: HTMLElement; | ||
readonly hljs: typeof HighlightJS | null; | ||
readonly hljs: HLJSApi | null; | ||
currentSelectionColumnId: number; | ||
constructor(target: HTMLElement, diffInput?: string | DiffFile[], config?: Diff2HtmlUIConfig, hljs?: typeof HighlightJS); | ||
constructor(target: HTMLElement, diffInput?: string | DiffFile[], config?: Diff2HtmlUIConfig, hljs?: HLJSApi); | ||
draw(): void; | ||
@@ -43,3 +43,2 @@ synchronisedScroll(): void; | ||
smartSelection(): void; | ||
private instanceOfHighlightResult; | ||
private getHashTag; | ||
@@ -46,0 +45,0 @@ private isElement; |
@@ -12,3 +12,3 @@ var __assign = (this && this.__assign) || function () { | ||
}; | ||
import { nodeStream, mergeStreams } from './highlight.js-helpers'; | ||
import { closeTags, nodeStream, mergeStreams } from './highlight.js-helpers'; | ||
import { html, defaultDiff2HtmlConfig } from '../../diff2html'; | ||
@@ -115,4 +115,6 @@ export var defaultDiff2HtmlUIConfig = __assign(__assign({}, defaultDiff2HtmlConfig), { synchronisedScroll: true, highlight: true, fileListToggle: true, fileListStartVisible: false, smartSelection: true, fileContentToggle: true }); | ||
files.forEach(function (file) { | ||
var oldLinesState; | ||
var newLinesState; | ||
if (_this.hljs === null) | ||
return; | ||
var language = file.getAttribute('data-lang'); | ||
var hljsLanguage = language ? _this.hljs.getLanguage(language) : undefined; | ||
var codeLines = file.querySelectorAll('.d2h-code-line-ctn'); | ||
@@ -126,19 +128,6 @@ codeLines.forEach(function (line) { | ||
return; | ||
var lineState = lineParent.classList.contains('d2h-del') ? oldLinesState : newLinesState; | ||
var language = file.getAttribute('data-lang'); | ||
var result = language && _this.hljs.getLanguage(language) | ||
? _this.hljs.highlight(language, text, true, lineState) | ||
: _this.hljs.highlightAuto(text); | ||
if (_this.instanceOfHighlightResult(result)) { | ||
if (lineParent.classList.contains('d2h-del')) { | ||
oldLinesState = result.top; | ||
} | ||
else if (lineParent.classList.contains('d2h-ins')) { | ||
newLinesState = result.top; | ||
} | ||
else { | ||
oldLinesState = result.top; | ||
newLinesState = result.top; | ||
} | ||
} | ||
var result = closeTags(_this.hljs.highlight(text, { | ||
language: (hljsLanguage === null || hljsLanguage === void 0 ? void 0 : hljsLanguage.name) || 'plaintext', | ||
ignoreIllegals: true, | ||
})); | ||
var originalStream = nodeStream(line); | ||
@@ -161,5 +150,2 @@ if (originalStream.length) { | ||
}; | ||
Diff2HtmlUI.prototype.instanceOfHighlightResult = function (object) { | ||
return 'top' in object; | ||
}; | ||
Diff2HtmlUI.prototype.getHashTag = function () { | ||
@@ -166,0 +152,0 @@ var docUrl = document.URL; |
@@ -0,1 +1,2 @@ | ||
import { HighlightResult } from 'highlight.js'; | ||
declare type NodeEvent = { | ||
@@ -8,3 +9,4 @@ event: 'start' | 'stop'; | ||
export declare function mergeStreams(original: NodeEvent[], highlighted: NodeEvent[], value: string): string; | ||
export declare function closeTags(res: HighlightResult): HighlightResult; | ||
export {}; | ||
//# sourceMappingURL=highlight.js-helpers.d.ts.map |
@@ -90,2 +90,21 @@ function escapeHTML(value) { | ||
} | ||
export function closeTags(res) { | ||
var tokenStack = new Array(); | ||
res.value = res.value | ||
.split('\n') | ||
.map(function (line) { | ||
var prepend = tokenStack.map(function (token) { return "<span class=\"" + token + "\">"; }).join(''); | ||
var matches = line.matchAll(/(<span class="(.*?)">|<\/span>)/g); | ||
Array.from(matches).forEach(function (match) { | ||
if (match[0] === '</span>') | ||
tokenStack.shift(); | ||
else | ||
tokenStack.unshift(match[2]); | ||
}); | ||
var append = '</span>'.repeat(tokenStack.length); | ||
return prepend + line + append; | ||
}) | ||
.join('\n'); | ||
return res; | ||
} | ||
//# sourceMappingURL=highlight.js-helpers.js.map |
@@ -1,2 +0,3 @@ | ||
export declare const hljs: HLJSApi; | ||
/// <reference types="highlight.js" /> | ||
export declare const hljs: import("highlight.js").HLJSApi; | ||
//# sourceMappingURL=highlight.js-slim.d.ts.map |
import highlightJS from 'highlight.js/lib/core'; | ||
import cLike from 'highlight.js/lib/languages/c-like'; | ||
import cpp from 'highlight.js/lib/languages/cpp'; | ||
@@ -54,3 +53,2 @@ import xml from 'highlight.js/lib/languages/xml'; | ||
import typescript from 'highlight.js/lib/languages/typescript'; | ||
highlightJS.registerLanguage('c-like', cLike); | ||
highlightJS.registerLanguage('cpp', cpp); | ||
@@ -57,0 +55,0 @@ highlightJS.registerLanguage('xml', xml); |
@@ -1,4 +0,4 @@ | ||
import * as HighlightJS from 'highlight.js/lib/core'; | ||
import { Diff2HtmlConfig } from '../../diff2html'; | ||
import { DiffFile } from '../../types'; | ||
import { HLJSApi } from 'highlight.js'; | ||
export interface Diff2HtmlUIConfig extends Diff2HtmlConfig { | ||
@@ -33,5 +33,5 @@ synchronisedScroll?: boolean; | ||
readonly targetElement: HTMLElement; | ||
readonly hljs: typeof HighlightJS | null; | ||
readonly hljs: HLJSApi | null; | ||
currentSelectionColumnId: number; | ||
constructor(target: HTMLElement, diffInput?: string | DiffFile[], config?: Diff2HtmlUIConfig, hljs?: typeof HighlightJS); | ||
constructor(target: HTMLElement, diffInput?: string | DiffFile[], config?: Diff2HtmlUIConfig, hljs?: HLJSApi); | ||
draw(): void; | ||
@@ -43,3 +43,2 @@ synchronisedScroll(): void; | ||
smartSelection(): void; | ||
private instanceOfHighlightResult; | ||
private getHashTag; | ||
@@ -46,0 +45,0 @@ private isElement; |
@@ -117,4 +117,6 @@ "use strict"; | ||
files.forEach(function (file) { | ||
var oldLinesState; | ||
var newLinesState; | ||
if (_this.hljs === null) | ||
return; | ||
var language = file.getAttribute('data-lang'); | ||
var hljsLanguage = language ? _this.hljs.getLanguage(language) : undefined; | ||
var codeLines = file.querySelectorAll('.d2h-code-line-ctn'); | ||
@@ -128,19 +130,6 @@ codeLines.forEach(function (line) { | ||
return; | ||
var lineState = lineParent.classList.contains('d2h-del') ? oldLinesState : newLinesState; | ||
var language = file.getAttribute('data-lang'); | ||
var result = language && _this.hljs.getLanguage(language) | ||
? _this.hljs.highlight(language, text, true, lineState) | ||
: _this.hljs.highlightAuto(text); | ||
if (_this.instanceOfHighlightResult(result)) { | ||
if (lineParent.classList.contains('d2h-del')) { | ||
oldLinesState = result.top; | ||
} | ||
else if (lineParent.classList.contains('d2h-ins')) { | ||
newLinesState = result.top; | ||
} | ||
else { | ||
oldLinesState = result.top; | ||
newLinesState = result.top; | ||
} | ||
} | ||
var result = highlight_js_helpers_1.closeTags(_this.hljs.highlight(text, { | ||
language: (hljsLanguage === null || hljsLanguage === void 0 ? void 0 : hljsLanguage.name) || 'plaintext', | ||
ignoreIllegals: true, | ||
})); | ||
var originalStream = highlight_js_helpers_1.nodeStream(line); | ||
@@ -163,5 +152,2 @@ if (originalStream.length) { | ||
}; | ||
Diff2HtmlUI.prototype.instanceOfHighlightResult = function (object) { | ||
return 'top' in object; | ||
}; | ||
Diff2HtmlUI.prototype.getHashTag = function () { | ||
@@ -168,0 +154,0 @@ var docUrl = document.URL; |
@@ -0,1 +1,2 @@ | ||
import { HighlightResult } from 'highlight.js'; | ||
declare type NodeEvent = { | ||
@@ -8,3 +9,4 @@ event: 'start' | 'stop'; | ||
export declare function mergeStreams(original: NodeEvent[], highlighted: NodeEvent[], value: string): string; | ||
export declare function closeTags(res: HighlightResult): HighlightResult; | ||
export {}; | ||
//# sourceMappingURL=highlight.js-helpers.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.mergeStreams = exports.nodeStream = void 0; | ||
exports.closeTags = exports.mergeStreams = exports.nodeStream = void 0; | ||
function escapeHTML(value) { | ||
@@ -95,2 +95,22 @@ return value.replace(/&/gm, '&').replace(/</gm, '<').replace(/>/gm, '>'); | ||
exports.mergeStreams = mergeStreams; | ||
function closeTags(res) { | ||
var tokenStack = new Array(); | ||
res.value = res.value | ||
.split('\n') | ||
.map(function (line) { | ||
var prepend = tokenStack.map(function (token) { return "<span class=\"" + token + "\">"; }).join(''); | ||
var matches = line.matchAll(/(<span class="(.*?)">|<\/span>)/g); | ||
Array.from(matches).forEach(function (match) { | ||
if (match[0] === '</span>') | ||
tokenStack.shift(); | ||
else | ||
tokenStack.unshift(match[2]); | ||
}); | ||
var append = '</span>'.repeat(tokenStack.length); | ||
return prepend + line + append; | ||
}) | ||
.join('\n'); | ||
return res; | ||
} | ||
exports.closeTags = closeTags; | ||
//# sourceMappingURL=highlight.js-helpers.js.map |
@@ -1,2 +0,3 @@ | ||
export declare const hljs: HLJSApi; | ||
/// <reference types="highlight.js" /> | ||
export declare const hljs: import("highlight.js").HLJSApi; | ||
//# sourceMappingURL=highlight.js-slim.d.ts.map |
@@ -8,3 +8,2 @@ "use strict"; | ||
var core_1 = __importDefault(require("highlight.js/lib/core")); | ||
var c_like_1 = __importDefault(require("highlight.js/lib/languages/c-like")); | ||
var cpp_1 = __importDefault(require("highlight.js/lib/languages/cpp")); | ||
@@ -61,3 +60,2 @@ var xml_1 = __importDefault(require("highlight.js/lib/languages/xml")); | ||
var typescript_1 = __importDefault(require("highlight.js/lib/languages/typescript")); | ||
core_1.default.registerLanguage('c-like', c_like_1.default); | ||
core_1.default.registerLanguage('cpp', cpp_1.default); | ||
@@ -64,0 +62,0 @@ core_1.default.registerLanguage('xml', xml_1.default); |
{ | ||
"name": "diff2html", | ||
"version": "3.4.7", | ||
"version": "3.4.8-bumpdependencies.1.6572b68", | ||
"homepage": "https://diff2html.xyz", | ||
@@ -88,57 +88,56 @@ "description": "Fast Diff to colorized HTML", | ||
"optionalDependencies": { | ||
"highlight.js": "10.7.2" | ||
"highlight.js": "11.1.0" | ||
}, | ||
"devDependencies": { | ||
"@types/clipboard": "2.0.1", | ||
"@types/copy-webpack-plugin": "6.4.1", | ||
"@types/diff": "5.0.0", | ||
"@types/hogan.js": "3.0.0", | ||
"@types/jest": "26.0.22", | ||
"@types/mini-css-extract-plugin": "^1.2.2", | ||
"@types/mkdirp": "1.0.1", | ||
"@types/node": "14.14.37", | ||
"@types/copy-webpack-plugin": "8.0.1", | ||
"@types/diff": "5.0.1", | ||
"@types/hogan.js": "3.0.1", | ||
"@types/jest": "26.0.24", | ||
"@types/mini-css-extract-plugin": "^2.0.1", | ||
"@types/mkdirp": "1.0.2", | ||
"@types/node": "16.4.1", | ||
"@types/nopt": "3.0.29", | ||
"@typescript-eslint/eslint-plugin": "4.21.0", | ||
"@typescript-eslint/parser": "4.21.0", | ||
"autoprefixer": "10.2.5", | ||
"@typescript-eslint/eslint-plugin": "4.28.4", | ||
"@typescript-eslint/parser": "4.28.4", | ||
"autoprefixer": "10.3.1", | ||
"bulma": "^0.9.2", | ||
"clipboard": "2.0.8", | ||
"copy-webpack-plugin": "8.1.1", | ||
"css-loader": "5.2.0", | ||
"cssnano": "4.1.11", | ||
"eslint": "7.23.0", | ||
"eslint-config-prettier": "8.1.0", | ||
"eslint-plugin-import": "2.22.1", | ||
"eslint-plugin-jest": "24.3.4", | ||
"eslint-plugin-json": "2.1.2", | ||
"copy-webpack-plugin": "9.0.1", | ||
"css-loader": "6.2.0", | ||
"cssnano": "5.0.7", | ||
"eslint": "7.31.0", | ||
"eslint-config-prettier": "8.3.0", | ||
"eslint-plugin-import": "2.23.4", | ||
"eslint-plugin-jest": "24.4.0", | ||
"eslint-plugin-json": "3.0.0", | ||
"eslint-plugin-node": "11.1.0", | ||
"eslint-plugin-optimize-regex": "1.2.0", | ||
"eslint-plugin-promise": "4.3.1", | ||
"eslint-plugin-sonarjs": "0.6.0", | ||
"eslint-plugin-promise": "5.1.0", | ||
"eslint-plugin-sonarjs": "0.9.1", | ||
"file-loader": "6.2.0", | ||
"handlebars": "4.7.7", | ||
"handlebars-loader": "1.7.1", | ||
"html-webpack-plugin": "5.3.1", | ||
"husky": "^6.0.0", | ||
"html-webpack-plugin": "5.3.2", | ||
"husky": "^7.0.1", | ||
"image-webpack-loader": "7.0.1", | ||
"is-ci-cli": "2.2.0", | ||
"jest": "26.6.3", | ||
"lint-staged": "10.5.4", | ||
"jest": "27.0.6", | ||
"lint-staged": "11.1.0", | ||
"markdown-toc": "^1.2.0", | ||
"mini-css-extract-plugin": "1.4.1", | ||
"mini-css-extract-plugin": "2.1.0", | ||
"mkdirp": "1.0.4", | ||
"nopt": "5.0.0", | ||
"postcss": "8.2.10", | ||
"postcss": "8.3.6", | ||
"postcss-cli": "8.3.1", | ||
"postcss-import": "14.0.1", | ||
"postcss-loader": "5.2.0", | ||
"postcss-import": "14.0.2", | ||
"postcss-loader": "6.1.1", | ||
"postcss-preset-env": "6.7.0", | ||
"prettier": "2.2.1", | ||
"ts-jest": "26.5.4", | ||
"ts-loader": "8.1.0", | ||
"ts-node": "9.1.1", | ||
"typescript": "4.2.4", | ||
"prettier": "2.3.2", | ||
"ts-jest": "27.0.4", | ||
"ts-loader": "9.2.3", | ||
"ts-node": "10.1.0", | ||
"typescript": "4.3.5", | ||
"url-loader": "4.1.1", | ||
"webpack": "5.31.0", | ||
"webpack-cli": "4.6.0", | ||
"webpack": "5.46.0", | ||
"webpack-cli": "4.7.2", | ||
"whatwg-fetch": "3.6.2" | ||
@@ -153,4 +152,3 @@ }, | ||
"decompress": ">=4.2.1", | ||
"node-forge": ">=0.10.0", | ||
"@types/webpack": ">=5.28.0" | ||
"node-forge": ">=0.10.0" | ||
}, | ||
@@ -157,0 +155,0 @@ "license": "MIT", |
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 too big to display
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 not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1800741
52
4290
1