securemark 0.261.2 → 0.262.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/index.js +153 -114
- package/package.json +1 -1
- package/src/combinator/data/parser/context/memo.ts +1 -1
- package/src/combinator/data/parser/inits.ts +1 -1
- package/src/combinator/data/parser/sequence.ts +1 -1
- package/src/parser/api/bind.ts +2 -2
- package/src/parser/api/parse.test.ts +1 -1
- package/src/parser/api/parse.ts +1 -1
- package/src/parser/block/blockquote.test.ts +31 -31
- package/src/parser/block/blockquote.ts +1 -1
- package/src/parser/block/dlist.ts +1 -1
- package/src/parser/block/extension/aside.test.ts +3 -3
- package/src/parser/block/extension/aside.ts +1 -0
- package/src/parser/block/extension/example.test.ts +11 -11
- package/src/parser/block/extension/example.ts +1 -1
- package/src/parser/block/extension/fig.test.ts +5 -5
- package/src/parser/block/extension/figure.test.ts +2 -2
- package/src/parser/block/extension/figure.ts +1 -1
- package/src/parser/block/extension/message.ts +1 -1
- package/src/parser/block/extension/table.ts +1 -1
- package/src/parser/block/olist.ts +1 -1
- package/src/parser/block/reply.ts +1 -1
- package/src/parser/block/table.ts +8 -8
- package/src/parser/block/ulist.ts +1 -1
- package/src/parser/block.ts +1 -1
- package/src/parser/inline/bracket.ts +1 -1
- package/src/parser/inline/comment.ts +1 -1
- package/src/parser/inline/deletion.ts +1 -1
- package/src/parser/inline/emphasis.ts +1 -1
- package/src/parser/inline/extension/indexee.ts +9 -8
- package/src/parser/inline/extension/placeholder.ts +1 -1
- package/src/parser/inline/html.ts +1 -1
- package/src/parser/inline/insertion.ts +1 -1
- package/src/parser/inline/link.ts +1 -1
- package/src/parser/inline/mark.ts +1 -1
- package/src/parser/inline/media.ts +1 -1
- package/src/parser/inline/ruby.ts +1 -1
- package/src/parser/inline/strong.ts +1 -1
- package/src/parser/inline/template.ts +1 -1
- package/src/parser/locale.test.ts +1 -1
- package/src/parser/locale.ts +5 -4
- package/src/parser/processor/figure.test.ts +3 -3
- package/src/parser/processor/figure.ts +8 -7
- package/src/parser/processor/footnote.test.ts +2 -2
- package/src/parser/processor/footnote.ts +15 -11
- package/src/renderer/render.ts +1 -1
- package/src/util/info.ts +7 -5
- package/src/util/quote.ts +14 -12
- package/src/util/toc.ts +14 -8
package/package.json
CHANGED
|
@@ -34,7 +34,7 @@ export class Memo {
|
|
|
34
34
|
}
|
|
35
35
|
public clear(position: number): void {
|
|
36
36
|
const memory = this.memory;
|
|
37
|
-
for (let
|
|
37
|
+
for (let len = memory.length, i = position; i < len; ++i) {
|
|
38
38
|
memory.pop();
|
|
39
39
|
}
|
|
40
40
|
//console.log('clear', position + 1);
|
|
@@ -9,7 +9,7 @@ export function inits<T, D extends Parser<T>[]>(parsers: D, resume?: (nodes: T[]
|
|
|
9
9
|
return ({ source, context }) => {
|
|
10
10
|
let rest = source;
|
|
11
11
|
let nodes: T[] | undefined;
|
|
12
|
-
for (let
|
|
12
|
+
for (let len = parsers.length, i = 0; i < len; ++i) {
|
|
13
13
|
if (rest === '') break;
|
|
14
14
|
if (context.delimiters?.match(rest, context.precedence)) break;
|
|
15
15
|
const result = parsers[i]({ source: rest, context });
|
|
@@ -9,7 +9,7 @@ export function sequence<T, D extends Parser<T>[]>(parsers: D, resume?: (nodes:
|
|
|
9
9
|
return ({ source, context }) => {
|
|
10
10
|
let rest = source;
|
|
11
11
|
let nodes: T[] | undefined;
|
|
12
|
-
for (let
|
|
12
|
+
for (let len = parsers.length, i = 0; i < len; ++i) {
|
|
13
13
|
if (rest === '') return;
|
|
14
14
|
if (context.delimiters?.match(rest, context.precedence)) return;
|
|
15
15
|
const result = parsers[i]({ source: rest, context });
|
package/src/parser/api/bind.ts
CHANGED
|
@@ -144,7 +144,7 @@ export function bind(target: DocumentFragment | HTMLElement | ShadowRoot, settin
|
|
|
144
144
|
|
|
145
145
|
function nearest(index: number): HTMLElement | undefined {
|
|
146
146
|
let el: HTMLElement | undefined;
|
|
147
|
-
for (let
|
|
147
|
+
for (let len = 0, i = 0; i < blocks.length; ++i) {
|
|
148
148
|
const block = blocks[i];
|
|
149
149
|
len += block[0].length;
|
|
150
150
|
el = block[1][0] ?? el;
|
|
@@ -154,7 +154,7 @@ export function bind(target: DocumentFragment | HTMLElement | ShadowRoot, settin
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
function index(source: HTMLElement): number {
|
|
157
|
-
for (let
|
|
157
|
+
for (let len = 0, i = 0; i < blocks.length; ++i) {
|
|
158
158
|
const block = blocks[i];
|
|
159
159
|
if (block[1].includes(source)) return len;
|
|
160
160
|
len += block[0].length;
|
|
@@ -198,7 +198,7 @@ describe('Unit: parser/api/parse', () => {
|
|
|
198
198
|
[
|
|
199
199
|
`<aside class="header"><details open=""><summary>Header</summary><span class="field" data-name="url" data-value="https://example/x"><span class="field-name">URL</span>: <span class="field-value">https://example/x</span>\n</span></details></aside>`,
|
|
200
200
|
'<pre class="invalid" translate="no" data-invalid-syntax="header" data-invalid-type="syntax" data-invalid-message="Invalid syntax">---\nURL: https://example/y\n---\n</pre>',
|
|
201
|
-
'<aside class="example" data-type="markdown"><pre translate="no">---\nURL: https://example/y\n---\n\n{#}</pre><hr><section><aside class="header"><details open=""><summary>Header</summary><span class="field" data-name="url" data-value="https://example/y"><span class="field-name">URL</span>: <span class="field-value">https://example/y</span>\n</span></details></aside><p><a class="url" href="https://example/y#" target="_blank">#</a></p><ol class="references"></ol></section></aside>',
|
|
201
|
+
'<aside class="example" data-type="markdown"><pre translate="no">---\nURL: https://example/y\n---\n\n{#}</pre><hr><section><aside class="header"><details open=""><summary>Header</summary><span class="field" data-name="url" data-value="https://example/y"><span class="field-name">URL</span>: <span class="field-value">https://example/y</span>\n</span></details></aside><p><a class="url" href="https://example/y#" target="_blank">#</a></p><h2>References</h2><ol class="references"></ol></section></aside>',
|
|
202
202
|
'<p><a class="url" href="https://example/x#" target="_blank">#</a></p>',
|
|
203
203
|
]);
|
|
204
204
|
});
|
package/src/parser/api/parse.ts
CHANGED
|
@@ -11,8 +11,8 @@ import { normalize } from './normalize';
|
|
|
11
11
|
import { headers } from './header';
|
|
12
12
|
import { figure } from '../processor/figure';
|
|
13
13
|
import { footnote } from '../processor/footnote';
|
|
14
|
-
import { frag } from 'typed-dom/dom';
|
|
15
14
|
import { ReadonlyURL } from 'spica/url';
|
|
15
|
+
import { frag } from 'typed-dom/dom';
|
|
16
16
|
|
|
17
17
|
interface Options extends ParserOptions {
|
|
18
18
|
readonly test?: boolean;
|
|
@@ -65,38 +65,38 @@ describe('Unit: parser/block/blockquote', () => {
|
|
|
65
65
|
assert.deepStrictEqual(inspect(parser('!')), undefined);
|
|
66
66
|
assert.deepStrictEqual(inspect(parser('!>')), undefined);
|
|
67
67
|
assert.deepStrictEqual(inspect(parser('!> ')), [['<blockquote></blockquote>'], '']);
|
|
68
|
-
assert.deepStrictEqual(inspect(parser('!> \\')), [['<blockquote><section><p>\\</p><ol class="references"></ol></section></blockquote>'], '']);
|
|
69
|
-
assert.deepStrictEqual(inspect(parser('!> \\\n')), [['<blockquote><section><p>\\</p><ol class="references"></ol></section></blockquote>'], '']);
|
|
70
|
-
assert.deepStrictEqual(inspect(parser('!> a')), [['<blockquote><section><p>a</p><ol class="references"></ol></section></blockquote>'], '']);
|
|
71
|
-
assert.deepStrictEqual(inspect(parser('!> a\n')), [['<blockquote><section><p>a</p><ol class="references"></ol></section></blockquote>'], '']);
|
|
72
|
-
assert.deepStrictEqual(inspect(parser('!> a\\\nb')), [['<blockquote><section><p>a<span class="linebreak"> </span>b</p><ol class="references"></ol></section></blockquote>'], '']);
|
|
73
|
-
assert.deepStrictEqual(inspect(parser('!> _a\nb_')), [['<blockquote><section><p><em>a<br>b</em></p><ol class="references"></ol></section></blockquote>'], '']);
|
|
74
|
-
assert.deepStrictEqual(inspect(parser('!> _a\n> b_')), [['<blockquote><section><p><em>a<br>b</em></p><ol class="references"></ol></section></blockquote>'], '']);
|
|
75
|
-
assert.deepStrictEqual(inspect(parser('!> a \n b c ')), [['<blockquote><section><p> a<br> b c</p><ol class="references"></ol></section></blockquote>'], '']);
|
|
76
|
-
assert.deepStrictEqual(inspect(parser('!>> a')), [['<blockquote><blockquote><section><p>a</p><ol class="references"></ol></section></blockquote></blockquote>'], '']);
|
|
77
|
-
assert.deepStrictEqual(inspect(parser('!>> a\n> b')), [['<blockquote><blockquote><section><p>a</p><ol class="references"></ol></section></blockquote><section><p>b</p><ol class="references"></ol></section></blockquote>'], '']);
|
|
78
|
-
assert.deepStrictEqual(inspect(parser('!> - a')), [['<blockquote><section><ul><li>a</li></ul><ol class="references"></ol></section></blockquote>'], '']);
|
|
79
|
-
assert.deepStrictEqual(inspect(parser('!> ```\na\n```')), [['<blockquote><section><pre class="text">a</pre><ol class="references"></ol></section></blockquote>'], '']);
|
|
80
|
-
assert.deepStrictEqual(inspect(parser('!> ```\n> a\n```')), [['<blockquote><section><pre class="text">a</pre><ol class="references"></ol></section></blockquote>'], '']);
|
|
81
|
-
assert.deepStrictEqual(inspect(parser('!> ```\n> a\n> ```')), [['<blockquote><section><pre class="text">a</pre><ol class="references"></ol></section></blockquote>'], '']);
|
|
82
|
-
assert.deepStrictEqual(inspect(parser('!> ```\n> a\n> \n> b\n> ```')), [['<blockquote><section><pre class="text">a<br><br>b</pre><ol class="references"></ol></section></blockquote>'], '']);
|
|
83
|
-
assert.deepStrictEqual(inspect(parser('!> a\n>\n> b')), [['<blockquote><section><p>a</p><p>b</p><ol class="references"></ol></section></blockquote>'], '']);
|
|
84
|
-
assert.deepStrictEqual(inspect(parser('!> > a')), [['<blockquote><section><blockquote><pre>a</pre></blockquote><ol class="references"></ol></section></blockquote>'], '']);
|
|
85
|
-
assert.deepStrictEqual(inspect(parser('!> > a\n> b')), [['<blockquote><section><blockquote><pre>a<br>b</pre></blockquote><ol class="references"></ol></section></blockquote>'], '']);
|
|
86
|
-
assert.deepStrictEqual(inspect(parser('!> > a\n> > b')), [['<blockquote><section><blockquote><pre>a<br>b</pre></blockquote><ol class="references"></ol></section></blockquote>'], '']);
|
|
87
|
-
assert.deepStrictEqual(inspect(parser('!> > a\n>> b')), [['<blockquote><section><blockquote><pre>a</pre></blockquote><ol class="references"></ol></section><blockquote><section><p>b</p><ol class="references"></ol></section></blockquote></blockquote>'], '']);
|
|
88
|
-
assert.deepStrictEqual(inspect(parser('!>> > a\n> b')), [['<blockquote><blockquote><section><blockquote><pre>a</pre></blockquote><ol class="references"></ol></section></blockquote><section><p>b</p><ol class="references"></ol></section></blockquote>'], '']);
|
|
89
|
-
assert.deepStrictEqual(inspect(parser('!> !> a')), [['<blockquote><section><blockquote><section><p>a</p><ol class="references"></ol></section></blockquote><ol class="references"></ol></section></blockquote>'], '']);
|
|
90
|
-
assert.deepStrictEqual(inspect(parser('!> \na')), [['<blockquote><section><p>a</p><ol class="references"></ol></section></blockquote>'], '']);
|
|
68
|
+
assert.deepStrictEqual(inspect(parser('!> \\')), [['<blockquote><section><p>\\</p><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
69
|
+
assert.deepStrictEqual(inspect(parser('!> \\\n')), [['<blockquote><section><p>\\</p><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
70
|
+
assert.deepStrictEqual(inspect(parser('!> a')), [['<blockquote><section><p>a</p><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
71
|
+
assert.deepStrictEqual(inspect(parser('!> a\n')), [['<blockquote><section><p>a</p><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
72
|
+
assert.deepStrictEqual(inspect(parser('!> a\\\nb')), [['<blockquote><section><p>a<span class="linebreak"> </span>b</p><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
73
|
+
assert.deepStrictEqual(inspect(parser('!> _a\nb_')), [['<blockquote><section><p><em>a<br>b</em></p><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
74
|
+
assert.deepStrictEqual(inspect(parser('!> _a\n> b_')), [['<blockquote><section><p><em>a<br>b</em></p><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
75
|
+
assert.deepStrictEqual(inspect(parser('!> a \n b c ')), [['<blockquote><section><p> a<br> b c</p><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
76
|
+
assert.deepStrictEqual(inspect(parser('!>> a')), [['<blockquote><blockquote><section><p>a</p><h2>References</h2><ol class="references"></ol></section></blockquote></blockquote>'], '']);
|
|
77
|
+
assert.deepStrictEqual(inspect(parser('!>> a\n> b')), [['<blockquote><blockquote><section><p>a</p><h2>References</h2><ol class="references"></ol></section></blockquote><section><p>b</p><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
78
|
+
assert.deepStrictEqual(inspect(parser('!> - a')), [['<blockquote><section><ul><li>a</li></ul><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
79
|
+
assert.deepStrictEqual(inspect(parser('!> ```\na\n```')), [['<blockquote><section><pre class="text">a</pre><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
80
|
+
assert.deepStrictEqual(inspect(parser('!> ```\n> a\n```')), [['<blockquote><section><pre class="text">a</pre><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
81
|
+
assert.deepStrictEqual(inspect(parser('!> ```\n> a\n> ```')), [['<blockquote><section><pre class="text">a</pre><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
82
|
+
assert.deepStrictEqual(inspect(parser('!> ```\n> a\n> \n> b\n> ```')), [['<blockquote><section><pre class="text">a<br><br>b</pre><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
83
|
+
assert.deepStrictEqual(inspect(parser('!> a\n>\n> b')), [['<blockquote><section><p>a</p><p>b</p><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
84
|
+
assert.deepStrictEqual(inspect(parser('!> > a')), [['<blockquote><section><blockquote><pre>a</pre></blockquote><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
85
|
+
assert.deepStrictEqual(inspect(parser('!> > a\n> b')), [['<blockquote><section><blockquote><pre>a<br>b</pre></blockquote><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
86
|
+
assert.deepStrictEqual(inspect(parser('!> > a\n> > b')), [['<blockquote><section><blockquote><pre>a<br>b</pre></blockquote><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
87
|
+
assert.deepStrictEqual(inspect(parser('!> > a\n>> b')), [['<blockquote><section><blockquote><pre>a</pre></blockquote><h2>References</h2><ol class="references"></ol></section><blockquote><section><p>b</p><h2>References</h2><ol class="references"></ol></section></blockquote></blockquote>'], '']);
|
|
88
|
+
assert.deepStrictEqual(inspect(parser('!>> > a\n> b')), [['<blockquote><blockquote><section><blockquote><pre>a</pre></blockquote><h2>References</h2><ol class="references"></ol></section></blockquote><section><p>b</p><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
89
|
+
assert.deepStrictEqual(inspect(parser('!> !> a')), [['<blockquote><section><blockquote><section><p>a</p><h2>References</h2><ol class="references"></ol></section></blockquote><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
90
|
+
assert.deepStrictEqual(inspect(parser('!> \na')), [['<blockquote><section><p>a</p><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
91
91
|
assert.deepStrictEqual(inspect(parser('!>\n')), undefined);
|
|
92
|
-
assert.deepStrictEqual(inspect(parser('!>\na')), [['<blockquote><section><p>a</p><ol class="references"></ol></section></blockquote>'], '']);
|
|
93
|
-
assert.deepStrictEqual(inspect(parser('!>\n a')), [['<blockquote><section><p> a</p><ol class="references"></ol></section></blockquote>'], '']);
|
|
94
|
-
assert.deepStrictEqual(inspect(parser('!>\n>')), [['<blockquote><section><ol class="references"></ol></section></blockquote>'], '']);
|
|
95
|
-
assert.deepStrictEqual(inspect(parser('!>\n> a')), [['<blockquote><section><p>a</p><ol class="references"></ol></section></blockquote>'], '']);
|
|
96
|
-
assert.deepStrictEqual(inspect(parser('!>> ## a\n> ## a')), [['<blockquote><blockquote><section><h2>a</h2><ol class="references"></ol></section></blockquote><section><h2>a</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
97
|
-
assert.deepStrictEqual(inspect(parser('!>> ~ a\n> ~ a')), [['<blockquote><blockquote><section><dl><dt>a</dt><dd></dd></dl><ol class="references"></ol></section></blockquote><section><dl><dt>a</dt><dd></dd></dl><ol class="references"></ol></section></blockquote>'], '']);
|
|
98
|
-
assert.deepStrictEqual(inspect(parser('!>> ~~~figure $test-a\n>> > \n>>\n~~~\n> ~~~figure $test-a\n> > \n>\n[#a]\n~~~')), [['<blockquote><blockquote><section><figure data-type="quote" data-label="test-a" data-group="test" data-number="1"><figcaption><span class="figindex">Test 1. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure><ol class="references"></ol></section></blockquote><section><figure data-type="quote" data-label="test-a" data-group="test" data-number="1"><figcaption><span class="figindex">Test 1. </span><span class="figtext"><a class="index">a</a></span></figcaption><div><blockquote></blockquote></div></figure><ol class="references"></ol></section></blockquote>'], '']);
|
|
99
|
-
assert.deepStrictEqual(inspect(parser('!>> ((a))\n> ((a))')), [['<blockquote><blockquote><section><p><sup class="annotation disabled" title="a"><span hidden="">a</span><a>*1</a></sup></p><ol class="annotations"><li data-marker="*1">a<sup><a>^1</a></sup></li></ol><ol class="references"></ol></section></blockquote><section><p><sup class="annotation disabled" title="a"><span hidden="">a</span><a>*1</a></sup></p><ol class="annotations"><li data-marker="*1">a<sup><a>^1</a></sup></li></ol><ol class="references"></ol></section></blockquote>'], '']);
|
|
92
|
+
assert.deepStrictEqual(inspect(parser('!>\na')), [['<blockquote><section><p>a</p><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
93
|
+
assert.deepStrictEqual(inspect(parser('!>\n a')), [['<blockquote><section><p> a</p><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
94
|
+
assert.deepStrictEqual(inspect(parser('!>\n>')), [['<blockquote><section><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
95
|
+
assert.deepStrictEqual(inspect(parser('!>\n> a')), [['<blockquote><section><p>a</p><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
96
|
+
assert.deepStrictEqual(inspect(parser('!>> ## a\n> ## a')), [['<blockquote><blockquote><section><h2>a</h2><h2>References</h2><ol class="references"></ol></section></blockquote><section><h2>a</h2><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
97
|
+
assert.deepStrictEqual(inspect(parser('!>> ~ a\n> ~ a')), [['<blockquote><blockquote><section><dl><dt>a</dt><dd></dd></dl><h2>References</h2><ol class="references"></ol></section></blockquote><section><dl><dt>a</dt><dd></dd></dl><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
98
|
+
assert.deepStrictEqual(inspect(parser('!>> ~~~figure $test-a\n>> > \n>>\n~~~\n> ~~~figure $test-a\n> > \n>\n[#a]\n~~~')), [['<blockquote><blockquote><section><figure data-type="quote" data-label="test-a" data-group="test" data-number="1"><figcaption><span class="figindex">Test 1. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure><h2>References</h2><ol class="references"></ol></section></blockquote><section><figure data-type="quote" data-label="test-a" data-group="test" data-number="1"><figcaption><span class="figindex">Test 1. </span><span class="figtext"><a class="index">a</a></span></figcaption><div><blockquote></blockquote></div></figure><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
99
|
+
assert.deepStrictEqual(inspect(parser('!>> ((a))\n> ((a))')), [['<blockquote><blockquote><section><p><sup class="annotation disabled" title="a"><span hidden="">a</span><a>*1</a></sup></p><ol class="annotations"><li data-marker="*1">a<sup><a>^1</a></sup></li></ol><h2>References</h2><ol class="references"></ol></section></blockquote><section><p><sup class="annotation disabled" title="a"><span hidden="">a</span><a>*1</a></sup></p><ol class="annotations"><li data-marker="*1">a<sup><a>^1</a></sup></li></ol><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
});
|
|
@@ -45,7 +45,7 @@ const markdown: BlockquoteParser.MarkdownParser = lazy(() => fmap(
|
|
|
45
45
|
references,
|
|
46
46
|
},
|
|
47
47
|
}, context);
|
|
48
|
-
return [[html('section', [document, references])], ''];
|
|
48
|
+
return [[html('section', [document, html('h2', 'References'), references])], ''];
|
|
49
49
|
}))),
|
|
50
50
|
]))),
|
|
51
51
|
ns => [html('blockquote', ns)]));
|
|
@@ -5,8 +5,8 @@ import { anyline } from '../source';
|
|
|
5
5
|
import { State } from '../context';
|
|
6
6
|
import { localize } from '../locale';
|
|
7
7
|
import { visualize, trimBlank } from '../visibility';
|
|
8
|
-
import { html, defrag } from 'typed-dom/dom';
|
|
9
8
|
import { push } from 'spica/array';
|
|
9
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
10
10
|
|
|
11
11
|
export const dlist: DListParser = lazy(() => block(localize(fmap(validate(
|
|
12
12
|
/^~[^\S\n]+(?=\S)/,
|
|
@@ -14,9 +14,9 @@ describe('Unit: parser/block/extension/aside', () => {
|
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
it('valid', () => {
|
|
17
|
-
assert.deepStrictEqual(inspect(parser('~~~aside\n# 0\n~~~')), [['<aside id="index:0" class="aside"><h1>0</h1><ol class="references"></ol></aside>'], '']);
|
|
18
|
-
assert.deepStrictEqual(inspect(parser('~~~aside\n## 0\n~~~')), [['<aside id="index:0" class="aside"><h2>0</h2><ol class="references"></ol></aside>'], '']);
|
|
19
|
-
assert.deepStrictEqual(inspect(parser('~~~aside\n# 0\n\n$-0.0\n\n## 1\n\n$test-a\n> \n~~~')), [['<aside id="index:0" class="aside"><h1>0</h1><figure data-label="$-0.0" data-group="$" hidden="" data-number="0.0"></figure><h2>1</h2><figure data-type="quote" data-label="test-a" data-group="test" data-number="1.1"><figcaption><span class="figindex">Test 1.1. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure><ol class="references"></ol></aside>'], '']);
|
|
17
|
+
assert.deepStrictEqual(inspect(parser('~~~aside\n# 0\n~~~')), [['<aside id="index:0" class="aside"><h1>0</h1><h2>References</h2><ol class="references"></ol></aside>'], '']);
|
|
18
|
+
assert.deepStrictEqual(inspect(parser('~~~aside\n## 0\n~~~')), [['<aside id="index:0" class="aside"><h2>0</h2><h2>References</h2><ol class="references"></ol></aside>'], '']);
|
|
19
|
+
assert.deepStrictEqual(inspect(parser('~~~aside\n# 0\n\n$-0.0\n\n## 1\n\n$test-a\n> \n~~~')), [['<aside id="index:0" class="aside"><h1>0</h1><figure data-label="$-0.0" data-group="$" hidden="" data-number="0.0"></figure><h2>1</h2><figure data-type="quote" data-label="test-a" data-group="test" data-number="1.1"><figcaption><span class="figindex">Test 1.1. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure><h2>References</h2><ol class="references"></ol></aside>'], '']);
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
});
|
|
@@ -14,17 +14,17 @@ describe('Unit: parser/block/extension/example', () => {
|
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
it('valid', () => {
|
|
17
|
-
assert.deepStrictEqual(inspect(parser('~~~\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no"></pre><hr><section><ol class="references"></ol></section></aside>'], '']);
|
|
18
|
-
assert.deepStrictEqual(inspect(parser('~~~example/markdown\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no"></pre><hr><section><ol class="references"></ol></section></aside>'], '']);
|
|
19
|
-
assert.deepStrictEqual(inspect(parser('~~~example/markdown\n\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no"></pre><hr><section><ol class="references"></ol></section></aside>'], '']);
|
|
20
|
-
assert.deepStrictEqual(inspect(parser('~~~example/markdown\na\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">a</pre><hr><section><p>a</p><ol class="references"></ol></section></aside>'], '']);
|
|
21
|
-
assert.deepStrictEqual(inspect(parser('~~~example/markdown\n_a\nb_\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">_a\nb_</pre><hr><section><p><em>a<br>b</em></p><ol class="references"></ol></section></aside>'], '']);
|
|
22
|
-
assert.deepStrictEqual(inspect(parser('~~~example/markdown\n$fig-a\n!https://host\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">$fig-a\n!https://host</pre><hr><section><figure data-type="media" data-label="fig-a" data-group="fig" data-number="1"><figcaption><span class="figindex">Fig. 1. </span><span class="figtext"></span></figcaption><div><a href="https://host" target="_blank"><img class="media" data-src="https://host" alt=""></a></div></figure><ol class="references"></ol></section></aside>'], '']);
|
|
23
|
-
assert.deepStrictEqual(inspect(parser('~~~example/markdown\n[$fig-a]\n!https://host\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">[$fig-a]\n!https://host</pre><hr><section><figure data-type="media" data-label="fig-a" data-group="fig" data-number="1"><figcaption><span class="figindex">Fig. 1. </span><span class="figtext"></span></figcaption><div><a href="https://host" target="_blank"><img class="media" data-src="https://host" alt=""></a></div></figure><ol class="references"></ol></section></aside>'], '']);
|
|
24
|
-
assert.deepStrictEqual(inspect(parser('~~~example/markdown\n## a\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">## a</pre><hr><section><h2>a</h2><ol class="references"></ol></section></aside>'], '']);
|
|
25
|
-
assert.deepStrictEqual(inspect(parser('~~~example/markdown\n~ a\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">~ a</pre><hr><section><dl><dt>a</dt><dd></dd></dl><ol class="references"></ol></section></aside>'], '']);
|
|
26
|
-
assert.deepStrictEqual(inspect(parser('~~~example/markdown\n((a))[[b]]\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">((a))[[b]]</pre><hr><section><p><sup class="annotation disabled" title="a"><span hidden="">a</span><a>*1</a></sup><sup class="reference disabled" title="b"><span hidden="">b</span><a>[1]</a></sup></p><ol class="annotations"><li data-marker="*1">a<sup><a>^1</a></sup></li></ol><ol class="references"><li>b<sup><a>^1</a></sup></li></ol></section></aside>'], '']);
|
|
27
|
-
assert.deepStrictEqual(inspect(parser('~~~~example/markdown\na\n~~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">a</pre><hr><section><p>a</p><ol class="references"></ol></section></aside>'], '']);
|
|
17
|
+
assert.deepStrictEqual(inspect(parser('~~~\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no"></pre><hr><section><h2>References</h2><ol class="references"></ol></section></aside>'], '']);
|
|
18
|
+
assert.deepStrictEqual(inspect(parser('~~~example/markdown\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no"></pre><hr><section><h2>References</h2><ol class="references"></ol></section></aside>'], '']);
|
|
19
|
+
assert.deepStrictEqual(inspect(parser('~~~example/markdown\n\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no"></pre><hr><section><h2>References</h2><ol class="references"></ol></section></aside>'], '']);
|
|
20
|
+
assert.deepStrictEqual(inspect(parser('~~~example/markdown\na\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">a</pre><hr><section><p>a</p><h2>References</h2><ol class="references"></ol></section></aside>'], '']);
|
|
21
|
+
assert.deepStrictEqual(inspect(parser('~~~example/markdown\n_a\nb_\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">_a\nb_</pre><hr><section><p><em>a<br>b</em></p><h2>References</h2><ol class="references"></ol></section></aside>'], '']);
|
|
22
|
+
assert.deepStrictEqual(inspect(parser('~~~example/markdown\n$fig-a\n!https://host\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">$fig-a\n!https://host</pre><hr><section><figure data-type="media" data-label="fig-a" data-group="fig" data-number="1"><figcaption><span class="figindex">Fig. 1. </span><span class="figtext"></span></figcaption><div><a href="https://host" target="_blank"><img class="media" data-src="https://host" alt=""></a></div></figure><h2>References</h2><ol class="references"></ol></section></aside>'], '']);
|
|
23
|
+
assert.deepStrictEqual(inspect(parser('~~~example/markdown\n[$fig-a]\n!https://host\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">[$fig-a]\n!https://host</pre><hr><section><figure data-type="media" data-label="fig-a" data-group="fig" data-number="1"><figcaption><span class="figindex">Fig. 1. </span><span class="figtext"></span></figcaption><div><a href="https://host" target="_blank"><img class="media" data-src="https://host" alt=""></a></div></figure><h2>References</h2><ol class="references"></ol></section></aside>'], '']);
|
|
24
|
+
assert.deepStrictEqual(inspect(parser('~~~example/markdown\n## a\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">## a</pre><hr><section><h2>a</h2><h2>References</h2><ol class="references"></ol></section></aside>'], '']);
|
|
25
|
+
assert.deepStrictEqual(inspect(parser('~~~example/markdown\n~ a\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">~ a</pre><hr><section><dl><dt>a</dt><dd></dd></dl><h2>References</h2><ol class="references"></ol></section></aside>'], '']);
|
|
26
|
+
assert.deepStrictEqual(inspect(parser('~~~example/markdown\n((a))[[b]]\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">((a))[[b]]</pre><hr><section><p><sup class="annotation disabled" title="a"><span hidden="">a</span><a>*1</a></sup><sup class="reference disabled" title="b"><span hidden="">b</span><a>[1]</a></sup></p><ol class="annotations"><li data-marker="*1">a<sup><a>^1</a></sup></li></ol><h2>References</h2><ol class="references"><li>b<sup><a>^1</a></sup></li></ol></section></aside>'], '']);
|
|
27
|
+
assert.deepStrictEqual(inspect(parser('~~~~example/markdown\na\n~~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">a</pre><hr><section><p>a</p><h2>References</h2><ol class="references"></ol></section></aside>'], '']);
|
|
28
28
|
assert.deepStrictEqual(inspect(parser('~~~example/math\na\n~~~')), [['<aside class="example" data-type="math"><pre translate="no">a</pre><hr><div class="math" translate="no">$$\na\n$$</div></aside>'], '']);
|
|
29
29
|
assert.deepStrictEqual(inspect(parser(`~~~example/math\n0${'\n'.repeat(100)}~~~`), '>'), [['<aside class="example" data-type="math">'], '']);
|
|
30
30
|
});
|
|
@@ -35,7 +35,7 @@ export const example: ExtensionParser.ExampleParser = block(validate('~~~', fmap
|
|
|
35
35
|
html('aside', { class: 'example', 'data-type': 'markdown' }, [
|
|
36
36
|
html('pre', { translate: 'no' }, body.slice(0, -1)),
|
|
37
37
|
html('hr'),
|
|
38
|
-
html('section', [document, references]),
|
|
38
|
+
html('section', [document, html('h2', 'References'), references]),
|
|
39
39
|
]),
|
|
40
40
|
];
|
|
41
41
|
}
|
|
@@ -31,16 +31,16 @@ describe('Unit: parser/block/extension/fig', () => {
|
|
|
31
31
|
assert.deepStrictEqual(inspect(parser('[$group-name]\n```\n~~~\n```')), [['<figure data-type="text" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><pre class="text">~~~</pre></div></figure>'], '']);
|
|
32
32
|
assert.deepStrictEqual(inspect(parser('[$group-name]\n$$\n\n$$')), [['<figure data-type="math" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><div class="math" translate="no">$$\n\n$$</div></div></figure>'], '']);
|
|
33
33
|
assert.deepStrictEqual(inspect(parser('[$group-name]\n$$\n\n$$\n')), [['<figure data-type="math" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><div class="math" translate="no">$$\n\n$$</div></div></figure>'], '']);
|
|
34
|
-
assert.deepStrictEqual(inspect(parser('[$group-name]\n~~~\n~~~')), [['<figure data-type="example" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><aside class="example" data-type="markdown"><pre translate="no"></pre><hr><section><ol class="references"></ol></section></aside></div></figure>'], '']);
|
|
35
|
-
assert.deepStrictEqual(inspect(parser('[$group-name]\n~~~\n~~~\n')), [['<figure data-type="example" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><aside class="example" data-type="markdown"><pre translate="no"></pre><hr><section><ol class="references"></ol></section></aside></div></figure>'], '']);
|
|
36
|
-
assert.deepStrictEqual(inspect(parser('[$group-name]\n~~~example/markdown\n~~~')), [['<figure data-type="example" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><aside class="example" data-type="markdown"><pre translate="no"></pre><hr><section><ol class="references"></ol></section></aside></div></figure>'], '']);
|
|
37
|
-
assert.deepStrictEqual(inspect(parser('[$group-name]\n~~~example/markdown\n~~~\n')), [['<figure data-type="example" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><aside class="example" data-type="markdown"><pre translate="no"></pre><hr><section><ol class="references"></ol></section></aside></div></figure>'], '']);
|
|
34
|
+
assert.deepStrictEqual(inspect(parser('[$group-name]\n~~~\n~~~')), [['<figure data-type="example" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><aside class="example" data-type="markdown"><pre translate="no"></pre><hr><section><h2>References</h2><ol class="references"></ol></section></aside></div></figure>'], '']);
|
|
35
|
+
assert.deepStrictEqual(inspect(parser('[$group-name]\n~~~\n~~~\n')), [['<figure data-type="example" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><aside class="example" data-type="markdown"><pre translate="no"></pre><hr><section><h2>References</h2><ol class="references"></ol></section></aside></div></figure>'], '']);
|
|
36
|
+
assert.deepStrictEqual(inspect(parser('[$group-name]\n~~~example/markdown\n~~~')), [['<figure data-type="example" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><aside class="example" data-type="markdown"><pre translate="no"></pre><hr><section><h2>References</h2><ol class="references"></ol></section></aside></div></figure>'], '']);
|
|
37
|
+
assert.deepStrictEqual(inspect(parser('[$group-name]\n~~~example/markdown\n~~~\n')), [['<figure data-type="example" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><aside class="example" data-type="markdown"><pre translate="no"></pre><hr><section><h2>References</h2><ol class="references"></ol></section></aside></div></figure>'], '']);
|
|
38
38
|
assert.deepStrictEqual(inspect(parser('[$group-name]\n~~~table\n~~~')), [['<figure data-type="table" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><table></table></div></figure>'], '']);
|
|
39
39
|
assert.deepStrictEqual(inspect(parser('[$group-name]\n~~~table\n~~~\n')), [['<figure data-type="table" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><table></table></div></figure>'], '']);
|
|
40
40
|
assert.deepStrictEqual(inspect(parser('[$group-name]\n> ')), [['<figure data-type="quote" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>'], '']);
|
|
41
41
|
assert.deepStrictEqual(inspect(parser('[$group-name]\n> \n')), [['<figure data-type="quote" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>'], '']);
|
|
42
42
|
assert.deepStrictEqual(inspect(parser('[$group-name]\n>\n~~~')), [['<figure data-type="quote" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><blockquote><pre><br>~~~</pre></blockquote></div></figure>'], '']);
|
|
43
|
-
assert.deepStrictEqual(inspect(parser('[$group-name]\n!> _a_')), [['<figure data-type="quote" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><blockquote><section><p><em>a</em></p><ol class="references"></ol></section></blockquote></div></figure>'], '']);
|
|
43
|
+
assert.deepStrictEqual(inspect(parser('[$group-name]\n!> _a_')), [['<figure data-type="quote" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><blockquote><section><p><em>a</em></p><h2>References</h2><ol class="references"></ol></section></blockquote></div></figure>'], '']);
|
|
44
44
|
assert.deepStrictEqual(inspect(parser('[$group-name]\n![]{https://host}')), [['<figure data-type="media" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><a href="https://host" target="_blank"><img class="media" data-src="https://host" alt=""></a></div></figure>'], '']);
|
|
45
45
|
assert.deepStrictEqual(inspect(parser('[$group-name]\n![]{https://host}\n')), [['<figure data-type="media" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><a href="https://host" target="_blank"><img class="media" data-src="https://host" alt=""></a></div></figure>'], '']);
|
|
46
46
|
assert.deepStrictEqual(inspect(parser('$group-name\n!https://host')), [['<figure data-type="media" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><a href="https://host" target="_blank"><img class="media" data-src="https://host" alt=""></a></div></figure>'], '']);
|
|
@@ -53,8 +53,8 @@ describe('Unit: parser/block/extension/figure', () => {
|
|
|
53
53
|
assert.deepStrictEqual(inspect(parser('~~~figure [$group-name]\n$$\n\n$$\n~~~')), [['<figure data-type="math" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><div class="math" translate="no">$$\n\n$$</div></div></figure>'], '']);
|
|
54
54
|
assert.deepStrictEqual(inspect(parser('~~~figure [$group-name]\n$$\n~~~\n$$\n~~~')), [['<figure data-type="math" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><div class="math" translate="no">$$\n~~~\n$$</div></div></figure>'], '']);
|
|
55
55
|
assert.deepStrictEqual(inspect(parser('~~~figure [$group-name]\n$$\n\n$$\n\ncaption\n~~~')), [['<figure data-type="math" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext">caption</span></figcaption><div><div class="math" translate="no">$$\n\n$$</div></div></figure>'], '']);
|
|
56
|
-
assert.deepStrictEqual(inspect(parser('~~~figure [$group-name]\n~~~\n~~~\n\ncaption\n~~~')), [['<figure data-type="example" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext">caption</span></figcaption><div><aside class="example" data-type="markdown"><pre translate="no"></pre><hr><section><ol class="references"></ol></section></aside></div></figure>'], '']);
|
|
57
|
-
assert.deepStrictEqual(inspect(parser('~~~figure [$group-name]\n~~~example/markdown\n~~~\n\ncaption\n~~~')), [['<figure data-type="example" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext">caption</span></figcaption><div><aside class="example" data-type="markdown"><pre translate="no"></pre><hr><section><ol class="references"></ol></section></aside></div></figure>'], '']);
|
|
56
|
+
assert.deepStrictEqual(inspect(parser('~~~figure [$group-name]\n~~~\n~~~\n\ncaption\n~~~')), [['<figure data-type="example" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext">caption</span></figcaption><div><aside class="example" data-type="markdown"><pre translate="no"></pre><hr><section><h2>References</h2><ol class="references"></ol></section></aside></div></figure>'], '']);
|
|
57
|
+
assert.deepStrictEqual(inspect(parser('~~~figure [$group-name]\n~~~example/markdown\n~~~\n\ncaption\n~~~')), [['<figure data-type="example" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext">caption</span></figcaption><div><aside class="example" data-type="markdown"><pre translate="no"></pre><hr><section><h2>References</h2><ol class="references"></ol></section></aside></div></figure>'], '']);
|
|
58
58
|
assert.deepStrictEqual(inspect(parser('~~~figure [$group-name]\n~~~table\n~~~\n\ncaption\n~~~')), [['<figure data-type="table" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext">caption</span></figcaption><div><table></table></div></figure>'], '']);
|
|
59
59
|
assert.deepStrictEqual(inspect(parser('~~~figure [$group-name]\n> \n~~~\n\n~~~')), [['<figure data-type="quote" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><blockquote><pre><br>~~~</pre></blockquote></div></figure>'], '']);
|
|
60
60
|
assert.deepStrictEqual(inspect(parser('~~~figure [$group-name]\n> \n~~~\n\ncaption\n~~~')), [['<figure data-type="quote" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext">caption</span></figcaption><div><blockquote><pre><br>~~~</pre></blockquote></div></figure>'], '']);
|
|
@@ -16,8 +16,8 @@ import { inline, media, shortmedia } from '../../inline';
|
|
|
16
16
|
import { State } from '../../context';
|
|
17
17
|
import { localize } from '../../locale';
|
|
18
18
|
import { visualize, trimBlank } from '../../visibility';
|
|
19
|
-
import { html, defrag } from 'typed-dom/dom';
|
|
20
19
|
import { memoize } from 'spica/memoize';
|
|
20
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
21
21
|
|
|
22
22
|
import FigureParser = ExtensionParser.FigureParser;
|
|
23
23
|
|
|
@@ -12,8 +12,8 @@ import { mathblock } from '../mathblock';
|
|
|
12
12
|
import { sidefence } from '../sidefence';
|
|
13
13
|
import { blockquote } from '../blockquote';
|
|
14
14
|
import { paragraph } from '../paragraph';
|
|
15
|
-
import { html } from 'typed-dom/dom';
|
|
16
15
|
import { unshift, push } from 'spica/array';
|
|
16
|
+
import { html } from 'typed-dom/dom';
|
|
17
17
|
|
|
18
18
|
import MessageParser = ExtensionParser.MessageParser;
|
|
19
19
|
|
|
@@ -7,8 +7,8 @@ import { inline } from '../../inline';
|
|
|
7
7
|
import { str, anyline, emptyline, contentline } from '../../source';
|
|
8
8
|
import { localize } from '../../locale';
|
|
9
9
|
import { visualize } from '../../visibility';
|
|
10
|
-
import { html, define, defrag } from 'typed-dom/dom';
|
|
11
10
|
import { unshift, splice } from 'spica/array';
|
|
11
|
+
import { html, define, defrag } from 'typed-dom/dom';
|
|
12
12
|
|
|
13
13
|
import TableParser = ExtensionParser.TableParser;
|
|
14
14
|
import RowParser = TableParser.RowParser;
|
|
@@ -8,9 +8,9 @@ import { inline, indexee, indexer } from '../inline';
|
|
|
8
8
|
import { contentline } from '../source';
|
|
9
9
|
import { State } from '../context';
|
|
10
10
|
import { trimBlank } from '../visibility';
|
|
11
|
-
import { html, define, defrag } from 'typed-dom/dom';
|
|
12
11
|
import { memoize } from 'spica/memoize';
|
|
13
12
|
import { shift } from 'spica/array';
|
|
13
|
+
import { html, define, defrag } from 'typed-dom/dom';
|
|
14
14
|
|
|
15
15
|
const openers = {
|
|
16
16
|
'.': /^([0-9]+|[a-z]+|[A-Z]+)(?:-(?!-)[0-9]*)*(?![^\S\n])\.?(?:$|\s)/,
|
|
@@ -6,8 +6,8 @@ import { inline } from '../inline';
|
|
|
6
6
|
import { anyline } from '../source';
|
|
7
7
|
import { localize } from '../locale';
|
|
8
8
|
import { visualize } from '../visibility';
|
|
9
|
-
import { html, defrag } from 'typed-dom/dom';
|
|
10
9
|
import { push, pop } from 'spica/array';
|
|
10
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
11
11
|
|
|
12
12
|
/*
|
|
13
13
|
必ず対象指定から始まる
|
|
@@ -3,9 +3,9 @@ import { union, sequence, some, creation, block, line, validate, focus, rewrite,
|
|
|
3
3
|
import { inline } from '../inline';
|
|
4
4
|
import { contentline } from '../source';
|
|
5
5
|
import { trimNode } from '../visibility';
|
|
6
|
-
import {
|
|
7
|
-
import { duffEach, duffReduce } from 'spica/duff';
|
|
6
|
+
import { duffReduce } from 'spica/duff';
|
|
8
7
|
import { push } from 'spica/array';
|
|
8
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
9
9
|
|
|
10
10
|
import RowParser = TableParser.RowParser;
|
|
11
11
|
import AlignParser = TableParser.AlignParser;
|
|
@@ -65,13 +65,13 @@ function format(rows: HTMLTableRowElement[]): HTMLTableRowElement[] {
|
|
|
65
65
|
? []
|
|
66
66
|
: duffReduce(rows.shift()!.children, (acc, el) => push(acc, [el.textContent!]), [] as string[]);
|
|
67
67
|
for (let i = 0; i < rows.length; ++i) {
|
|
68
|
-
|
|
69
|
-
if (
|
|
70
|
-
aligns[
|
|
68
|
+
for (let cols = rows[i].children, len = cols.length, j = 0; j < len; ++j) {
|
|
69
|
+
if (j > 0 && !aligns[j]) {
|
|
70
|
+
aligns[j] = aligns[j - 1];
|
|
71
71
|
}
|
|
72
|
-
if (!aligns[
|
|
73
|
-
|
|
74
|
-
}
|
|
72
|
+
if (!aligns[j]) continue;
|
|
73
|
+
cols[j].setAttribute('align', aligns[j]);
|
|
74
|
+
}
|
|
75
75
|
}
|
|
76
76
|
return rows;
|
|
77
77
|
}
|
|
@@ -5,8 +5,8 @@ import { ilist_ } from './ilist';
|
|
|
5
5
|
import { inline, indexer, indexee } from '../inline';
|
|
6
6
|
import { State } from '../context';
|
|
7
7
|
import { trimBlank } from '../visibility';
|
|
8
|
-
import { html, defrag } from 'typed-dom/dom';
|
|
9
8
|
import { unshift } from 'spica/array';
|
|
9
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
10
10
|
|
|
11
11
|
export const ulist: UListParser = lazy(() => block(validate(
|
|
12
12
|
/^-(?=[^\S\n]|\n[^\S\n]*\S)/,
|
package/src/parser/block.ts
CHANGED
|
@@ -16,8 +16,8 @@ import { sidefence } from './block/sidefence';
|
|
|
16
16
|
import { blockquote } from './block/blockquote';
|
|
17
17
|
import { reply } from './block/reply';
|
|
18
18
|
import { paragraph } from './block/paragraph';
|
|
19
|
-
import { html } from 'typed-dom/dom';
|
|
20
19
|
import { rnd0Z } from 'spica/random';
|
|
20
|
+
import { html } from 'typed-dom/dom';
|
|
21
21
|
|
|
22
22
|
export import BlockParser = MarkdownParser.BlockParser;
|
|
23
23
|
export import HorizontalRuleParser = BlockParser.HorizontalRuleParser;
|
|
@@ -4,8 +4,8 @@ import { union, some, syntax, surround, lazy } from '../../combinator';
|
|
|
4
4
|
import { inline } from '../inline';
|
|
5
5
|
import { str } from '../source';
|
|
6
6
|
import { Syntax, State } from '../context';
|
|
7
|
-
import { html, defrag } from 'typed-dom/dom';
|
|
8
7
|
import { unshift, push } from 'spica/array';
|
|
8
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
9
9
|
|
|
10
10
|
const index = /^[0-9A-Za-z]+(?:(?:[.-]|, )[0-9A-Za-z]+)*/;
|
|
11
11
|
|
|
@@ -3,9 +3,9 @@ import { union, some, syntax, validate, surround, open, close, match, lazy } fro
|
|
|
3
3
|
import { inline } from '../inline';
|
|
4
4
|
import { text, str } from '../source';
|
|
5
5
|
import { Syntax, State } from '../context';
|
|
6
|
-
import { html, defrag } from 'typed-dom/dom';
|
|
7
6
|
import { memoize } from 'spica/memoize';
|
|
8
7
|
import { unshift, push } from 'spica/array';
|
|
8
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
9
9
|
|
|
10
10
|
export const comment: CommentParser = lazy(() => validate('[%', syntax(Syntax.none, 4, 1, State.none, match(
|
|
11
11
|
/^\[(%+)\s/,
|
|
@@ -4,8 +4,8 @@ import { inline } from '../inline';
|
|
|
4
4
|
import { str } from '../source';
|
|
5
5
|
import { Syntax, State } from '../context';
|
|
6
6
|
import { blankWith } from '../visibility';
|
|
7
|
-
import { html, defrag } from 'typed-dom/dom';
|
|
8
7
|
import { unshift } from 'spica/array';
|
|
8
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
9
9
|
|
|
10
10
|
export const deletion: DeletionParser = lazy(() => surround(
|
|
11
11
|
str('~~', '~'),
|
|
@@ -4,8 +4,8 @@ import { inline } from '../inline';
|
|
|
4
4
|
import { str } from '../source';
|
|
5
5
|
import { Syntax, State } from '../context';
|
|
6
6
|
import { startTight, blankWith } from '../visibility';
|
|
7
|
-
import { html, defrag } from 'typed-dom/dom';
|
|
8
7
|
import { unshift } from 'spica/array';
|
|
8
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
9
9
|
|
|
10
10
|
export const emphasis: EmphasisParser = lazy(() => surround(
|
|
11
11
|
str('_', '_'),
|
|
@@ -3,7 +3,7 @@ import { MarkdownParser } from '../../../../markdown';
|
|
|
3
3
|
import { Parser } from '../../../combinator/data/parser';
|
|
4
4
|
import { fmap } from '../../../combinator';
|
|
5
5
|
import { define } from 'typed-dom/dom';
|
|
6
|
-
import {
|
|
6
|
+
import { querySelectorAll } from 'typed-dom/query';
|
|
7
7
|
|
|
8
8
|
export function indexee<P extends Parser<unknown, MarkdownParser.Context>>(parser: P, optional?: boolean): P;
|
|
9
9
|
export function indexee(parser: Parser<HTMLElement, MarkdownParser.Context>, optional?: boolean): Parser<HTMLElement> {
|
|
@@ -28,32 +28,33 @@ export function text(source: HTMLElement | DocumentFragment, optional = false):
|
|
|
28
28
|
if (index) return index;
|
|
29
29
|
assert(!source.querySelector('.annotation, br'));
|
|
30
30
|
const target = source.cloneNode(true) as typeof source;
|
|
31
|
-
|
|
31
|
+
for (let es = querySelectorAll(target, 'code[data-src], .math[data-src], .comment, rt, rp, .reference, .checkbox, ul, ol'), i = 0; i < es.length; ++i) {
|
|
32
|
+
const el = es[i];
|
|
32
33
|
switch (el.tagName) {
|
|
33
34
|
case 'CODE':
|
|
34
35
|
define(el, el.getAttribute('data-src')!);
|
|
35
|
-
|
|
36
|
+
continue;
|
|
36
37
|
case 'RT':
|
|
37
38
|
case 'RP':
|
|
38
39
|
case 'UL':
|
|
39
40
|
case 'OL':
|
|
40
41
|
el.remove();
|
|
41
|
-
|
|
42
|
+
continue;
|
|
42
43
|
}
|
|
43
44
|
switch (el.className) {
|
|
44
45
|
case 'math':
|
|
45
46
|
define(el, el.getAttribute('data-src')!);
|
|
46
|
-
|
|
47
|
+
continue;
|
|
47
48
|
case 'comment':
|
|
48
49
|
case 'checkbox':
|
|
49
50
|
el.remove();
|
|
50
|
-
|
|
51
|
+
continue;
|
|
51
52
|
case 'reference':
|
|
52
53
|
assert(el.firstElementChild?.hasAttribute('hidden'));
|
|
53
54
|
el.firstChild!.remove();
|
|
54
|
-
|
|
55
|
+
continue;
|
|
55
56
|
}
|
|
56
|
-
}
|
|
57
|
+
}
|
|
57
58
|
// Better:
|
|
58
59
|
//return target.innerText;
|
|
59
60
|
return target.textContent!;
|
|
@@ -4,8 +4,8 @@ import { inline } from '../../inline';
|
|
|
4
4
|
import { str } from '../../source';
|
|
5
5
|
import { Syntax, State } from '../../context';
|
|
6
6
|
import { startTight } from '../../visibility';
|
|
7
|
-
import { html, defrag } from 'typed-dom/dom';
|
|
8
7
|
import { unshift } from 'spica/array';
|
|
8
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
9
9
|
|
|
10
10
|
// Don't use the symbols already used: !#$%@&*+~=
|
|
11
11
|
|