Skip to content

Commit ae91dce

Browse files
committed
bump: Update highlight.js
1 parent c37321b commit ae91dce

File tree

8 files changed

+84
-80
lines changed

8 files changed

+84
-80
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"hogan.js": "3.0.2"
9090
},
9191
"optionalDependencies": {
92-
"highlight.js": "9.18.1"
92+
"highlight.js": "10.0.2"
9393
},
9494
"devDependencies": {
9595
"@types/clipboard": "2.0.1",

src/render-utils.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,7 @@ export function filenameDiff(file: DiffFileName): string {
186186
* Generates a unique string numerical identifier based on the names of the file diff
187187
*/
188188
export function getHtmlId(file: DiffFileName): string {
189-
return `d2h-${hashCode(filenameDiff(file))
190-
.toString()
191-
.slice(-6)}`;
189+
return `d2h-${hashCode(filenameDiff(file)).toString().slice(-6)}`;
192190
}
193191

194192
/**

src/ui/js/diff2html-ui-base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as HighlightJS from 'highlight.js/lib/highlight.js';
1+
import * as HighlightJS from 'highlight.js/lib/core';
22
import { ICompiledMode, IHighlightResult, IAutoHighlightResult } from 'highlight.js';
33
import { nodeStream, mergeStreams } from './highlight.js-helpers';
44

src/ui/js/highlight.js-helpers.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@
55

66
/* Utility functions */
77

8-
function escape(value: string): string {
9-
return value
10-
.replace(/&/gm, '&')
11-
.replace(/</gm, '&lt;')
12-
.replace(/>/gm, '&gt;');
8+
function escapeHTML(value: string): string {
9+
return value.replace(/&/gm, '&amp;').replace(/</gm, '&lt;').replace(/>/gm, '&gt;');
1310
}
1411

1512
function tag(node: Node): string {
@@ -97,7 +94,7 @@ export function mergeStreams(original: NodeEvent[], highlighted: NodeEvent[], va
9794
}
9895

9996
result += `<${tag(node)} ${Array<Attr>()
100-
.map.call(node.attributes, attr => `${attr.nodeName}="${escape(attr.value)}"`)
97+
.map.call(node.attributes, attr => `${attr.nodeName}="${escapeHTML(attr.value).replace(/"/g, '&quot;')}"`)
10198
.join(' ')}>`;
10299
}
103100

@@ -111,7 +108,7 @@ export function mergeStreams(original: NodeEvent[], highlighted: NodeEvent[], va
111108

112109
while (original.length || highlighted.length) {
113110
let stream = selectStream();
114-
result += escape(value.substring(processed, stream[0].offset));
111+
result += escapeHTML(value.substring(processed, stream[0].offset));
115112
processed = stream[0].offset;
116113
if (stream === original) {
117114
/*
@@ -135,5 +132,6 @@ export function mergeStreams(original: NodeEvent[], highlighted: NodeEvent[], va
135132
render(stream.splice(0, 1)[0]);
136133
}
137134
}
138-
return result + escape(value.substr(processed));
135+
136+
return result + escapeHTML(value.substr(processed));
139137
}

src/ui/js/highlight.js-slim.ts

Lines changed: 69 additions & 61 deletions
Large diffs are not rendered by default.

typings/highlight.js/highlight.js.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
declare module 'highlight.js/lib/highlight.js' {
1+
declare module 'highlight.js/lib/core' {
22
import hljs from 'highlight.js';
33

44
export = hljs;

typings/highlight.js/languages.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
declare module 'highlight.js/lib/languages/*' {
22
import { HLJSStatic, IModeBase } from 'highlight.js';
33

4-
export default function(hljs?: HLJSStatic): IModeBase;
4+
export default function (hljs?: HLJSStatic): IModeBase;
55
}

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4573,10 +4573,10 @@ hex-color-regex@^1.1.0:
45734573
resolved "https://registry.yarnpkg.com/hex-color-regex/-/hex-color-regex-1.1.0.tgz#4c06fccb4602fe2602b3c93df82d7e7dbf1a8a8e"
45744574
integrity sha512-l9sfDFsuqtOqKDsQdqrMRk0U85RZc0RtOR9yPI7mRVOa4FsR/BVnZ0shmQRM96Ji99kYZP/7hn1cedc1+ApsTQ==
45754575

4576-
highlight.js@9.18.1:
4577-
version "9.18.1"
4578-
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.18.1.tgz#ed21aa001fe6252bb10a3d76d47573c6539fe13c"
4579-
integrity sha512-OrVKYz70LHsnCgmbXctv/bfuvntIKDz177h0Co37DQ5jamGZLVmoCVMtjMtNZY3X9DrCcKfklHPNeA0uPZhSJg==
4576+
highlight.js@10.0.2:
4577+
version "10.0.2"
4578+
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-10.0.2.tgz#d2c732544f8f68bceaf0cefb4b0575bce8eddbee"
4579+
integrity sha512-2gMT2MHU6/2OjAlnaOE2LFdr9dwviDN3Q2lSw7Ois3/5uTtahbgYTkr4EPoY828ps+2eQWiixPTF8+phU6Ofkg==
45804580

45814581
hmac-drbg@^1.0.0:
45824582
version "1.0.1"

0 commit comments

Comments
 (0)