securemark 0.268.2 → 0.269.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 +8 -0
- package/dist/index.js +45 -35
- package/markdown.d.ts +59 -41
- package/package.json +6 -6
- package/src/parser/api/bind.test.ts +3 -3
- package/src/parser/api/parse.test.ts +3 -3
- package/src/parser/autolink.test.ts +2 -2
- package/src/parser/autolink.ts +5 -12
- package/src/parser/block/blockquote.test.ts +1 -1
- package/src/parser/block/extension/example.test.ts +1 -1
- package/src/parser/block/paragraph.test.ts +4 -2
- package/src/parser/block/paragraph.ts +3 -2
- package/src/parser/block/reply/quote.test.ts +2 -2
- package/src/parser/block/reply/quote.ts +8 -12
- package/src/parser/inline/autolink/url.test.ts +2 -0
- package/src/parser/inline/autolink/url.ts +13 -2
- package/src/parser/inline/autolink.ts +33 -30
- package/src/parser/inline/extension/indexee.ts +3 -2
- package/src/parser/inline/extension/placeholder.test.ts +1 -1
- package/src/parser/inline/link.ts +8 -3
- package/src/parser/inline/media.ts +6 -1
- package/src/parser/inline/shortmedia.ts +12 -3
- package/src/parser/inline.test.ts +6 -9
- package/src/parser/inline.ts +8 -7
- package/src/parser/processor/footnote.test.ts +17 -17
- package/src/parser/processor/footnote.ts +6 -5
- package/src/parser/source/escapable.ts +5 -1
- package/src/parser/source/text.ts +5 -1
- package/src/parser/source/unescapable.ts +7 -1
- package/src/parser/util.ts +0 -10
- package/src/parser/visibility.ts +1 -2
- package/src/util/quote.test.ts +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { text } from '../inline/extension/indexee';
|
|
1
|
+
import { identity, text } from '../inline/extension/indexee';
|
|
2
2
|
import { frag, html, define } from 'typed-dom/dom';
|
|
3
3
|
|
|
4
4
|
export function* footnote(
|
|
@@ -44,13 +44,15 @@ function build(
|
|
|
44
44
|
}
|
|
45
45
|
const refs = target.querySelectorAll(`sup.${syntax}:not(.disabled)`);
|
|
46
46
|
const titles = new Map<string, string>();
|
|
47
|
-
const contents = new Map<string,
|
|
47
|
+
const contents = new Map<string, HTMLSpanElement>();
|
|
48
48
|
for (let len = refs.length, i = 0; i < len; ++i) {
|
|
49
49
|
if (i % 10 === 9) yield;
|
|
50
50
|
const ref = refs[i];
|
|
51
51
|
const identifier = ref.getAttribute('data-abbr') || ` ${ref.firstElementChild!.innerHTML}`;
|
|
52
52
|
if (titles.has(identifier)) continue;
|
|
53
|
-
const content =
|
|
53
|
+
const content = html('span',
|
|
54
|
+
{ id: identity(opts.id, text(ref.firstElementChild!), 'note') },
|
|
55
|
+
ref.firstElementChild!.cloneNode(true).childNodes);
|
|
54
56
|
const title = text(content).trim();
|
|
55
57
|
if (!title) continue;
|
|
56
58
|
titles.set(identifier, title);
|
|
@@ -100,7 +102,6 @@ function build(
|
|
|
100
102
|
const title = titles.get(identifier);
|
|
101
103
|
assert(title !== '');
|
|
102
104
|
assert(syntax !== 'annotation' || title);
|
|
103
|
-
const content = frag(ref.firstElementChild!.cloneNode(true).childNodes);
|
|
104
105
|
const refIndex = ++count;
|
|
105
106
|
const refId = opts.id !== ''
|
|
106
107
|
? `${syntax}:${opts.id ?? ''}:ref:${refIndex}`
|
|
@@ -134,7 +135,7 @@ function build(
|
|
|
134
135
|
html('a',
|
|
135
136
|
{
|
|
136
137
|
href: refId && `#${refId}`,
|
|
137
|
-
title: abbr && text(
|
|
138
|
+
title: abbr && text(frag(ref.firstElementChild!.cloneNode(true).childNodes)).trim() || undefined,
|
|
138
139
|
},
|
|
139
140
|
`^${refIndex}`));
|
|
140
141
|
}
|
|
@@ -4,7 +4,7 @@ import { nonWhitespace } from './text';
|
|
|
4
4
|
|
|
5
5
|
const delimiter = /[\s\x00-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]/;
|
|
6
6
|
|
|
7
|
-
export const escsource: EscapableSourceParser = creation(1, false, ({ source }) => {
|
|
7
|
+
export const escsource: EscapableSourceParser = creation(1, false, ({ source, context }) => {
|
|
8
8
|
if (source === '') return;
|
|
9
9
|
const i = source.search(delimiter);
|
|
10
10
|
switch (i) {
|
|
@@ -12,6 +12,10 @@ export const escsource: EscapableSourceParser = creation(1, false, ({ source })
|
|
|
12
12
|
return [[source], ''];
|
|
13
13
|
case 0:
|
|
14
14
|
switch (source[0]) {
|
|
15
|
+
case '\r':
|
|
16
|
+
assert(!source.includes('\r', 1));
|
|
17
|
+
context.resources && ++context.resources.clock;
|
|
18
|
+
return [[], source.slice(1)];
|
|
15
19
|
case '\x1B':
|
|
16
20
|
return [[source.slice(1, 2)], source.slice(2)];
|
|
17
21
|
case '\\':
|
|
@@ -16,6 +16,10 @@ export const text: TextParser = creation(1, false, ({ source, context }) => {
|
|
|
16
16
|
return [[source], ''];
|
|
17
17
|
case 0:
|
|
18
18
|
switch (source[0]) {
|
|
19
|
+
case '\r':
|
|
20
|
+
assert(!source.includes('\r', 1));
|
|
21
|
+
context.resources && ++context.resources.clock;
|
|
22
|
+
return [[], source.slice(1)];
|
|
19
23
|
case '\x1B':
|
|
20
24
|
case '\\':
|
|
21
25
|
switch (source[1]) {
|
|
@@ -60,7 +64,7 @@ export const txt: TxtParser = union([
|
|
|
60
64
|
text,
|
|
61
65
|
]) as TxtParser;
|
|
62
66
|
|
|
63
|
-
export const linebreak: LinebreakParser = focus(
|
|
67
|
+
export const linebreak: LinebreakParser = focus(/^[\r\n]/, union([
|
|
64
68
|
text,
|
|
65
69
|
])) as LinebreakParser;
|
|
66
70
|
|
|
@@ -2,7 +2,7 @@ import { UnescapableSourceParser } from '../source';
|
|
|
2
2
|
import { creation } from '../../combinator';
|
|
3
3
|
import { delimiter, nonWhitespace, nonAlphanumeric, isAlphanumeric } from './text';
|
|
4
4
|
|
|
5
|
-
export const unescsource: UnescapableSourceParser = creation(1, false, ({ source }) => {
|
|
5
|
+
export const unescsource: UnescapableSourceParser = creation(1, false, ({ source, context }) => {
|
|
6
6
|
assert(source[0] !== '\x1B');
|
|
7
7
|
if (source === '') return;
|
|
8
8
|
const i = source.search(delimiter);
|
|
@@ -10,6 +10,12 @@ export const unescsource: UnescapableSourceParser = creation(1, false, ({ source
|
|
|
10
10
|
case -1:
|
|
11
11
|
return [[source], ''];
|
|
12
12
|
case 0: {
|
|
13
|
+
switch (source[0]) {
|
|
14
|
+
case '\r':
|
|
15
|
+
assert(!source.includes('\r', 1));
|
|
16
|
+
context.resources && ++context.resources.clock;
|
|
17
|
+
return [[], source.slice(1)];
|
|
18
|
+
}
|
|
13
19
|
const b = source[0] !== '\n' && source[0].trimStart() === '';
|
|
14
20
|
const i = b || isAlphanumeric(source[0])
|
|
15
21
|
? source.search(b ? nonWhitespace : nonAlphanumeric) || 1
|
package/src/parser/util.ts
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
import { Parser } from '../combinator/data/parser';
|
|
2
|
-
import { convert } from '../combinator';
|
|
3
|
-
|
|
4
|
-
export function format<P extends Parser<HTMLElement | string>>(parser: P): P;
|
|
5
|
-
export function format<T extends HTMLElement | string>(parser: Parser<T>): Parser<T> {
|
|
6
|
-
return convert(
|
|
7
|
-
source => source.replace(/(?<=^!?)https?:\/\/(?:[[]|[^\p{C}\p{S}\p{P}\s])\S*(?=[^\S\n]*(?:$|\n))/gm, '{ $& }'),
|
|
8
|
-
parser);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
1
|
export function stringify(nodes: readonly (HTMLElement | string)[]): string {
|
|
12
2
|
let acc = '';
|
|
13
3
|
for (let i = 0; i < nodes.length; ++i) {
|
package/src/parser/visibility.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { union, some, verify, convert, fmap } from '../combinator';
|
|
|
4
4
|
import { unsafehtmlentity } from './inline/htmlentity';
|
|
5
5
|
import { linebreak, unescsource } from './source';
|
|
6
6
|
import { State } from './context';
|
|
7
|
-
import { format } from './util';
|
|
8
7
|
import { invisibleHTMLEntityNames } from './api/normalize';
|
|
9
8
|
import { reduce } from 'spica/memoize';
|
|
10
9
|
import { push } from 'spica/array';
|
|
@@ -17,7 +16,7 @@ export function visualize<T extends HTMLElement | string>(parser: Parser<T>): Pa
|
|
|
17
16
|
return union([
|
|
18
17
|
convert(
|
|
19
18
|
source => source.replace(blankline, line => line.replace(/[\\&<]/g, '\x1B$&')),
|
|
20
|
-
verify(
|
|
19
|
+
verify(parser, (ns, rest, context) => !rest && hasVisible(ns, context))),
|
|
21
20
|
some(union([linebreak, unescsource])),
|
|
22
21
|
]);
|
|
23
22
|
}
|
package/src/util/quote.test.ts
CHANGED
|
@@ -5,10 +5,10 @@ describe('Unit: util/quote', () => {
|
|
|
5
5
|
describe('quote', () => {
|
|
6
6
|
it('basic', () => {
|
|
7
7
|
const range = document.createRange();
|
|
8
|
-
const el = parse('>>1\n>2\n> a\n>>4 `b` ${c}
|
|
8
|
+
const el = parse('>>1\n>2\n> a\n>>4 `b` ${c}$\n!{d}\n [e](f) ').firstElementChild!;
|
|
9
9
|
range.setStart(el.firstChild!.firstChild!, 0);
|
|
10
10
|
range.setEnd(el.lastChild!.lastChild!.lastChild!, 1);
|
|
11
|
-
assert(quote('3', range) === `>>>1\n> >2\n>> a\n>>3\n> >>4 \`b\` \${c}
|
|
11
|
+
assert(quote('3', range) === `>>>1\n> >2\n>> a\n>>3\n> >>4 \`b\` \${c}$\n> !{d}\n> e`);
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
it('adjustment', () => {
|