securemark 0.294.0 → 0.294.1
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 +164 -119
- package/package.json +2 -2
- package/src/combinator/control/constraint/contract.ts +2 -2
- package/src/combinator/control/constraint/line.ts +2 -2
- package/src/combinator/control/manipulation/indent.ts +3 -7
- package/src/combinator/control/manipulation/scope.ts +4 -6
- package/src/combinator/control/manipulation/surround.ts +5 -8
- package/src/combinator/control/monad/bind.ts +2 -3
- package/src/combinator/data/data.ts +2 -2
- package/src/combinator/data/parser/context.test.ts +4 -4
- package/src/combinator/data/parser/inits.ts +4 -6
- package/src/combinator/data/parser/sequence.ts +4 -6
- package/src/combinator/data/parser/some.ts +5 -7
- package/src/combinator/data/parser.ts +3 -21
- package/src/debug.test.ts +2 -2
- package/src/parser/api/bind.ts +5 -5
- package/src/parser/api/header.ts +2 -2
- package/src/parser/api/normalize.ts +2 -2
- package/src/parser/api/parse.ts +2 -2
- package/src/parser/block/codeblock.ts +2 -2
- package/src/parser/block/extension/example.ts +2 -2
- package/src/parser/block/extension/figure.ts +1 -1
- package/src/parser/block/extension/message.ts +2 -2
- package/src/parser/block/extension/table.ts +2 -2
- package/src/parser/block.ts +4 -0
- package/src/parser/inline/emstrong.ts +5 -5
- package/src/parser/inline/reference.ts +2 -2
- package/src/parser/inline/ruby.ts +4 -4
- package/src/parser/processor/note.ts +2 -2
- package/src/parser/segment.ts +4 -4
- package/src/parser/source/line.ts +5 -0
- package/src/parser/source/str.ts +1 -1
- package/src/parser/util.ts +5 -5
- package/src/parser/visibility.ts +2 -2
package/src/parser/segment.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MarkdownParser } from '../../markdown';
|
|
2
2
|
import { Command } from './context';
|
|
3
|
-
import { clean
|
|
3
|
+
import { clean } from '../combinator/data/parser';
|
|
4
4
|
import { union, some } from '../combinator';
|
|
5
5
|
import { segment as heading } from './block/heading';
|
|
6
6
|
import { segment as codeblock } from './block/codeblock';
|
|
@@ -48,13 +48,13 @@ export function* segment(source: string): Generator<string, undefined, undefined
|
|
|
48
48
|
position: 0,
|
|
49
49
|
};
|
|
50
50
|
const input = { context };
|
|
51
|
-
|
|
51
|
+
for (; context.position < source.length;) {
|
|
52
52
|
const { position } = context;
|
|
53
53
|
const result = parser(input)!;
|
|
54
54
|
assert(result);
|
|
55
55
|
assert(context.position > position);
|
|
56
|
-
const segs =
|
|
57
|
-
?
|
|
56
|
+
const segs = result.length > 0
|
|
57
|
+
? result.foldl<string[]>((acc, { value }) => void acc.push(value) || acc, [])
|
|
58
58
|
: [source.slice(position, context.position)];
|
|
59
59
|
assert(segs.join('') === source.slice(position, context.position));
|
|
60
60
|
for (let i = 0; i < segs.length; ++i) {
|
|
@@ -4,6 +4,7 @@ import { List } from '../../combinator/data/parser';
|
|
|
4
4
|
export const anyline: AnyLineParser = input => {
|
|
5
5
|
const { context } = input;
|
|
6
6
|
const { source, position } = context;
|
|
7
|
+
if (position === source.length) return;
|
|
7
8
|
context.position = source.indexOf('\n', position) + 1 || source.length;
|
|
8
9
|
return new List();
|
|
9
10
|
};
|
|
@@ -11,6 +12,8 @@ const regEmptyline = /[^\S\n]*(?:$|\n)/y;
|
|
|
11
12
|
export const emptyline: EmptyLineParser = input => {
|
|
12
13
|
const { context } = input;
|
|
13
14
|
const { source, position } = context;
|
|
15
|
+
if (position === source.length) return;
|
|
16
|
+
if (source[position] === '\n') return ++context.position, new List();
|
|
14
17
|
regEmptyline.lastIndex = position;
|
|
15
18
|
regEmptyline.test(source);
|
|
16
19
|
const i = regEmptyline.lastIndex;
|
|
@@ -22,6 +25,8 @@ const regContentline = /[^\S\n]*\S[^\n]*(?:$|\n)/y;
|
|
|
22
25
|
export const contentline: ContentLineParser = input => {
|
|
23
26
|
const { context } = input;
|
|
24
27
|
const { source, position } = context;
|
|
28
|
+
if (position === source.length) return;
|
|
29
|
+
if (source[position] === '\n') return;
|
|
25
30
|
regContentline.lastIndex = position;
|
|
26
31
|
regContentline.test(source);
|
|
27
32
|
const i = regContentline.lastIndex;
|
package/src/parser/source/str.ts
CHANGED
|
@@ -13,7 +13,7 @@ export function strs(pattern: string): Parser<string> {
|
|
|
13
13
|
return ({ context }) => {
|
|
14
14
|
const { source } = context;
|
|
15
15
|
let acc = '';
|
|
16
|
-
|
|
16
|
+
for (; context.position < source.length && source.startsWith(pattern, context.position);) {
|
|
17
17
|
acc += pattern;
|
|
18
18
|
context.position += pattern.length;
|
|
19
19
|
}
|
package/src/parser/util.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { min } from 'spica/alias';
|
|
2
2
|
import { MarkdownParser } from '../../markdown';
|
|
3
3
|
import { Command } from './context';
|
|
4
|
-
import { Parser, Result, List, Data, Ctx, Node, Context,
|
|
4
|
+
import { Parser, Result, List, Data, Ctx, Node, Context, failsafe } from '../combinator/data/parser';
|
|
5
5
|
import { define } from 'typed-dom/dom';
|
|
6
6
|
|
|
7
|
-
export function* unwrap<N>(nodes: List<Data<N>>): Iterable<N> {
|
|
8
|
-
for (const node of nodes) {
|
|
7
|
+
export function* unwrap<N>(nodes: List<Data<N>> | undefined): Iterable<N> {
|
|
8
|
+
for (const node of nodes ?? []) {
|
|
9
9
|
yield node.value;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
@@ -30,7 +30,7 @@ export function repeat<N extends HTMLElement | string>(symbol: string, parser: P
|
|
|
30
30
|
assert(source.startsWith(symbol, context.position));
|
|
31
31
|
let nodes = new List<Data<N>>();
|
|
32
32
|
let i = symbol.length;
|
|
33
|
-
|
|
33
|
+
for (; source[context.position + i] === source[context.position];) ++i;
|
|
34
34
|
context.position += i;
|
|
35
35
|
let state = false;
|
|
36
36
|
for (; i >= symbol.length; i -= symbol.length) {
|
|
@@ -44,7 +44,7 @@ export function repeat<N extends HTMLElement | string>(symbol: string, parser: P
|
|
|
44
44
|
const result = parser(input);
|
|
45
45
|
context.buffer = buf;
|
|
46
46
|
if (result === undefined) break;
|
|
47
|
-
nodes =
|
|
47
|
+
nodes = result;
|
|
48
48
|
switch (nodes.last?.value) {
|
|
49
49
|
case Command.Cancel:
|
|
50
50
|
assert(!source.startsWith(symbol, context.position));
|
package/src/parser/visibility.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MarkdownParser } from '../../markdown';
|
|
2
2
|
import { Command } from './context';
|
|
3
|
-
import { Parser, Input, List, Data,
|
|
3
|
+
import { Parser, Input, List, Data, failsafe } from '../combinator/data/parser';
|
|
4
4
|
import { convert, fmap } from '../combinator';
|
|
5
5
|
import { unsafehtmlentity } from './inline/htmlentity';
|
|
6
6
|
import { invisibleHTMLEntityNames } from './api/normalize';
|
|
@@ -93,7 +93,7 @@ function isTightStart(input: Input<MarkdownParser.Context>, except?: string): bo
|
|
|
93
93
|
switch (true) {
|
|
94
94
|
case source.length - position > 2
|
|
95
95
|
&& source[position + 1] !== ' '
|
|
96
|
-
&&
|
|
96
|
+
&& unsafehtmlentity(input)?.head?.value.trimStart() === '':
|
|
97
97
|
context.position = position;
|
|
98
98
|
return false;
|
|
99
99
|
}
|