securemark 0.261.0 → 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 +12 -0
- package/dist/index.js +1117 -646
- package/markdown.d.ts +0 -11
- package/package.json +9 -9
- 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/debug.test.ts +3 -3
- 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 +5 -7
- 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 +2 -2
- package/src/parser/inline/emphasis.ts +3 -3
- 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 +2 -2
- package/src/parser/inline/link.ts +1 -1
- package/src/parser/inline/mark.ts +2 -2
- package/src/parser/inline/media.ts +1 -1
- package/src/parser/inline/ruby.ts +1 -1
- package/src/parser/inline/strong.ts +3 -3
- package/src/parser/inline/template.ts +1 -1
- package/src/parser/inline.ts +0 -3
- package/src/parser/locale/ja.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 +10 -8
- package/src/parser/processor/footnote.test.ts +2 -2
- package/src/parser/processor/footnote.ts +17 -12
- package/src/parser/source/str.ts +4 -2
- package/src/parser/source/text.ts +2 -2
- package/src/renderer/render.ts +3 -3
- package/src/util/info.ts +7 -5
- package/src/util/quote.ts +14 -12
- package/src/util/toc.ts +14 -8
- package/src/parser/inline/escape.ts +0 -21
package/markdown.d.ts
CHANGED
|
@@ -621,7 +621,6 @@ export namespace MarkdownParser {
|
|
|
621
621
|
export interface InlineParser extends
|
|
622
622
|
Markdown<'inline'>,
|
|
623
623
|
Parser<HTMLElement | string, Context, [
|
|
624
|
-
InlineParser.EscapeParser,
|
|
625
624
|
InlineParser.AnnotationParser,
|
|
626
625
|
InlineParser.ReferenceParser,
|
|
627
626
|
InlineParser.TemplateParser,
|
|
@@ -647,16 +646,6 @@ export namespace MarkdownParser {
|
|
|
647
646
|
}
|
|
648
647
|
export namespace InlineParser {
|
|
649
648
|
interface Inline<T extends string> extends Markdown<`inline/${T}`> { }
|
|
650
|
-
export interface EscapeParser extends
|
|
651
|
-
// ****
|
|
652
|
-
// +++
|
|
653
|
-
// ~~~
|
|
654
|
-
// ===
|
|
655
|
-
Inline<'escape'>,
|
|
656
|
-
Parser<string, Context, [
|
|
657
|
-
SourceParser.StrParser,
|
|
658
|
-
]> {
|
|
659
|
-
}
|
|
660
649
|
export interface AnnotationParser extends
|
|
661
650
|
// ((abc))
|
|
662
651
|
Inline<'annotation'>,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "securemark",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.262.0",
|
|
4
4
|
"description": "Secure markdown renderer working on browsers for user input data.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://github.com/falsandtru/securemark",
|
|
@@ -28,17 +28,17 @@
|
|
|
28
28
|
"LICENSE"
|
|
29
29
|
],
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@types/dompurify": "2.3.
|
|
31
|
+
"@types/dompurify": "2.3.4",
|
|
32
32
|
"@types/jquery": "3.5.14",
|
|
33
33
|
"@types/mathjax": "0.0.37",
|
|
34
34
|
"@types/mocha": "9.1.1",
|
|
35
35
|
"@types/power-assert": "1.5.8",
|
|
36
36
|
"@types/prismjs": "1.26.0",
|
|
37
|
-
"@typescript-eslint/parser": "^5.
|
|
37
|
+
"@typescript-eslint/parser": "^5.36.2",
|
|
38
38
|
"babel-loader": "^8.2.5",
|
|
39
39
|
"babel-plugin-unassert": "^3.2.0",
|
|
40
|
-
"concurrently": "^7.
|
|
41
|
-
"eslint": "^8.
|
|
40
|
+
"concurrently": "^7.4.0",
|
|
41
|
+
"eslint": "^8.23.0",
|
|
42
42
|
"eslint-plugin-redos": "^4.4.1",
|
|
43
43
|
"eslint-webpack-plugin": "^3.2.0",
|
|
44
44
|
"glob": "^8.0.3",
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
"karma-mocha": "^2.0.1",
|
|
50
50
|
"karma-power-assert": "^1.0.0",
|
|
51
51
|
"mocha": "^10.0.0",
|
|
52
|
-
"npm-check-updates": "^16.
|
|
52
|
+
"npm-check-updates": "^16.1.1",
|
|
53
53
|
"semver": "^7.3.7",
|
|
54
|
-
"spica": "0.0.
|
|
54
|
+
"spica": "0.0.622",
|
|
55
55
|
"ts-loader": "^9.3.1",
|
|
56
|
-
"typed-dom": "^0.0.
|
|
57
|
-
"typescript": "4.
|
|
56
|
+
"typed-dom": "^0.0.305",
|
|
57
|
+
"typescript": "4.8.3",
|
|
58
58
|
"webpack": "^5.74.0",
|
|
59
59
|
"webpack-cli": "^4.10.0",
|
|
60
60
|
"webpack-merge": "^5.8.0"
|
|
@@ -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/debug.test.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Result, eval, exec } from './combinator/data/parser';
|
|
2
2
|
import { html, define } from 'typed-dom/dom';
|
|
3
|
-
import {
|
|
3
|
+
import { querySelectorWith, querySelectorAllWith } from 'typed-dom/query';
|
|
4
4
|
|
|
5
5
|
export function inspect(result: Result<HTMLElement | string>, until: number | string = Infinity): Result<string> {
|
|
6
6
|
return result && [
|
|
@@ -8,8 +8,8 @@ export function inspect(result: Result<HTMLElement | string>, until: number | st
|
|
|
8
8
|
assert(node || node === '' && '([{'.includes(nodes[i + 1][0]));
|
|
9
9
|
if (typeof node === 'string') return node;
|
|
10
10
|
node = node.cloneNode(true);
|
|
11
|
-
assert(!
|
|
12
|
-
|
|
11
|
+
assert(!querySelectorWith(node, '.invalid[data-invalid-message$="."]'));
|
|
12
|
+
querySelectorAllWith(node, '.invalid').forEach(el => {
|
|
13
13
|
assert(el.matches('[data-invalid-syntax][data-invalid-type][data-invalid-message]'));
|
|
14
14
|
define(el, {
|
|
15
15
|
'data-invalid-syntax': null,
|
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,10 +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
|
-
import { duffbk } from 'spica/duff';
|
|
14
12
|
import { shift } from 'spica/array';
|
|
13
|
+
import { html, define, defrag } from 'typed-dom/dom';
|
|
15
14
|
|
|
16
15
|
const openers = {
|
|
17
16
|
'.': /^([0-9]+|[a-z]+|[A-Z]+)(?:-(?!-)[0-9]*)*(?![^\S\n])\.?(?:$|\s)/,
|
|
@@ -124,16 +123,15 @@ function format(el: HTMLOListElement, type: string, form: string): HTMLOListElem
|
|
|
124
123
|
'data-type': style(type) || undefined,
|
|
125
124
|
});
|
|
126
125
|
const marker = el.firstElementChild?.getAttribute('data-marker')!.match(initial(type))?.[0] ?? '';
|
|
127
|
-
|
|
128
|
-
duffbk(es.length, i => {
|
|
126
|
+
for (let es = el.children, len = es.length, i = 0; i < len; ++i) {
|
|
129
127
|
const el = es[i];
|
|
130
128
|
switch (el.getAttribute('data-marker')) {
|
|
131
129
|
case '':
|
|
132
130
|
case marker:
|
|
133
131
|
el.removeAttribute('data-marker');
|
|
134
|
-
|
|
132
|
+
continue;
|
|
135
133
|
}
|
|
136
|
-
|
|
137
|
-
}
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
138
136
|
return el;
|
|
139
137
|
}
|
|
@@ -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
|
|