securemark 0.232.2 → 0.233.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 +4 -0
- package/dist/securemark.js +45 -80
- package/markdown.d.ts +13 -22
- package/package-lock.json +37 -37
- package/package.json +1 -1
- package/src/parser/api/parse.test.ts +6 -6
- package/src/parser/block/extension/aside.ts +3 -3
- package/src/parser/block/extension/table.ts +3 -3
- package/src/parser/block/paragraph.test.ts +7 -6
- package/src/parser/block/reply/cite.ts +1 -1
- package/src/parser/inline/annotation.test.ts +0 -2
- package/src/parser/inline/comment.test.ts +39 -38
- package/src/parser/inline/comment.ts +21 -28
- package/src/parser/inline/deletion.test.ts +0 -1
- package/src/parser/inline/emphasis.test.ts +0 -3
- package/src/parser/inline/extension/index.test.ts +4 -3
- package/src/parser/inline/extension/index.ts +2 -2
- package/src/parser/inline/extension/indexee.ts +21 -19
- package/src/parser/inline/extension/placeholder.test.ts +7 -7
- package/src/parser/inline/insertion.test.ts +0 -1
- package/src/parser/inline/link.test.ts +0 -1
- package/src/parser/inline/mark.test.ts +0 -3
- package/src/parser/inline/reference.test.ts +17 -19
- package/src/parser/inline/reference.ts +1 -1
- package/src/parser/inline/strong.test.ts +0 -3
- package/src/parser/inline.ts +3 -3
- package/src/parser/util.ts +2 -17
- package/src/parser/util.test.ts +0 -14
package/src/parser/inline.ts
CHANGED
|
@@ -4,11 +4,11 @@ import { escape } from './inline/escape';
|
|
|
4
4
|
import { annotation } from './inline/annotation';
|
|
5
5
|
import { reference } from './inline/reference';
|
|
6
6
|
import { template } from './inline/template';
|
|
7
|
+
import { comment } from './inline/comment';
|
|
7
8
|
import { extension } from './inline/extension';
|
|
8
9
|
import { ruby } from './inline/ruby';
|
|
9
10
|
import { link } from './inline/link';
|
|
10
11
|
import { html } from './inline/html';
|
|
11
|
-
import { comment } from './inline/comment';
|
|
12
12
|
import { insertion } from './inline/insertion';
|
|
13
13
|
import { deletion } from './inline/deletion';
|
|
14
14
|
import { mark } from './inline/mark';
|
|
@@ -29,11 +29,11 @@ export import EscapeParser = InlineParser.EscapeParser;
|
|
|
29
29
|
export import AnnotationParser = InlineParser.AnnotationParser;
|
|
30
30
|
export import ReferenceParser = InlineParser.ReferenceParser;
|
|
31
31
|
export import TemplateParser = InlineParser.TemplateParser;
|
|
32
|
+
export import CommentParser = InlineParser.CommentParser;
|
|
32
33
|
export import ExtensionParser = InlineParser.ExtensionParser;
|
|
33
34
|
export import RubyParser = InlineParser.RubyParser;
|
|
34
35
|
export import LinkParser = InlineParser.LinkParser;
|
|
35
36
|
export import HTMLParser = InlineParser.HTMLParser;
|
|
36
|
-
export import CommentParser = InlineParser.CommentParser;
|
|
37
37
|
export import InsertionParser = InlineParser.InsertionParser;
|
|
38
38
|
export import DeletionParser = InlineParser.DeletionParser;
|
|
39
39
|
export import MarkParser = InlineParser.MarkParser;
|
|
@@ -54,12 +54,12 @@ export const inline: InlineParser = union([
|
|
|
54
54
|
annotation,
|
|
55
55
|
reference,
|
|
56
56
|
template,
|
|
57
|
+
comment,
|
|
57
58
|
extension,
|
|
58
59
|
ruby,
|
|
59
60
|
link,
|
|
60
61
|
media,
|
|
61
62
|
html,
|
|
62
|
-
comment,
|
|
63
63
|
insertion,
|
|
64
64
|
deletion,
|
|
65
65
|
mark,
|
package/src/parser/util.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { undefined } from 'spica/global';
|
|
|
2
2
|
import { MarkdownParser } from '../../markdown';
|
|
3
3
|
import { Parser, eval } from '../combinator/data/parser';
|
|
4
4
|
import { union, some, verify, convert } from '../combinator';
|
|
5
|
-
import { comment } from './inline/comment';
|
|
6
5
|
import { unsafehtmlentity } from './inline/htmlentity';
|
|
7
6
|
import { linebreak, unescsource } from './source';
|
|
8
7
|
import { push, pop } from 'spica/array';
|
|
@@ -42,13 +41,13 @@ const invisibleHTMLEntityNames = [
|
|
|
42
41
|
'InvisibleComma',
|
|
43
42
|
'ic',
|
|
44
43
|
];
|
|
45
|
-
const blankline = new RegExp(String.raw`^(?!$)(?:\\$|\\?[^\S\n]|&(?:${invisibleHTMLEntityNames.join('|')});|<wbr
|
|
44
|
+
const blankline = new RegExp(String.raw`^(?!$)(?:\\$|\\?[^\S\n]|&(?:${invisibleHTMLEntityNames.join('|')});|<wbr>)+$`, 'gm');
|
|
46
45
|
|
|
47
46
|
export function visualize<P extends Parser<HTMLElement | string>>(parser: P): P;
|
|
48
47
|
export function visualize<T extends HTMLElement | string>(parser: Parser<T>): Parser<T> {
|
|
49
48
|
return union([
|
|
50
49
|
convert(
|
|
51
|
-
source => source.replace(blankline,
|
|
50
|
+
source => source.replace(blankline, line => line.replace(/[\\&<]/g, '\x1B$&')),
|
|
52
51
|
verify(parser, (ns, rest, context) => !rest && hasVisible(ns, context))),
|
|
53
52
|
some(union([linebreak, unescsource])),
|
|
54
53
|
]);
|
|
@@ -117,15 +116,6 @@ function isStartTight(source: string, context: MarkdownParser.Context): boolean
|
|
|
117
116
|
return false;
|
|
118
117
|
}
|
|
119
118
|
return true;
|
|
120
|
-
case '[':
|
|
121
|
-
switch (true) {
|
|
122
|
-
case source.length >= 7
|
|
123
|
-
&& source[1] === '#'
|
|
124
|
-
&& eval(comment(source, context))?.[0].className === 'comment':
|
|
125
|
-
assert(!eval(comment(source, context))?.[0].matches('.invalid'));
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
return true;
|
|
129
119
|
default:
|
|
130
120
|
return source[0].trimStart() !== '';
|
|
131
121
|
}
|
|
@@ -138,7 +128,6 @@ export function isEndTightNodes(nodes: readonly (HTMLElement | string)[]): boole
|
|
|
138
128
|
if (nodes.length === 0) return true;
|
|
139
129
|
for (let i = nodes.length; i--;) {
|
|
140
130
|
const node = nodes[i];
|
|
141
|
-
if (typeof node === 'object' && node.className === 'comment') continue;
|
|
142
131
|
return isVisible(node, -1);
|
|
143
132
|
}
|
|
144
133
|
return false;
|
|
@@ -165,8 +154,6 @@ function isVisible(node: HTMLElement | string, strpos?: number): boolean {
|
|
|
165
154
|
return false;
|
|
166
155
|
case 'SPAN':
|
|
167
156
|
return node.className !== 'linebreak';
|
|
168
|
-
case 'SUP':
|
|
169
|
-
return node.className !== 'comment';
|
|
170
157
|
default:
|
|
171
158
|
return true;
|
|
172
159
|
}
|
|
@@ -179,7 +166,6 @@ export function trimNode(nodes: (HTMLElement | string)[]): (HTMLElement | string
|
|
|
179
166
|
function trimNodeStart(nodes: (HTMLElement | string)[]): (HTMLElement | string)[] {
|
|
180
167
|
for (let node = nodes[0]; nodes.length > 0 && !isVisible(node = nodes[0], 0);) {
|
|
181
168
|
if (nodes.length === 1 && typeof node === 'object' && node.className === 'indexer') break;
|
|
182
|
-
if (typeof node === 'object' && node.className === 'comment') break;
|
|
183
169
|
if (typeof node === 'string') {
|
|
184
170
|
const pos = node.length - node.trimStart().length;
|
|
185
171
|
if (pos > 0) {
|
|
@@ -198,7 +184,6 @@ export function trimNodeEnd(nodes: (HTMLElement | string)[]): (HTMLElement | str
|
|
|
198
184
|
? [nodes.pop()!]
|
|
199
185
|
: [];
|
|
200
186
|
for (let node = nodes[0]; nodes.length > 0 && !isVisible(node = nodes[nodes.length - 1], -1);) {
|
|
201
|
-
if (typeof node === 'object' && node.className === 'comment') break;
|
|
202
187
|
if (typeof node === 'string') {
|
|
203
188
|
const pos = node.trimEnd().length;
|
|
204
189
|
if (pos > 0) {
|
package/src/parser/util.test.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { visualize } from './util';
|
|
2
|
-
|
|
3
|
-
describe('Unit: parser/util', () => {
|
|
4
|
-
describe('visualize', () => {
|
|
5
|
-
it('stress', () => {
|
|
6
|
-
visualize(s => [[s], ''])(`[# ${'a'.repeat(100000 - 6)} #]`);
|
|
7
|
-
visualize(s => [[s], ''])(`[# ${'a\n'.repeat(100000 / 2 - 6 / 2)} #]`);
|
|
8
|
-
visualize(s => [[s], ''])(`[# a${' '.repeat(100000 - 6)} #`);
|
|
9
|
-
visualize(s => [[s], ''])(`${'[# '.repeat(100000 - 2)}a #]`);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
});
|