securemark 0.281.4 → 0.283.0
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 +9 -0
- package/design.md +5 -9
- package/dist/index.js +7354 -7166
- package/package.json +2 -2
- package/src/combinator/control/manipulation/convert.ts +4 -8
- package/src/combinator/control/manipulation/indent.ts +3 -5
- package/src/combinator/control/manipulation/scope.ts +6 -3
- package/src/combinator/control/manipulation/surround.ts +17 -2
- package/src/combinator/data/parser/context.test.ts +6 -6
- package/src/combinator/data/parser/context.ts +25 -39
- package/src/combinator/data/parser.ts +2 -3
- package/src/parser/api/bind.ts +6 -6
- package/src/parser/api/parse.test.ts +17 -16
- package/src/parser/api/parse.ts +0 -3
- package/src/parser/block/blockquote.ts +4 -3
- package/src/parser/block/dlist.test.ts +1 -1
- package/src/parser/block/dlist.ts +6 -6
- package/src/parser/block/extension/aside.ts +4 -3
- package/src/parser/block/extension/example.ts +4 -3
- package/src/parser/block/extension/table.ts +7 -7
- package/src/parser/block/heading.ts +3 -2
- package/src/parser/block/ilist.ts +2 -1
- package/src/parser/block/olist.ts +4 -3
- package/src/parser/block/reply/cite.ts +3 -3
- package/src/parser/block/reply/quote.ts +3 -3
- package/src/parser/block/sidefence.ts +2 -1
- package/src/parser/block/table.ts +9 -9
- package/src/parser/block/ulist.ts +6 -5
- package/src/parser/block.ts +16 -5
- package/src/parser/context.ts +9 -21
- package/src/parser/inline/annotation.ts +5 -4
- package/src/parser/inline/autolink/email.ts +2 -1
- package/src/parser/inline/autolink/url.ts +6 -5
- package/src/parser/inline/autolink.ts +2 -2
- package/src/parser/inline/bracket.ts +17 -17
- package/src/parser/inline/code.test.ts +1 -1
- package/src/parser/inline/code.ts +2 -1
- package/src/parser/inline/deletion.ts +3 -3
- package/src/parser/inline/emphasis.ts +3 -3
- package/src/parser/inline/emstrong.ts +3 -3
- package/src/parser/inline/extension/index.test.ts +4 -4
- package/src/parser/inline/extension/index.ts +18 -6
- package/src/parser/inline/extension/indexee.ts +37 -7
- package/src/parser/inline/extension/indexer.test.ts +2 -2
- package/src/parser/inline/extension/indexer.ts +2 -1
- package/src/parser/inline/extension/label.ts +2 -2
- package/src/parser/inline/extension/placeholder.ts +4 -4
- package/src/parser/inline/html.ts +2 -2
- package/src/parser/inline/htmlentity.ts +2 -1
- package/src/parser/inline/insertion.ts +3 -3
- package/src/parser/inline/link.test.ts +2 -2
- package/src/parser/inline/link.ts +7 -7
- package/src/parser/inline/mark.test.ts +2 -2
- package/src/parser/inline/mark.ts +3 -3
- package/src/parser/inline/math.test.ts +3 -3
- package/src/parser/inline/math.ts +6 -5
- package/src/parser/inline/media.test.ts +1 -1
- package/src/parser/inline/media.ts +5 -5
- package/src/parser/inline/reference.ts +6 -5
- package/src/parser/inline/remark.ts +2 -2
- package/src/parser/inline/ruby.ts +3 -3
- package/src/parser/inline/strong.ts +3 -3
- package/src/parser/inline/template.ts +4 -4
- package/src/parser/inline.ts +1 -0
- package/src/parser/source/escapable.ts +2 -1
- package/src/parser/source/str.ts +3 -2
- package/src/parser/source/text.ts +2 -1
- package/src/parser/source/unescapable.ts +2 -1
- package/src/combinator/data/parser/context/memo.ts +0 -57
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { max } from 'spica/alias';
|
|
2
|
-
|
|
3
|
-
export class Memo {
|
|
4
|
-
constructor(
|
|
5
|
-
public readonly targets = ~0,
|
|
6
|
-
public readonly margin = 0,
|
|
7
|
-
) {
|
|
8
|
-
}
|
|
9
|
-
private memory: Record<number, Record<number, Record<number, readonly [unknown[], number] | readonly []>> | undefined> = {};
|
|
10
|
-
private count = 0;
|
|
11
|
-
private $length = 0;
|
|
12
|
-
public get length(): number {
|
|
13
|
-
return this.$length;
|
|
14
|
-
}
|
|
15
|
-
public get(
|
|
16
|
-
position: number,
|
|
17
|
-
syntax: number,
|
|
18
|
-
state: number,
|
|
19
|
-
): readonly [unknown[], number] | readonly [] | undefined {
|
|
20
|
-
assert(position > 0);
|
|
21
|
-
if (this.count === 0) return;
|
|
22
|
-
//console.log('get', position, syntax, state, this.memory[position - 1]?.[syntax]?.[state]);
|
|
23
|
-
const cache = this.memory[position - 1]?.[syntax]?.[state];
|
|
24
|
-
return cache?.length === 2
|
|
25
|
-
? [cache[0].slice(), cache[1]]
|
|
26
|
-
: cache;
|
|
27
|
-
}
|
|
28
|
-
public set(
|
|
29
|
-
position: number,
|
|
30
|
-
syntax: number,
|
|
31
|
-
state: number,
|
|
32
|
-
nodes: unknown[] | undefined,
|
|
33
|
-
offset: number,
|
|
34
|
-
): void {
|
|
35
|
-
assert(position > 0);
|
|
36
|
-
this.$length = max(this.$length, position);
|
|
37
|
-
const record = this.memory[position - 1] ??= (++this.count, {});
|
|
38
|
-
assert(!record[syntax]?.[state]);
|
|
39
|
-
(record[syntax] ??= {})[state] = nodes
|
|
40
|
-
? [nodes.slice(), offset]
|
|
41
|
-
: [];
|
|
42
|
-
//console.log('set', position, syntax, state, record[syntax]?.[state]);
|
|
43
|
-
}
|
|
44
|
-
public resize(position: number): void {
|
|
45
|
-
const memory = this.memory;
|
|
46
|
-
for (let i = this.$length; i > position; this.$length = --i) {
|
|
47
|
-
if (!(i in memory)) continue;
|
|
48
|
-
memory[i] &&= (--this.count, undefined);
|
|
49
|
-
}
|
|
50
|
-
//console.log('resize', position + 1);
|
|
51
|
-
}
|
|
52
|
-
public clear(): void {
|
|
53
|
-
this.memory = {};
|
|
54
|
-
this.count = 0;
|
|
55
|
-
this.$length = 0;
|
|
56
|
-
}
|
|
57
|
-
}
|