securemark 0.258.1 → 0.258.2
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 +4 -0
- package/dist/index.js +41 -37
- package/package.json +1 -1
- package/src/combinator/control/manipulation/convert.ts +7 -7
- package/src/combinator/control/manipulation/scope.ts +4 -4
- package/src/combinator/data/parser/context/memo.ts +7 -5
- package/src/combinator/data/parser/context.ts +15 -15
- package/src/parser/inline/bracket.ts +12 -12
- package/src/parser/inline/link.ts +6 -2
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.258.
|
|
1
|
+
/*! securemark v0.258.2 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("DOMPurify"), require("Prism"));
|
|
@@ -2250,17 +2250,17 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
2250
2250
|
}));
|
|
2251
2251
|
exports.convert = void 0;
|
|
2252
2252
|
|
|
2253
|
-
const
|
|
2253
|
+
const parser_1 = __webpack_require__(6728);
|
|
2254
2254
|
|
|
2255
2255
|
function convert(conv, parser) {
|
|
2256
2256
|
return (source, context = {}) => {
|
|
2257
2257
|
if (source === '') return;
|
|
2258
|
-
|
|
2259
|
-
if (
|
|
2258
|
+
const src = conv(source);
|
|
2259
|
+
if (src === '') return [[], ''];
|
|
2260
2260
|
const memo = context.memo;
|
|
2261
|
-
|
|
2262
|
-
const result = parser(
|
|
2263
|
-
|
|
2261
|
+
memo && (memo.offset += source.length - src.length);
|
|
2262
|
+
const result = parser(src, context);
|
|
2263
|
+
memo && (memo.offset -= source.length - src.length);
|
|
2264
2264
|
return result;
|
|
2265
2265
|
};
|
|
2266
2266
|
}
|
|
@@ -2543,9 +2543,9 @@ function focus(scope, parser) {
|
|
|
2543
2543
|
const src = match(source);
|
|
2544
2544
|
if (src === '') return;
|
|
2545
2545
|
const memo = context.memo;
|
|
2546
|
-
memo && (memo.offset
|
|
2546
|
+
memo && (memo.offset += source.length - src.length);
|
|
2547
2547
|
const result = parser(src, context);
|
|
2548
|
-
memo && (memo.offset
|
|
2548
|
+
memo && (memo.offset -= source.length - src.length);
|
|
2549
2549
|
if (!result) return;
|
|
2550
2550
|
return (0, parser_1.exec)(result).length < src.length ? [(0, parser_1.eval)(result), (0, parser_1.exec)(result) + source.slice(src.length)] : global_1.undefined;
|
|
2551
2551
|
};
|
|
@@ -2562,9 +2562,9 @@ function rewrite(scope, parser) {
|
|
|
2562
2562
|
context.memo = memo;
|
|
2563
2563
|
if (!res1 || (0, parser_1.exec)(res1).length >= source.length) return;
|
|
2564
2564
|
const src = source.slice(0, source.length - (0, parser_1.exec)(res1).length);
|
|
2565
|
-
memo && (memo.offset
|
|
2565
|
+
memo && (memo.offset += source.length - src.length);
|
|
2566
2566
|
const res2 = parser(src, context);
|
|
2567
|
-
memo && (memo.offset
|
|
2567
|
+
memo && (memo.offset -= source.length - src.length);
|
|
2568
2568
|
if (!res2) return;
|
|
2569
2569
|
return (0, parser_1.exec)(res2).length < src.length ? [(0, parser_1.eval)(res2), (0, parser_1.exec)(res2) + (0, parser_1.exec)(res1)] : global_1.undefined;
|
|
2570
2570
|
};
|
|
@@ -2866,21 +2866,19 @@ function syntax(syntax, precedence, cost, parser) {
|
|
|
2866
2866
|
--resources.recursion;
|
|
2867
2867
|
const pos = source.length;
|
|
2868
2868
|
const cache = syntax && context.memo?.get(pos, syntax, state);
|
|
2869
|
-
const result = cache ? [cache[0], source.slice(cache[1])] : parser(source, context);
|
|
2869
|
+
const result = cache ? cache.length === 0 ? global_1.undefined : [cache[0], source.slice(cache[1])] : parser(source, context);
|
|
2870
2870
|
++resources.recursion;
|
|
2871
2871
|
|
|
2872
|
-
if (result) {
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
}
|
|
2872
|
+
if (result && !cache) {
|
|
2873
|
+
resources.budget -= cost;
|
|
2874
|
+
}
|
|
2876
2875
|
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
}
|
|
2876
|
+
if (syntax) {
|
|
2877
|
+
if (state & context.backtrackable) {
|
|
2878
|
+
context.memo ??= new memo_1.Memo();
|
|
2879
|
+
cache ?? context.memo.set(pos, syntax, state, (0, parser_1.eval)(result), source.length - (0, parser_1.exec)(result, '').length);
|
|
2880
|
+
} else if (result && context.memo?.length >= pos) {
|
|
2881
|
+
context.memo.clear(pos);
|
|
2884
2882
|
}
|
|
2885
2883
|
}
|
|
2886
2884
|
|
|
@@ -3080,7 +3078,7 @@ class Memo {
|
|
|
3080
3078
|
|
|
3081
3079
|
set(position, syntax, state, nodes, offset) {
|
|
3082
3080
|
const record = this.memory[position + this.offset - 1] ??= {};
|
|
3083
|
-
record[`${syntax}:${state}`] = [nodes.slice(), offset]; //console.log('set', position + this.offset, syntax, state);
|
|
3081
|
+
record[`${syntax}:${state}`] = nodes ? [nodes.slice(), offset] : []; //console.log('set', position + this.offset, syntax, state);
|
|
3084
3082
|
}
|
|
3085
3083
|
|
|
3086
3084
|
clear(position) {
|
|
@@ -3088,7 +3086,7 @@ class Memo {
|
|
|
3088
3086
|
|
|
3089
3087
|
for (let i = position + this.offset, len = memory.length; i < len; ++i) {
|
|
3090
3088
|
memory.pop();
|
|
3091
|
-
} //console.log(position);
|
|
3089
|
+
} //console.log('clear', position);
|
|
3092
3090
|
|
|
3093
3091
|
}
|
|
3094
3092
|
|
|
@@ -5947,26 +5945,26 @@ const dom_1 = __webpack_require__(3252);
|
|
|
5947
5945
|
const array_1 = __webpack_require__(8112);
|
|
5948
5946
|
|
|
5949
5947
|
const index = /^[0-9A-Za-z]+(?:(?:[.-]|, )[0-9A-Za-z]+)*/;
|
|
5950
|
-
exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.syntax)(0
|
|
5948
|
+
exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.syntax)(0
|
|
5951
5949
|
/* Rule.none */
|
|
5952
|
-
, 2, (0,
|
|
5950
|
+
, 2, (0, source_1.str)(index)), (0, source_1.str)(')')), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.syntax)(128
|
|
5953
5951
|
/* Rule.bracket */
|
|
5954
|
-
, 2, (0, combinator_1.
|
|
5952
|
+
, 2, (0, combinator_1.some)(inline_1.inline, ')', [[')', 2]])), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest) => [[(0, dom_1.html)('span', {
|
|
5955
5953
|
class: 'paren'
|
|
5956
|
-
}, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))], rest], ([as, bs = []], rest) => [(0, array_1.unshift)([''], (0, array_1.unshift)(as, bs)), rest])), (0, combinator_1.syntax)(0
|
|
5954
|
+
}, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))], rest], ([as, bs = []], rest) => [(0, array_1.unshift)([''], (0, array_1.unshift)(as, bs)), rest]), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.syntax)(0
|
|
5957
5955
|
/* Rule.none */
|
|
5958
|
-
, 2, (0,
|
|
5956
|
+
, 2, (0, source_1.str)(new RegExp(index.source.replace(', ', '[,、]').replace(/[09AZaz.]|\-(?!\w)/g, c => c.trimStart() && String.fromCharCode(c.charCodeAt(0) + 0xFEE0))))), (0, source_1.str)(')')), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.syntax)(128
|
|
5959
5957
|
/* Rule.bracket */
|
|
5960
|
-
, 2, (0, combinator_1.
|
|
5958
|
+
, 2, (0, combinator_1.some)(inline_1.inline, ')', [[')', 2]])), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest) => [[(0, dom_1.html)('span', {
|
|
5961
5959
|
class: 'paren'
|
|
5962
|
-
}, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))], rest], ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest])), (0, combinator_1.syntax)(128
|
|
5960
|
+
}, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))], rest], ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.syntax)(128
|
|
5963
5961
|
/* Rule.bracket */
|
|
5964
|
-
, 2, (0, combinator_1.
|
|
5962
|
+
, 2, (0, combinator_1.some)(inline_1.inline, ']', [[']', 2]])), (0, source_1.str)(']'), true, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)([''], (0, array_1.unshift)(as, bs)), rest]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.syntax)(128
|
|
5965
5963
|
/* Rule.bracket */
|
|
5966
|
-
, 2, (0, combinator_1.
|
|
5967
|
-
(0, combinator_1.syntax)(1
|
|
5964
|
+
, 2, (0, combinator_1.some)(inline_1.inline, '}', [['}', 2]])), (0, source_1.str)('}'), true, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), // Control media blinking in editing rather than control confusion of pairs of quote marks.
|
|
5965
|
+
(0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.syntax)(1
|
|
5968
5966
|
/* Rule.quote */
|
|
5969
|
-
, 8, (0, combinator_1.
|
|
5967
|
+
, 8, (0, combinator_1.some)(inline_1.inline, '"', [['"', 8]])), (0, source_1.str)('"'), true, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest])]));
|
|
5970
5968
|
|
|
5971
5969
|
/***/ }),
|
|
5972
5970
|
|
|
@@ -6671,7 +6669,13 @@ exports.link = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['[', '{'
|
|
|
6671
6669
|
if (content[0] === '') return [content, rest];
|
|
6672
6670
|
if (params.length === 0) return;
|
|
6673
6671
|
if (content.length !== 0 && (0, visibility_1.trimNode)(content).length === 0) return;
|
|
6674
|
-
|
|
6672
|
+
|
|
6673
|
+
for (let source = (0, util_1.stringify)(content); source;) {
|
|
6674
|
+
const result = (0, autolink_1.autolink)(source, context);
|
|
6675
|
+
if (typeof (0, parser_1.eval)(result)[0] === 'object') return;
|
|
6676
|
+
source = (0, parser_1.exec)(result);
|
|
6677
|
+
}
|
|
6678
|
+
|
|
6675
6679
|
const INSECURE_URI = params.shift();
|
|
6676
6680
|
const el = elem(INSECURE_URI, (0, dom_1.defrag)(content), new url_1.ReadonlyURL(resolve(INSECURE_URI, context.host ?? global_1.location, context.url ?? context.host ?? global_1.location), context.host?.href || global_1.location.href), context.host?.origin || global_1.location.origin);
|
|
6677
6681
|
if (el.classList.contains('invalid')) return [[el], rest];
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Parser } from '../../data/parser';
|
|
1
|
+
import { Parser, check } from '../../data/parser';
|
|
3
2
|
|
|
4
3
|
export function convert<P extends Parser<unknown>>(conv: (source: string) => string, parser: P): P;
|
|
5
4
|
export function convert<T>(conv: (source: string) => string, parser: Parser<T>): Parser<T> {
|
|
6
5
|
assert(parser);
|
|
7
6
|
return (source, context = {}) => {
|
|
8
7
|
if (source === '') return;
|
|
9
|
-
|
|
10
|
-
if (
|
|
8
|
+
const src = conv(source);
|
|
9
|
+
if (src === '') return [[], ''];
|
|
11
10
|
const memo = context.memo;
|
|
12
|
-
|
|
13
|
-
const result = parser(
|
|
14
|
-
|
|
11
|
+
memo && (memo.offset += source.length - src.length);
|
|
12
|
+
const result = parser(src, context);
|
|
13
|
+
assert(check(src, result));
|
|
14
|
+
memo && (memo.offset -= source.length - src.length);
|
|
15
15
|
return result;
|
|
16
16
|
};
|
|
17
17
|
}
|
|
@@ -14,10 +14,10 @@ export function focus<T>(scope: string | RegExp, parser: Parser<T>): Parser<T> {
|
|
|
14
14
|
assert(source.startsWith(src));
|
|
15
15
|
if (src === '') return;
|
|
16
16
|
const memo = context.memo;
|
|
17
|
-
memo && (memo.offset
|
|
17
|
+
memo && (memo.offset += source.length - src.length);
|
|
18
18
|
const result = parser(src, context);
|
|
19
19
|
assert(check(src, result));
|
|
20
|
-
memo && (memo.offset
|
|
20
|
+
memo && (memo.offset -= source.length - src.length);
|
|
21
21
|
if (!result) return;
|
|
22
22
|
assert(exec(result).length < src.length);
|
|
23
23
|
return exec(result).length < src.length
|
|
@@ -42,10 +42,10 @@ export function rewrite<T>(scope: Parser<unknown>, parser: Parser<T>): Parser<T>
|
|
|
42
42
|
const src = source.slice(0, source.length - exec(res1).length);
|
|
43
43
|
assert(src !== '');
|
|
44
44
|
assert(source.startsWith(src));
|
|
45
|
-
memo && (memo.offset
|
|
45
|
+
memo && (memo.offset += source.length - src.length);
|
|
46
46
|
const res2 = parser(src, context);
|
|
47
47
|
assert(check(src, res2));
|
|
48
|
-
memo && (memo.offset
|
|
48
|
+
memo && (memo.offset -= source.length - src.length);
|
|
49
49
|
if (!res2) return;
|
|
50
50
|
assert(exec(res2) === '');
|
|
51
51
|
return exec(res2).length < src.length
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export class Memo {
|
|
2
|
-
private memory: Record<string, readonly [any[], number]>[/* pos */] = [];
|
|
2
|
+
private memory: Record<string, readonly [any[], number] | readonly []>[/* pos */] = [];
|
|
3
3
|
public get length(): number {
|
|
4
4
|
return this.memory.length;
|
|
5
5
|
}
|
|
@@ -8,7 +8,7 @@ export class Memo {
|
|
|
8
8
|
position: number,
|
|
9
9
|
syntax: number,
|
|
10
10
|
state: number,
|
|
11
|
-
): readonly [any[], number] | undefined {
|
|
11
|
+
): readonly [any[], number] | readonly [] | undefined {
|
|
12
12
|
//console.log('get', position + this.offset, syntax, state, this.memory[position + this.offset - 1]?.[`${syntax}:${state}`]);;
|
|
13
13
|
return this.memory[position + this.offset - 1]?.[`${syntax}:${state}`];
|
|
14
14
|
}
|
|
@@ -16,12 +16,14 @@ export class Memo {
|
|
|
16
16
|
position: number,
|
|
17
17
|
syntax: number,
|
|
18
18
|
state: number,
|
|
19
|
-
nodes: any[],
|
|
19
|
+
nodes: any[] | undefined,
|
|
20
20
|
offset: number,
|
|
21
21
|
): void {
|
|
22
22
|
const record = this.memory[position + this.offset - 1] ??= {};
|
|
23
23
|
assert(!record[`${syntax}:${state}`]);
|
|
24
|
-
record[`${syntax}:${state}`] =
|
|
24
|
+
record[`${syntax}:${state}`] = nodes
|
|
25
|
+
? [nodes.slice(), offset]
|
|
26
|
+
: [];
|
|
25
27
|
//console.log('set', position + this.offset, syntax, state);
|
|
26
28
|
}
|
|
27
29
|
public clear(position: number): void {
|
|
@@ -29,6 +31,6 @@ export class Memo {
|
|
|
29
31
|
for (let i = position + this.offset, len = memory.length; i < len; ++i) {
|
|
30
32
|
memory.pop();
|
|
31
33
|
}
|
|
32
|
-
//console.log(position);
|
|
34
|
+
//console.log('clear', position);
|
|
33
35
|
}
|
|
34
36
|
}
|
|
@@ -76,24 +76,24 @@ export function syntax<T>(syntax: number, precedence: number, cost: number | Par
|
|
|
76
76
|
const pos = source.length;
|
|
77
77
|
const cache = syntax && context.memo?.get(pos, syntax, state);
|
|
78
78
|
const result: Result<T> = cache
|
|
79
|
-
?
|
|
79
|
+
? cache.length === 0
|
|
80
|
+
? undefined
|
|
81
|
+
: [cache[0], source.slice(cache[1])]
|
|
80
82
|
: parser!(source, context);
|
|
81
83
|
++resources.recursion;
|
|
82
|
-
if (result) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
if (result && !cache) {
|
|
85
|
+
assert(cost = cost as number);
|
|
86
|
+
resources.budget -= cost;
|
|
87
|
+
}
|
|
88
|
+
if (syntax) {
|
|
89
|
+
if (state & context.backtrackable) {
|
|
90
|
+
context.memo ??= new Memo();
|
|
91
|
+
cache ?? context.memo.set(pos, syntax, state, eval(result), source.length - exec(result, '').length);
|
|
92
|
+
assert.deepStrictEqual(cache && cache, cache && context.memo.get(pos, syntax, state));
|
|
86
93
|
}
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
cache ?? context.memo.set(pos, syntax, state, eval(result), source.length - exec(result).length);
|
|
91
|
-
assert.deepStrictEqual(cache && cache, cache && context.memo.get(pos, syntax, state));
|
|
92
|
-
}
|
|
93
|
-
else if (context.memo?.length! >= pos) {
|
|
94
|
-
assert(!(state & context.backtrackable));
|
|
95
|
-
context.memo!.clear(pos);
|
|
96
|
-
}
|
|
94
|
+
else if (result && context.memo?.length! >= pos) {
|
|
95
|
+
assert(!(state & context.backtrackable));
|
|
96
|
+
context.memo!.clear(pos);
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
context.precedence = p;
|
|
@@ -10,22 +10,22 @@ import { unshift, push } from 'spica/array';
|
|
|
10
10
|
const index = /^[0-9A-Za-z]+(?:(?:[.-]|, )[0-9A-Za-z]+)*/;
|
|
11
11
|
|
|
12
12
|
export const bracket: BracketParser = lazy(() => union([
|
|
13
|
-
syntax(Rule.none, 2,
|
|
14
|
-
syntax(Rule.bracket, 2,
|
|
13
|
+
surround(str('('), syntax(Rule.none, 2, str(index)), str(')')),
|
|
14
|
+
surround(str('('), syntax(Rule.bracket, 2, some(inline, ')', [[')', 2]])), str(')'), true,
|
|
15
15
|
([as, bs = [], cs], rest) => [[html('span', { class: 'paren' }, defrag(push(unshift(as, bs), cs)))], rest],
|
|
16
|
-
([as, bs = []], rest) => [unshift([''], unshift(as, bs)), rest])
|
|
17
|
-
syntax(Rule.none, 2,
|
|
18
|
-
syntax(Rule.bracket, 2,
|
|
16
|
+
([as, bs = []], rest) => [unshift([''], unshift(as, bs)), rest]),
|
|
17
|
+
surround(str('('), syntax(Rule.none, 2, str(new RegExp(index.source.replace(', ', '[,、]').replace(/[09AZaz.]|\-(?!\w)/g, c => c.trimStart() && String.fromCharCode(c.charCodeAt(0) + 0xFEE0))))), str(')')),
|
|
18
|
+
surround(str('('), syntax(Rule.bracket, 2, some(inline, ')', [[')', 2]])), str(')'), true,
|
|
19
19
|
([as, bs = [], cs], rest) => [[html('span', { class: 'paren' }, defrag(push(unshift(as, bs), cs)))], rest],
|
|
20
|
-
([as, bs = []], rest) => [unshift(as, bs), rest])
|
|
21
|
-
syntax(Rule.bracket, 2,
|
|
20
|
+
([as, bs = []], rest) => [unshift(as, bs), rest]),
|
|
21
|
+
surround(str('['), syntax(Rule.bracket, 2, some(inline, ']', [[']', 2]])), str(']'), true,
|
|
22
22
|
undefined,
|
|
23
|
-
([as, bs = []], rest) => [unshift([''], unshift(as, bs)), rest])
|
|
24
|
-
syntax(Rule.bracket, 2,
|
|
23
|
+
([as, bs = []], rest) => [unshift([''], unshift(as, bs)), rest]),
|
|
24
|
+
surround(str('{'), syntax(Rule.bracket, 2, some(inline, '}', [['}', 2]])), str('}'), true,
|
|
25
25
|
undefined,
|
|
26
|
-
([as, bs = []], rest) => [unshift(as, bs), rest])
|
|
26
|
+
([as, bs = []], rest) => [unshift(as, bs), rest]),
|
|
27
27
|
// Control media blinking in editing rather than control confusion of pairs of quote marks.
|
|
28
|
-
syntax(Rule.quote, 8,
|
|
28
|
+
surround(str('"'), syntax(Rule.quote, 8, some(inline, '"', [['"', 8]])), str('"'), true,
|
|
29
29
|
undefined,
|
|
30
|
-
([as, bs = []], rest) => [unshift(as, bs), rest])
|
|
30
|
+
([as, bs = []], rest) => [unshift(as, bs), rest]),
|
|
31
31
|
]));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { undefined, location, encodeURI, decodeURI, Location } from 'spica/global';
|
|
2
2
|
import { LinkParser, TextLinkParser } from '../inline';
|
|
3
|
-
import { Result, eval } from '../../combinator/data/parser';
|
|
3
|
+
import { Result, eval, exec } from '../../combinator/data/parser';
|
|
4
4
|
import { union, inits, tails, subsequence, some, guard, syntax, state, validate, surround, open, dup, reverse, lazy, fmap, bind } from '../../combinator';
|
|
5
5
|
import { inline, media, shortmedia } from '../inline';
|
|
6
6
|
import { attributes } from './html';
|
|
@@ -42,7 +42,11 @@ export const link: LinkParser = lazy(() => validate(['[', '{'], syntax(Rule.link
|
|
|
42
42
|
if (params.length === 0) return;
|
|
43
43
|
assert(params.every(p => typeof p === 'string'));
|
|
44
44
|
if (content.length !== 0 && trimNode(content).length === 0) return;
|
|
45
|
-
|
|
45
|
+
for (let source = stringify(content); source;) {
|
|
46
|
+
const result = autolink(source, context);
|
|
47
|
+
if (typeof eval(result!)[0] === 'object') return;
|
|
48
|
+
source = exec(result!);
|
|
49
|
+
}
|
|
46
50
|
assert(!html('div', content).querySelector('a, .media, .annotation, .reference') || (content[0] as HTMLElement).matches('.media'));
|
|
47
51
|
const INSECURE_URI = params.shift()!;
|
|
48
52
|
assert(INSECURE_URI === INSECURE_URI.trim());
|