securemark 0.295.4 → 0.295.6
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 +83 -73
- package/markdown.d.ts +5 -10
- package/package.json +1 -1
- package/src/combinator/data/delimiter.ts +5 -2
- package/src/combinator/data/parser/some.ts +20 -11
- package/src/parser/api/bind.test.ts +2 -2
- package/src/parser/api/parse.test.ts +20 -10
- package/src/parser/block/blockquote.ts +2 -2
- package/src/parser/block/ilist.ts +1 -1
- package/src/parser/block/olist.ts +1 -1
- package/src/parser/block/sidefence.ts +1 -1
- package/src/parser/block/ulist.ts +1 -1
- package/src/parser/inline/autolink/url.ts +1 -1
- package/src/parser/inline/bracket.ts +0 -2
- package/src/parser/inline/deletion.ts +3 -4
- package/src/parser/inline/emphasis.ts +3 -4
- package/src/parser/inline/emstrong.ts +7 -13
- package/src/parser/inline/extension/index.ts +11 -17
- package/src/parser/inline/insertion.ts +3 -4
- package/src/parser/inline/italic.ts +5 -9
- package/src/parser/inline/link.test.ts +1 -1
- package/src/parser/inline/link.ts +8 -7
- package/src/parser/inline/mark.test.ts +6 -6
- package/src/parser/inline/mark.ts +8 -11
- package/src/parser/inline/ruby.ts +2 -2
- package/src/parser/inline/strong.ts +3 -4
- package/src/parser/inline.test.ts +4 -1
- package/src/parser/segment.test.ts +2 -2
- package/src/parser/segment.ts +2 -2
- package/src/parser/source/escapable.ts +2 -2
- package/src/parser/source/text.ts +13 -9
- package/src/parser/source/unescapable.ts +2 -2
- package/src/parser/visibility.ts +18 -14
|
@@ -8,7 +8,7 @@ import { html } from 'typed-dom/dom';
|
|
|
8
8
|
const delimiter = /(?=[\\$"`\[\](){}\r\n]|\s\$|:\/\/)/g;
|
|
9
9
|
|
|
10
10
|
export const escsource: EscapableSourceParser = ({ context }) => {
|
|
11
|
-
const { source, position } = context;
|
|
11
|
+
const { source, position, state } = context;
|
|
12
12
|
if (position === source.length) return;
|
|
13
13
|
const char = source[position];
|
|
14
14
|
consume(1, context);
|
|
@@ -38,7 +38,7 @@ export const escsource: EscapableSourceParser = ({ context }) => {
|
|
|
38
38
|
default:
|
|
39
39
|
assert(char !== '\n');
|
|
40
40
|
if (context.sequential) return new List([new Node(char)]);
|
|
41
|
-
let i = next(source, position, delimiter);
|
|
41
|
+
let i = next(source, position, state, delimiter);
|
|
42
42
|
assert(i > position);
|
|
43
43
|
i -= position;
|
|
44
44
|
consume(i - 1, context);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TextParser, TxtParser } from '../source';
|
|
2
|
-
import { Command } from '../context';
|
|
2
|
+
import { State, Command } from '../context';
|
|
3
3
|
import { List, Node } from '../../combinator/data/parser';
|
|
4
4
|
import { union, consume } from '../../combinator';
|
|
5
5
|
import { html } from 'typed-dom/dom';
|
|
@@ -9,7 +9,7 @@ export const nonWhitespace = /[^ \t ]/g;
|
|
|
9
9
|
|
|
10
10
|
export const text: TextParser = input => {
|
|
11
11
|
const { context } = input;
|
|
12
|
-
const { source, position } = context;
|
|
12
|
+
const { source, position, state } = context;
|
|
13
13
|
if (position === source.length) return;
|
|
14
14
|
const char = source[position];
|
|
15
15
|
consume(1, context);
|
|
@@ -43,7 +43,7 @@ export const text: TextParser = input => {
|
|
|
43
43
|
? nonWhitespace.test(source)
|
|
44
44
|
? nonWhitespace.lastIndex - 1
|
|
45
45
|
: source.length
|
|
46
|
-
: next(source, position);
|
|
46
|
+
: next(source, position, state);
|
|
47
47
|
assert(i > position);
|
|
48
48
|
const lineend = 0
|
|
49
49
|
|| s && i === source.length
|
|
@@ -83,7 +83,7 @@ function isWhitespace(char: string, linebreak: boolean): boolean {
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
export function next(source: string, position: number, delimiter?: RegExp): number {
|
|
86
|
+
export function next(source: string, position: number, state: number, delimiter?: RegExp): number {
|
|
87
87
|
let index: number;
|
|
88
88
|
if (delimiter) {
|
|
89
89
|
delimiter.lastIndex = position + 1;
|
|
@@ -91,7 +91,7 @@ export function next(source: string, position: number, delimiter?: RegExp): numb
|
|
|
91
91
|
index = delimiter.lastIndex;
|
|
92
92
|
}
|
|
93
93
|
else {
|
|
94
|
-
index = seek(source, position);
|
|
94
|
+
index = seek(source, position, state);
|
|
95
95
|
}
|
|
96
96
|
if (index === 0) return source.length;
|
|
97
97
|
assert(index > position);
|
|
@@ -121,7 +121,9 @@ export function next(source: string, position: number, delimiter?: RegExp): numb
|
|
|
121
121
|
: index;
|
|
122
122
|
break;
|
|
123
123
|
case '@':
|
|
124
|
-
index =
|
|
124
|
+
index = ~state & State.autolink
|
|
125
|
+
? backToEmailHead(source, position, index)
|
|
126
|
+
: index;
|
|
125
127
|
break;
|
|
126
128
|
}
|
|
127
129
|
assert(index > position);
|
|
@@ -223,15 +225,13 @@ export function isAlphanumeric(char: string): boolean {
|
|
|
223
225
|
// }
|
|
224
226
|
//};
|
|
225
227
|
|
|
226
|
-
function seek(source: string, position: number): number {
|
|
228
|
+
function seek(source: string, position: number, state: number): number {
|
|
227
229
|
for (let i = position + 1; i < source.length; ++i) {
|
|
228
230
|
const fst = source[i];
|
|
229
231
|
//if (fst.charCodeAt(0) in dict) return i;
|
|
230
232
|
switch (fst) {
|
|
231
233
|
case '\\':
|
|
232
234
|
case '!':
|
|
233
|
-
case '@':
|
|
234
|
-
case '#':
|
|
235
235
|
case '$':
|
|
236
236
|
case '"':
|
|
237
237
|
case '`':
|
|
@@ -254,6 +254,10 @@ function seek(source: string, position: number): number {
|
|
|
254
254
|
case '\r':
|
|
255
255
|
case '\n':
|
|
256
256
|
return i;
|
|
257
|
+
case '@':
|
|
258
|
+
case '#':
|
|
259
|
+
if (~state & State.autolink) return i;
|
|
260
|
+
continue;
|
|
257
261
|
case '+':
|
|
258
262
|
case '~':
|
|
259
263
|
case '=':
|
|
@@ -8,7 +8,7 @@ import { html } from 'typed-dom/dom';
|
|
|
8
8
|
export const delimiter = /(?=(?=[\x00-\x7F])[^0-9A-Za-z]|(?<=[\x00-\x7F])[^\x00-\x7F])/g;
|
|
9
9
|
|
|
10
10
|
export const unescsource: UnescapableSourceParser = ({ context }) => {
|
|
11
|
-
const { source, position } = context;
|
|
11
|
+
const { source, position, state } = context;
|
|
12
12
|
if (position === source.length) return;
|
|
13
13
|
const char = source[position];
|
|
14
14
|
consume(1, context);
|
|
@@ -31,7 +31,7 @@ export const unescsource: UnescapableSourceParser = ({ context }) => {
|
|
|
31
31
|
? nonWhitespace.test(source)
|
|
32
32
|
? nonWhitespace.lastIndex - 1
|
|
33
33
|
: source.length
|
|
34
|
-
: next(source, position, delimiter);
|
|
34
|
+
: next(source, position, state, delimiter);
|
|
35
35
|
assert(i > position);
|
|
36
36
|
i -= position;
|
|
37
37
|
consume(i - 1, context);
|
package/src/parser/visibility.ts
CHANGED
|
@@ -22,20 +22,24 @@ export function visualize<N extends HTMLElement | string>(parser: Parser<N>): Pa
|
|
|
22
22
|
parser);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export
|
|
26
|
-
export function blankWith(starts: '
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
`(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
25
|
+
export const afterNonblank = nonblankWith('');
|
|
26
|
+
export function blankWith(starts: '\n', delimiter: string | RegExp): RegExp {
|
|
27
|
+
return new RegExp([
|
|
28
|
+
// 空行除去
|
|
29
|
+
// 完全な空行はエスケープ済みなので再帰的バックトラックにはならない。
|
|
30
|
+
String.raw`(?:${starts}(?:\\?\s|&(?:${invisibleHTMLEntityNames.join('|')});|<wbr ?>)*)?`,
|
|
31
|
+
typeof delimiter === 'string'
|
|
32
|
+
? delimiter.replace(/[*+()\[\]]/g, '\\$&')
|
|
33
|
+
: delimiter.source,
|
|
34
|
+
].join(''), 'y');
|
|
35
|
+
}
|
|
36
|
+
function nonblankWith(delimiter: string | RegExp): RegExp {
|
|
37
|
+
return new RegExp([
|
|
38
|
+
String.raw`(?<!\s|&(?:${invisibleHTMLEntityNames.join('|')});|<wbr ?>)`,
|
|
39
|
+
typeof delimiter === 'string'
|
|
40
|
+
? delimiter.replace(/[*+()\[\]]/g, '\\$&')
|
|
41
|
+
: delimiter.source,
|
|
42
|
+
].join(''), 'y');
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
//export function looseStart<P extends Parser<HTMLElement | string>>(parser: P, except?: string): P;
|