securemark 0.296.1 → 0.296.3
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 +162 -124
- package/package.json +1 -1
- package/src/combinator/control/constraint/contract.ts +4 -3
- package/src/combinator/control/manipulation/scope.ts +1 -1
- package/src/combinator/control/manipulation/surround.ts +32 -16
- package/src/combinator/data/delimiter.ts +82 -6
- package/src/combinator/data/parser/context.test.ts +2 -2
- package/src/combinator/data/parser/context.ts +12 -36
- package/src/parser/api/bind.ts +6 -6
- package/src/parser/api/parse.ts +1 -1
- package/src/parser/inline/annotation.ts +3 -3
- package/src/parser/inline/deletion.ts +1 -1
- package/src/parser/inline/emphasis.ts +4 -4
- package/src/parser/inline/emstrong.test.ts +1 -0
- package/src/parser/inline/emstrong.ts +3 -3
- package/src/parser/inline/extension/index.ts +2 -3
- package/src/parser/inline/extension/placeholder.ts +2 -2
- package/src/parser/inline/insertion.ts +1 -1
- package/src/parser/inline/italic.test.ts +1 -0
- package/src/parser/inline/italic.ts +2 -2
- package/src/parser/inline/link.ts +3 -3
- package/src/parser/inline/mark.test.ts +1 -0
- package/src/parser/inline/mark.ts +4 -4
- package/src/parser/inline/reference.ts +3 -3
- package/src/parser/inline/strong.ts +4 -4
- package/src/parser/source/str.ts +4 -4
- package/src/parser/util.ts +7 -4
- package/src/parser/visibility.ts +13 -28
package/src/parser/util.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Parser, Result, List, Node, failsafe } from '../combinator/data/parser';
|
|
2
|
+
import { tester } from '../combinator/data/delimiter';
|
|
2
3
|
import { Context, Command } from './context';
|
|
3
4
|
import { min } from 'spica/alias';
|
|
4
5
|
import { define } from 'typed-dom/dom';
|
|
@@ -10,8 +11,8 @@ export function* unwrap<N>(nodes: List<Node<N>> | undefined): Iterable<N> {
|
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
export function repeat<P extends Parser<HTMLElement | string, Context>>(symbol: string, parser: P, cons: (nodes: List<Node<Parser.Node<P>>>, context: Parser.Context<P
|
|
14
|
-
export function repeat<N extends HTMLElement | string>(symbol: string, parser: Parser<N>, cons: (nodes: List<Node<N>>, context: Context) => List<Node<N>>, termination: (acc: List<Node<N>>, context: Context, prefix: number, postfix: number, state: boolean) => Result<string | N, Context> = (nodes, context, prefix, postfix) => {
|
|
14
|
+
export function repeat<P extends Parser<HTMLElement | string, Context>>(symbol: string, after: string | RegExp, parser: P, cons: (nodes: List<Node<Parser.Node<P>>>, context: Parser.Context<P>, nest: boolean) => List<Node<Parser.Node<P>>>, termination?: (acc: List<Node<Parser.Node<P>>>, context: Context, prefix: number, postfix: number, state: boolean) => Result<string | Parser.Node<P>>): P;
|
|
15
|
+
export function repeat<N extends HTMLElement | string>(symbol: string, after: string | RegExp, parser: Parser<N>, cons: (nodes: List<Node<N>>, context: Context, nest: boolean) => List<Node<N>>, termination: (acc: List<Node<N>>, context: Context, prefix: number, postfix: number, state: boolean) => Result<string | N, Context> = (nodes, context, prefix, postfix) => {
|
|
15
16
|
const acc = new List<Node<string | N>>();
|
|
16
17
|
if (prefix > 0) {
|
|
17
18
|
acc.push(new Node(symbol[0].repeat(prefix)));
|
|
@@ -24,6 +25,7 @@ export function repeat<N extends HTMLElement | string>(symbol: string, parser: P
|
|
|
24
25
|
}
|
|
25
26
|
return acc;
|
|
26
27
|
}): Parser<string | N, Context> {
|
|
28
|
+
const test = tester(after, false);
|
|
27
29
|
return failsafe(input => {
|
|
28
30
|
const { context } = input;
|
|
29
31
|
const { source, position } = context;
|
|
@@ -32,10 +34,11 @@ export function repeat<N extends HTMLElement | string>(symbol: string, parser: P
|
|
|
32
34
|
let i = symbol.length;
|
|
33
35
|
for (; source[context.position + i] === source[context.position];) ++i;
|
|
34
36
|
context.position += i;
|
|
37
|
+
if (test(input) === undefined) return;
|
|
35
38
|
let state = false;
|
|
36
39
|
for (; i >= symbol.length; i -= symbol.length) {
|
|
37
40
|
if (nodes.length > 0 && source.startsWith(symbol, context.position)) {
|
|
38
|
-
nodes = cons(nodes, context);
|
|
41
|
+
nodes = cons(nodes, context, i > symbol.length);
|
|
39
42
|
context.position += symbol.length;
|
|
40
43
|
continue;
|
|
41
44
|
}
|
|
@@ -57,7 +60,7 @@ export function repeat<N extends HTMLElement | string>(symbol: string, parser: P
|
|
|
57
60
|
state = true;
|
|
58
61
|
continue;
|
|
59
62
|
default:
|
|
60
|
-
nodes = cons(nodes, context);
|
|
63
|
+
nodes = cons(nodes, context, i > symbol.length);
|
|
61
64
|
state = true;
|
|
62
65
|
continue;
|
|
63
66
|
}
|
package/src/parser/visibility.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Parser,
|
|
2
|
-
import {
|
|
1
|
+
import { Parser, List, Node, failsafe } from '../combinator/data/parser';
|
|
2
|
+
import { Command } from './context';
|
|
3
3
|
import { Flag } from './node';
|
|
4
4
|
import { convert, fmap } from '../combinator';
|
|
5
5
|
import { invisibleBlankHTMLEntityNames } from './api/normalize';
|
|
@@ -25,7 +25,8 @@ export function visualize<P extends Parser>(parser: P): P {
|
|
|
25
25
|
parser);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export const
|
|
28
|
+
export const beforeNonblank = beforeNonblankWith('');
|
|
29
|
+
export const afterNonblank = afterNonblankWith('');
|
|
29
30
|
export function blankWith(starts: '\n', delimiter: string | RegExp): RegExp {
|
|
30
31
|
return new RegExp([
|
|
31
32
|
// 空行除去
|
|
@@ -36,37 +37,21 @@ export function blankWith(starts: '\n', delimiter: string | RegExp): RegExp {
|
|
|
36
37
|
: delimiter.source,
|
|
37
38
|
].join(''), 'y');
|
|
38
39
|
}
|
|
39
|
-
function
|
|
40
|
+
export function beforeNonblankWith(delimiter: string | RegExp): RegExp {
|
|
40
41
|
return new RegExp([
|
|
41
|
-
String.raw`(?<!\s|&(?:${invisibleBlankHTMLEntityNames.join('|')});|<wbr ?>)`,
|
|
42
42
|
typeof delimiter === 'string'
|
|
43
43
|
? delimiter.replace(/[*+()\[\]]/g, '\\$&')
|
|
44
44
|
: delimiter.source,
|
|
45
|
+
String.raw`(?!\\?\s|&(?:${invisibleBlankHTMLEntityNames.join('|')});|<wbr ?>)`,
|
|
45
46
|
].join(''), 'y');
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
function isNonblankStart(input: Input<Context>): boolean {
|
|
56
|
-
const { context } = input;
|
|
57
|
-
const { source, position } = context;
|
|
58
|
-
if (position === source.length) return true;
|
|
59
|
-
switch (source[position]) {
|
|
60
|
-
case ' ':
|
|
61
|
-
case ' ':
|
|
62
|
-
case '\t':
|
|
63
|
-
case '\n':
|
|
64
|
-
return false;
|
|
65
|
-
default:
|
|
66
|
-
const reg = blank.unit;
|
|
67
|
-
reg.lastIndex = position;
|
|
68
|
-
return !reg.test(source);
|
|
69
|
-
}
|
|
48
|
+
function afterNonblankWith(delimiter: string | RegExp): RegExp {
|
|
49
|
+
return new RegExp([
|
|
50
|
+
String.raw`(?<!\s|&(?:${invisibleBlankHTMLEntityNames.join('|')});|<wbr ?>)`,
|
|
51
|
+
typeof delimiter === 'string'
|
|
52
|
+
? delimiter.replace(/[*+()\[\]]/g, '\\$&')
|
|
53
|
+
: delimiter.source,
|
|
54
|
+
].join(''), 'y');
|
|
70
55
|
}
|
|
71
56
|
|
|
72
57
|
export function isNonblankFirstLine(nodes: List<Node<HTMLElement | string>>): boolean {
|