securemark 0.280.5 → 0.280.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/index.js +11 -6
- package/package.json +1 -1
- package/src/parser/inline/extension/indexee.ts +12 -10
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.280.
|
|
1
|
+
/*! securemark v0.280.7 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
|
|
2
2
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
3
3
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
4
4
|
module.exports = factory(require("Prism"), require("DOMPurify"));
|
|
@@ -6244,16 +6244,21 @@ function indexee(parser, optional) {
|
|
|
6244
6244
|
exports.indexee = indexee;
|
|
6245
6245
|
function identity(id, text, type = 'index') {
|
|
6246
6246
|
if (id === '') return undefined;
|
|
6247
|
-
text &&= text.trim().replace(/\s+/g, '
|
|
6247
|
+
text &&= text.trim().replace(/\s\s+/g, ' ');
|
|
6248
6248
|
if (text === '') return undefined;
|
|
6249
|
-
|
|
6249
|
+
const hash = text.replace(/\s/g, '_');
|
|
6250
|
+
if (hash.length <= 120 || type === '') return `${type}:${id ?? ''}:${hash}`;
|
|
6250
6251
|
const cs = [...text];
|
|
6251
|
-
if (cs.length <= 120) return `${type}:${id ?? ''}:${
|
|
6252
|
+
if (cs.length <= 120) return `${type}:${id ?? ''}:${hash}`;
|
|
6253
|
+
const ellipsis = '...';
|
|
6254
|
+
const len = (120 - ellipsis.length * 2) / 3 | 0;
|
|
6252
6255
|
switch (type) {
|
|
6253
6256
|
case 'index':
|
|
6254
|
-
return `${type}:${id ?? ''}:${cs.slice(0, 120 - 3).join('')}...`;
|
|
6255
6257
|
case 'mark':
|
|
6256
|
-
|
|
6258
|
+
const s1 = hash.slice(0, cs.slice(0, len).join('').trimEnd().length);
|
|
6259
|
+
const s3 = hash.slice(-cs.slice(-len).join('').trimStart().length);
|
|
6260
|
+
const s2 = cs.slice(cs.length / 2 - len / 2 - (len - s1.length) | 0).slice(0, len + len - s3.length).join('').trim().replace(/\s/g, '_');
|
|
6261
|
+
return `${type}:${id ?? ''}:${s1}${ellipsis}${s2}${ellipsis}${s3}`;
|
|
6257
6262
|
}
|
|
6258
6263
|
}
|
|
6259
6264
|
exports.identity = identity;
|
package/package.json
CHANGED
|
@@ -13,25 +13,27 @@ export function identity(id: string | undefined, text: string, type: 'index' | '
|
|
|
13
13
|
assert(!id?.match(/[^0-9a-z/-]/i));
|
|
14
14
|
assert(!text.includes('\n'));
|
|
15
15
|
if (id === '') return undefined;
|
|
16
|
-
text &&= text.trim().replace(/\s+/g, '
|
|
16
|
+
text &&= text.trim().replace(/\s\s+/g, ' ');
|
|
17
17
|
if (text === '') return undefined;
|
|
18
|
-
|
|
18
|
+
const hash = text.replace(/\s/g, '_');
|
|
19
|
+
if (hash.length <= 120 || type === '') return `${type}:${id ?? ''}:${hash}`;
|
|
19
20
|
const cs = [...text];
|
|
20
|
-
if (cs.length <= 120) return `${type}:${id ?? ''}:${
|
|
21
|
+
if (cs.length <= 120) return `${type}:${id ?? ''}:${hash}`;
|
|
22
|
+
const ellipsis = '...';
|
|
23
|
+
const len = (120 - ellipsis.length * 2) / 3 | 0;
|
|
21
24
|
switch (type) {
|
|
22
25
|
case 'index':
|
|
23
|
-
return `${type}:${id ?? ''}:${cs.slice(0, 120 - 3).join('')}...`;
|
|
24
26
|
case 'mark':
|
|
25
|
-
|
|
27
|
+
const s1 = hash.slice(0, cs.slice(0, len).join('').trimEnd().length);
|
|
28
|
+
const s3 = hash.slice(-cs.slice(-len).join('').trimStart().length);
|
|
29
|
+
const s2 = cs.slice(cs.length / 2 - len / 2 - (len - s1.length) | 0).slice(0, len + len - s3.length).join('').trim().replace(/\s/g, '_');
|
|
30
|
+
return `${type}:${id ?? ''}:${s1}${ellipsis}${s2}${ellipsis}${s3}`;
|
|
26
31
|
}
|
|
27
32
|
assert(false);
|
|
28
33
|
}
|
|
29
34
|
assert(identity(undefined, '0'.repeat(120 - 1) + 1)!.slice(7) === '0'.repeat(120 - 1) + 1);
|
|
30
|
-
assert(identity(undefined, '0'.repeat(
|
|
31
|
-
assert(identity(undefined, '0'.repeat(
|
|
32
|
-
assert(identity(undefined, '0'.repeat(120 - 1) + 1, 'mark')!.slice(6) === '0'.repeat(120 - 1) + 1);
|
|
33
|
-
assert(identity(undefined, '0'.repeat(41) + '1'.repeat(38) + '2'.repeat(41) + 3, 'mark')!.slice(6) === '0'.repeat(38) + '...' + '1'.repeat(38) + '...' + '2'.repeat(38 - 1) + 3);
|
|
34
|
-
assert(identity(undefined, '0'.repeat(81) + '1'.repeat(38) + '2'.repeat(81) + 3, 'mark')!.slice(6) === '0'.repeat(38) + '...' + '1'.repeat(38) + '...' + '2'.repeat(38 - 1) + 3);
|
|
35
|
+
assert(identity(undefined, '0'.repeat(41) + '1'.repeat(38) + '2'.repeat(41) + 3)!.slice(7) === '0'.repeat(38) + '...' + '1'.repeat(38) + '...' + '2'.repeat(38 - 1) + 3);
|
|
36
|
+
assert(identity(undefined, '0'.repeat(81) + '1'.repeat(38) + '2'.repeat(81) + 3)!.slice(7) === '0'.repeat(38) + '...' + '1'.repeat(38) + '...' + '2'.repeat(38 - 1) + 3);
|
|
35
37
|
|
|
36
38
|
export function index(source: Element, optional = false): string {
|
|
37
39
|
assert(!source.matches('.indexer'));
|