securemark 0.235.0 → 0.235.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/securemark.js +93 -84
  3. package/package-lock.json +19 -19
  4. package/package.json +1 -1
  5. package/src/combinator/control/manipulation/context.test.ts +4 -4
  6. package/src/combinator/control/manipulation/resource.ts +6 -3
  7. package/src/combinator/control/manipulation/surround.ts +3 -4
  8. package/src/combinator/data/parser/inits.ts +1 -1
  9. package/src/combinator/data/parser/sequence.ts +1 -1
  10. package/src/combinator/data/parser/some.ts +23 -25
  11. package/src/combinator/data/parser.ts +33 -10
  12. package/src/parser/api/bind.test.ts +3 -3
  13. package/src/parser/api/parse.test.ts +12 -5
  14. package/src/parser/block/blockquote.test.ts +1 -1
  15. package/src/parser/block/extension/aside.test.ts +1 -1
  16. package/src/parser/block/extension/example.test.ts +2 -2
  17. package/src/parser/block/extension/fig.test.ts +20 -20
  18. package/src/parser/block/extension/figure.test.ts +31 -28
  19. package/src/parser/block/extension/figure.ts +4 -2
  20. package/src/parser/block/extension/table.ts +6 -6
  21. package/src/parser/block.ts +1 -2
  22. package/src/parser/inline/bracket.ts +3 -3
  23. package/src/parser/inline/emphasis.ts +2 -5
  24. package/src/parser/inline/emstrong.ts +4 -5
  25. package/src/parser/inline/html.ts +3 -3
  26. package/src/parser/inline/mark.ts +2 -5
  27. package/src/parser/inline/strong.test.ts +1 -1
  28. package/src/parser/inline/strong.ts +2 -5
  29. package/src/parser/inline.test.ts +0 -1
  30. package/src/parser/processor/figure.test.ts +28 -28
  31. package/src/parser/processor/figure.ts +1 -1
  32. package/src/parser/util.ts +5 -7
@@ -3,7 +3,7 @@ import { union, some, creator, surround, open, lazy } from '../../combinator';
3
3
  import { inline } from '../inline';
4
4
  import { strong } from './strong';
5
5
  import { str } from '../source';
6
- import { startTight, isEndTightNodes, delimiter } from '../util';
6
+ import { startTight, delimiter } from '../util';
7
7
  import { html, defrag } from 'typed-dom';
8
8
  import { unshift } from 'spica/array';
9
9
 
@@ -15,8 +15,5 @@ export const emphasis: EmphasisParser = lazy(() => creator(surround(
15
15
  open(some(inline, '*'), inline),
16
16
  ])), '*'),
17
17
  str('*'), false,
18
- ([as, bs, cs], rest) =>
19
- isEndTightNodes(bs)
20
- ? [[html('em', defrag(bs))], rest]
21
- : [unshift(as, bs), cs[0] + rest],
18
+ ([, bs], rest) => [[html('em', defrag(bs))], rest],
22
19
  ([as, bs], rest) => [unshift(as, bs), rest])));
@@ -5,7 +5,7 @@ import { union, some, creator, surround, open, lazy, bind } from '../../combinat
5
5
  import { inline } from '../inline';
6
6
  import { strong } from './strong';
7
7
  import { str } from '../source';
8
- import { startTight, isEndTightNodes, delimiter } from '../util';
8
+ import { startTight, delimiter } from '../util';
9
9
  import { html, defrag } from 'typed-dom';
10
10
  import { unshift } from 'spica/array';
11
11
 
@@ -26,9 +26,8 @@ export const emstrong: EmStrongParser = lazy(() => creator(surround(
26
26
  open(some(inline, '*'), inline),
27
27
  ]))),
28
28
  str(/^\*{1,3}/), false,
29
- ([as, bs, cs], rest, context): Result<HTMLElement | string, MarkdownParser.Context> => {
29
+ ([, bs, cs], rest, context): Result<HTMLElement | string, MarkdownParser.Context> => {
30
30
  assert(cs.length === 1);
31
- if (!isEndTightNodes(bs)) return [unshift(as, bs), cs[0] + rest];
32
31
  switch (cs[0]) {
33
32
  case '***':
34
33
  return [[html('em', [html('strong', defrag(bs))])], rest];
@@ -36,7 +35,7 @@ export const emstrong: EmStrongParser = lazy(() => creator(surround(
36
35
  return bind<EmphasisParser>(
37
36
  subemphasis,
38
37
  (ds, rest) =>
39
- rest.slice(0, 1) === '*' && isEndTightNodes(ds)
38
+ rest.slice(0, 1) === '*'
40
39
  ? [[html('em', unshift([html('strong', defrag(bs))], defrag(ds)))], rest.slice(1)]
41
40
  : [unshift(['*', html('strong', defrag(bs))], ds), rest])
42
41
  (rest, context) ?? [['*', html('strong', defrag(bs))], rest];
@@ -44,7 +43,7 @@ export const emstrong: EmStrongParser = lazy(() => creator(surround(
44
43
  return bind<StrongParser>(
45
44
  substrong,
46
45
  (ds, rest) =>
47
- rest.slice(0, 2) === '**' && isEndTightNodes(ds)
46
+ rest.slice(0, 2) === '**'
48
47
  ? [[html('strong', unshift([html('em', defrag(bs))], defrag(ds)))], rest.slice(2)]
49
48
  : [unshift(['**', html('em', defrag(bs))], ds), rest])
50
49
  (rest, context) ?? [['**', html('em', defrag(bs))], rest];
@@ -87,8 +87,10 @@ export const attribute: HTMLParser.TagParser.AttributeParser = union([
87
87
  str(/^[^\S\n]+[a-z]+(?:-[a-z]+)*(?:="(?:\\[^\n]|[^\\\n"])*")?(?=[^\S\n]|>)/),
88
88
  ]);
89
89
 
90
- function elem(tag: string, as: (HTMLElement | string)[], bs: (HTMLElement | string)[], cs: (HTMLElement | string)[], context: MarkdownParser.Context): HTMLElement {
90
+ function elem(tag: string, as: string[], bs: (HTMLElement | string)[], cs: string[], context: MarkdownParser.Context): HTMLElement {
91
+ assert(as.length > 0);
91
92
  assert(bs.length === defrag(bs).length);
93
+ assert(cs.length === 1);
92
94
  if (!tags.includes(tag)) return invalid('tag', `Invalid HTML tag <${tag}>.`, as, bs, cs);
93
95
  switch (tag) {
94
96
  case 'sup':
@@ -111,8 +113,6 @@ function elem(tag: string, as: (HTMLElement | string)[], bs: (HTMLElement | stri
111
113
  case as[as.length - 1] !== '>'
112
114
  || 'data-invalid-syntax' in (attrs = attributes('html', [], attrspec[tag], as.slice(1, -1) as string[])):
113
115
  return invalid('attribute', 'Invalid HTML attribute.', as, bs, cs);
114
- case cs.length === 0:
115
- return invalid('closer', `Missing the closing HTML tag <${tag}>.`, as, bs, cs);
116
116
  default:
117
117
  assert(attrs);
118
118
  return h(tag as 'span', attrs, bs);
@@ -2,7 +2,7 @@ import { MarkParser } from '../inline';
2
2
  import { union, some, creator, surround, open, lazy } from '../../combinator';
3
3
  import { inline } from '../inline';
4
4
  import { str } from '../source';
5
- import { startTight, isEndTightNodes, delimiter } from '../util';
5
+ import { startTight, delimiter } from '../util';
6
6
  import { html, defrag } from 'typed-dom';
7
7
  import { unshift } from 'spica/array';
8
8
 
@@ -13,8 +13,5 @@ export const mark: MarkParser = lazy(() => creator(surround(
13
13
  open(some(inline, '='), inline),
14
14
  ]))),
15
15
  str('=='), false,
16
- ([as, bs, cs], rest) =>
17
- isEndTightNodes(bs)
18
- ? [[html('mark', defrag(bs))], rest]
19
- : [unshift(as, bs), cs[0] + rest],
16
+ ([, bs], rest) => [[html('mark', defrag(bs))], rest],
20
17
  ([as, bs], rest) => [unshift(as, bs), rest])));
@@ -9,11 +9,11 @@ describe('Unit: parser/inline/strong', () => {
9
9
  it('invalid', () => {
10
10
  assert.deepStrictEqual(inspect(parser('**')), undefined);
11
11
  assert.deepStrictEqual(inspect(parser('**a')), [['**', 'a'], '']);
12
- assert.deepStrictEqual(inspect(parser('**a*')), [['**', 'a', '*'], '']);
13
12
  assert.deepStrictEqual(inspect(parser('**a **')), [['**', 'a', ' ', '**'], '']);
14
13
  assert.deepStrictEqual(inspect(parser('**a\n**')), [['**', 'a', '<br>', '**'], '']);
15
14
  assert.deepStrictEqual(inspect(parser('**a\\ **')), [['**', 'a', ' ', '**'], '']);
16
15
  assert.deepStrictEqual(inspect(parser('**a\\\n**')), [['**', 'a', '<span class="linebreak"> </span>', '**'], '']);
16
+ assert.deepStrictEqual(inspect(parser('**a*')), [['**', 'a', '*'], '']);
17
17
  assert.deepStrictEqual(inspect(parser('**a*b**')), [['**', 'a', '<em>b</em>', '*'], '']);
18
18
  assert.deepStrictEqual(inspect(parser('** **')), undefined);
19
19
  assert.deepStrictEqual(inspect(parser('** a**')), undefined);
@@ -2,7 +2,7 @@ import { StrongParser } from '../inline';
2
2
  import { union, some, creator, surround, open, lazy } from '../../combinator';
3
3
  import { inline } from '../inline';
4
4
  import { str } from '../source';
5
- import { startTight, isEndTightNodes, delimiter } from '../util';
5
+ import { startTight, delimiter } from '../util';
6
6
  import { html, defrag } from 'typed-dom';
7
7
  import { unshift } from 'spica/array';
8
8
 
@@ -13,8 +13,5 @@ export const strong: StrongParser = lazy(() => creator(surround(
13
13
  open(some(inline, '*'), inline),
14
14
  ])), '*'),
15
15
  str('**'), false,
16
- ([as, bs, cs], rest) =>
17
- isEndTightNodes(bs)
18
- ? [[html('strong', defrag(bs))], rest]
19
- : [unshift(as, bs), cs[0] + rest],
16
+ ([, bs], rest) => [[html('strong', defrag(bs))], rest],
20
17
  ([as, bs], rest) => [unshift(as, bs), rest])));
@@ -92,7 +92,6 @@ describe('Unit: parser/inline', () => {
92
92
  assert.deepStrictEqual(inspect(parser('***a***')), [['<em><strong>a</strong></em>'], '']);
93
93
  assert.deepStrictEqual(inspect(parser('***a***b')), [['<em><strong>a</strong></em>', 'b'], '']);
94
94
  assert.deepStrictEqual(inspect(parser('***a****')), [['<em><strong>a</strong></em>', '*'], '']);
95
- assert.deepStrictEqual(inspect(parser('***a *b****')), [['<em><strong>a <em>b</em></strong></em>'], '']);
96
95
  assert.deepStrictEqual(inspect(parser('****a***')), [['****', 'a', '***'], '']);
97
96
  assert.deepStrictEqual(inspect(parser('****a****')), [['****', 'a', '****'], '']);
98
97
  assert.deepStrictEqual(inspect(parser('*(*a*)*')), [['<em><span class="paren">(<em>a</em>)</span></em>'], '']);
@@ -28,7 +28,7 @@ describe('Unit: parser/processor/figure', () => {
28
28
  assert.deepStrictEqual(
29
29
  [...target.children].map(el => el.outerHTML),
30
30
  [
31
- '<figure data-label="fig-a" data-group="fig" data-number="1" id="label:fig-a"><div class="figcontent"><blockquote></blockquote></div><span class="figindex">Fig. 1. </span><figcaption></figcaption></figure>',
31
+ '<figure data-label="fig-a" data-group="fig" data-number="1" id="label:fig-a"><div class="figcontent"><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 1. </span></figcaption></figure>',
32
32
  '<p><a class="label" data-label="fig-a" href="#label:fig-a">Fig. 1</a></p>',
33
33
  '<p><a class="label" data-label="fig-a" href="#label:fig-a">Fig. 1</a></p>',
34
34
  ]);
@@ -47,10 +47,10 @@ describe('Unit: parser/processor/figure', () => {
47
47
  assert.deepStrictEqual(
48
48
  [...target.children].map(el => el.outerHTML),
49
49
  [
50
- '<figure data-label="fig-a" data-group="fig" data-number="1" id="label:fig-a"><div class="figcontent"><blockquote></blockquote></div><span class="figindex">Fig. 1. </span><figcaption></figcaption></figure>',
50
+ '<figure data-label="fig-a" data-group="fig" data-number="1" id="label:fig-a"><div class="figcontent"><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 1. </span></figcaption></figure>',
51
51
  '<h2 id="index:0">0</h2>',
52
- '<figure data-label="fig-b" data-group="fig" data-number="2" id="label:fig-b"><div class="figcontent"><blockquote></blockquote></div><span class="figindex">Fig. 2. </span><figcaption></figcaption></figure>',
53
- '<figure data-label="table-a" data-group="table" data-number="1" id="label:table-a"><div class="figcontent"><blockquote></blockquote></div><span class="figindex">Table 1. </span><figcaption></figcaption></figure>',
52
+ '<figure data-label="fig-b" data-group="fig" data-number="2" id="label:fig-b"><div class="figcontent"><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 2. </span></figcaption></figure>',
53
+ '<figure data-label="table-a" data-group="table" data-number="1" id="label:table-a"><div class="figcontent"><blockquote></blockquote></div><figcaption><span class="figindex">Table 1. </span></figcaption></figure>',
54
54
  ]);
55
55
  }
56
56
  });
@@ -65,7 +65,7 @@ describe('Unit: parser/processor/figure', () => {
65
65
  assert.deepStrictEqual(
66
66
  [...target.children].map(el => el.outerHTML),
67
67
  [
68
- '<figure data-label="$-a" data-group="$" data-number="1" id="label:$-a"><div class="figcontent"><div class="math" translate="no">$$\n$$</div></div><span class="figindex">(1)</span><figcaption></figcaption></figure>',
68
+ '<figure data-label="$-a" data-group="$" data-number="1" id="label:$-a"><div class="figcontent"><div class="math" translate="no">$$\n$$</div></div><figcaption><span class="figindex">(1)</span></figcaption></figure>',
69
69
  '<p><a class="label" data-label="$-a" href="#label:$-a">(1)</a></p>',
70
70
  ]);
71
71
  }
@@ -87,11 +87,11 @@ describe('Unit: parser/processor/figure', () => {
87
87
  assert.deepStrictEqual(
88
88
  [...target.children].map(el => el.outerHTML),
89
89
  [
90
- '<figure data-label="fig-2" data-group="fig" data-number="2" id="label:fig-2"><div class="figcontent"><blockquote></blockquote></div><span class="figindex">Fig. 2. </span><figcaption></figcaption></figure>',
91
- '<figure data-label="fig-3.1" data-group="fig" data-number="3.1" id="label:fig-3.1"><div class="figcontent"><blockquote></blockquote></div><span class="figindex">Fig. 3.1. </span><figcaption></figcaption></figure>',
92
- '<figure data-label="$-4.1.1" data-group="$" data-number="4.1.1" id="label:$-4.1.1"><div class="figcontent"><div class="math" translate="no">$$\n$$</div></div><span class="figindex">(4.1.1)</span><figcaption></figcaption></figure>',
93
- '<figure data-label="$-a" data-group="$" data-number="1" id="label:$-a"><div class="figcontent"><div class="math" translate="no">$$\n$$</div></div><span class="figindex">(1)</span><figcaption></figcaption></figure>',
94
- '<figure data-label="fig-a" data-group="fig" data-number="1" id="label:fig-a"><div class="figcontent"><blockquote></blockquote></div><span class="figindex">Fig. 1. </span><figcaption></figcaption></figure>',
90
+ '<figure data-label="fig-2" data-group="fig" data-number="2" id="label:fig-2"><div class="figcontent"><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 2. </span></figcaption></figure>',
91
+ '<figure data-label="fig-3.1" data-group="fig" data-number="3.1" id="label:fig-3.1"><div class="figcontent"><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 3.1. </span></figcaption></figure>',
92
+ '<figure data-label="$-4.1.1" data-group="$" data-number="4.1.1" id="label:$-4.1.1"><div class="figcontent"><div class="math" translate="no">$$\n$$</div></div><figcaption><span class="figindex">(4.1.1)</span></figcaption></figure>',
93
+ '<figure data-label="$-a" data-group="$" data-number="1" id="label:$-a"><div class="figcontent"><div class="math" translate="no">$$\n$$</div></div><figcaption><span class="figindex">(1)</span></figcaption></figure>',
94
+ '<figure data-label="fig-a" data-group="fig" data-number="1" id="label:fig-a"><div class="figcontent"><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 1. </span></figcaption></figure>',
95
95
  '<p><a class="label" data-label="fig-2" href="#label:fig-2">Fig. 2</a></p>',
96
96
  '<p><a class="label" data-label="$-4.1.1" href="#label:$-4.1.1">(4.1.1)</a></p>',
97
97
  '<p><a class="label disabled invalid" data-label="fig-1" data-invalid-syntax="label" data-invalid-type="reference" data-invalid-description="Missing the reference.">$fig-1</a></p>',
@@ -111,10 +111,10 @@ describe('Unit: parser/processor/figure', () => {
111
111
  assert.deepStrictEqual(
112
112
  [...target.children].map(el => el.outerHTML),
113
113
  [
114
- '<blockquote><blockquote><section><figure data-label="fig-a" data-group="fig" data-number="1"><div class="figcontent"><blockquote></blockquote></div><span class="figindex">Fig. 1. </span><figcaption></figcaption></figure><ol class="annotations"></ol><ol class="references"></ol></section></blockquote><section><figure data-label="fig-a" data-group="fig" data-number="1"><div class="figcontent"><blockquote></blockquote></div><span class="figindex">Fig. 1. </span><figcaption></figcaption></figure><ol class="annotations"></ol><ol class="references"></ol></section></blockquote>',
115
- '<aside class="example" data-type="markdown"><pre translate="no">~~~figure $fig-a\n&gt; \n\n~~~\n\n$fig-a</pre><hr><section><figure data-label="fig-a" data-group="fig" data-number="1"><div class="figcontent"><blockquote></blockquote></div><span class="figindex">Fig. 1. </span><figcaption></figcaption></figure><p><a class="label disabled" data-label="fig-a">Fig. 1</a></p><ol class="annotations"></ol><ol class="references"></ol></section></aside>',
116
- '<figure data-label="fig-b" data-group="fig" data-number="1" id="label:fig-b"><div class="figcontent"><blockquote></blockquote></div><span class="figindex">Fig. 1. </span><figcaption></figcaption></figure>',
117
- '<figure data-label="fig-a" data-group="fig" data-number="2" id="label:fig-a"><div class="figcontent"><blockquote></blockquote></div><span class="figindex">Fig. 2. </span><figcaption></figcaption></figure>',
114
+ '<blockquote><blockquote><section><figure data-label="fig-a" data-group="fig" data-number="1"><div class="figcontent"><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 1. </span></figcaption></figure><ol class="annotations"></ol><ol class="references"></ol></section></blockquote><section><figure data-label="fig-a" data-group="fig" data-number="1"><div class="figcontent"><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 1. </span></figcaption></figure><ol class="annotations"></ol><ol class="references"></ol></section></blockquote>',
115
+ '<aside class="example" data-type="markdown"><pre translate="no">~~~figure $fig-a\n&gt; \n\n~~~\n\n$fig-a</pre><hr><section><figure data-label="fig-a" data-group="fig" data-number="1"><div class="figcontent"><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 1. </span></figcaption></figure><p><a class="label disabled" data-label="fig-a">Fig. 1</a></p><ol class="annotations"></ol><ol class="references"></ol></section></aside>',
116
+ '<figure data-label="fig-b" data-group="fig" data-number="1" id="label:fig-b"><div class="figcontent"><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 1. </span></figcaption></figure>',
117
+ '<figure data-label="fig-a" data-group="fig" data-number="2" id="label:fig-a"><div class="figcontent"><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 2. </span></figcaption></figure>',
118
118
  ]);
119
119
  }
120
120
  });
@@ -163,16 +163,16 @@ describe('Unit: parser/processor/figure', () => {
163
163
  '<h1 id="index:0">0</h1>',
164
164
  '<figure data-label="$-0.0" data-group="$" hidden="" data-number="0.0"></figure>',
165
165
  '<h2 id="index:0">0</h2>',
166
- '<figure data-label="fig-1" data-group="fig" data-number="1" id="label:fig-1"><div class="figcontent"><blockquote></blockquote></div><span class="figindex">Fig. 1. </span><figcaption></figcaption></figure>',
166
+ '<figure data-label="fig-1" data-group="fig" data-number="1" id="label:fig-1"><div class="figcontent"><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 1. </span></figcaption></figure>',
167
167
  '<h2 id="index:0">0</h2>',
168
168
  '<blockquote><section><h2>0</h2><ol class="annotations"></ol><ol class="references"></ol></section></blockquote>',
169
- '<figure data-label="fig-b" data-group="fig" data-number="2.1" id="label:fig-b"><div class="figcontent"><blockquote></blockquote></div><span class="figindex">Fig. 2.1. </span><figcaption></figcaption></figure>',
169
+ '<figure data-label="fig-b" data-group="fig" data-number="2.1" id="label:fig-b"><div class="figcontent"><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 2.1. </span></figcaption></figure>',
170
170
  '<h2 id="index:0">0</h2>',
171
171
  '<figure data-label="$-0.0.0" data-group="$" hidden=""></figure>',
172
- '<figure data-label="fig-c" data-group="fig" data-number="3.1" id="label:fig-c"><div class="figcontent"><blockquote></blockquote></div><span class="figindex">Fig. 3.1. </span><figcaption></figcaption></figure>',
172
+ '<figure data-label="fig-c" data-group="fig" data-number="3.1" id="label:fig-c"><div class="figcontent"><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 3.1. </span></figcaption></figure>',
173
173
  '<h2 id="index:0">0</h2>',
174
174
  '<figure data-label="$-0.1.0" data-group="$" hidden=""></figure>',
175
- '<figure data-label="fig-d" data-group="fig" data-number="4.1" id="label:fig-d"><div class="figcontent"><blockquote></blockquote></div><span class="figindex">Fig. 4.1. </span><figcaption></figcaption></figure>',
175
+ '<figure data-label="fig-d" data-group="fig" data-number="4.1" id="label:fig-d"><div class="figcontent"><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 4.1. </span></figcaption></figure>',
176
176
  '<figure data-label="$-0.0" data-group="$" hidden=""></figure>',
177
177
  '<figure data-label="$-0.1.0" data-group="$" hidden=""></figure>',
178
178
  '<figure data-label="$-0.4.0" data-group="$" hidden=""></figure>',
@@ -180,19 +180,19 @@ describe('Unit: parser/processor/figure', () => {
180
180
  '<h2 id="index:0">0</h2>',
181
181
  '<h2 id="index:0">0</h2>',
182
182
  '<figure data-label="$-0.0" data-group="$" hidden="" data-number="6.0"></figure>',
183
- '<figure data-label="fig-e" data-group="fig" data-number="6.1" id="label:fig-e"><div class="figcontent"><blockquote></blockquote></div><span class="figindex">Fig. 6.1. </span><figcaption></figcaption></figure>',
183
+ '<figure data-label="fig-e" data-group="fig" data-number="6.1" id="label:fig-e"><div class="figcontent"><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 6.1. </span></figcaption></figure>',
184
184
  '<h2 id="index:0">0</h2>',
185
185
  '<figure data-label="$-5.0" data-group="$" hidden="" data-number="5.0"></figure>',
186
- '<figure data-label="fig-f" data-group="fig" data-number="5.1" id="label:fig-f"><div class="figcontent"><blockquote></blockquote></div><span class="figindex">Fig. 5.1. </span><figcaption></figcaption></figure>',
186
+ '<figure data-label="fig-f" data-group="fig" data-number="5.1" id="label:fig-f"><div class="figcontent"><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 5.1. </span></figcaption></figure>',
187
187
  '<figure data-label="$-0" data-group="$" hidden=""></figure>',
188
- '<figure data-label="fig-g" data-group="fig" data-number="5.2" id="label:fig-g"><div class="figcontent"><blockquote></blockquote></div><span class="figindex">Fig. 5.2. </span><figcaption></figcaption></figure>',
188
+ '<figure data-label="fig-g" data-group="fig" data-number="5.2" id="label:fig-g"><div class="figcontent"><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 5.2. </span></figcaption></figure>',
189
189
  '<h3 id="index:0">0</h3>',
190
190
  '<figure data-label="$-0.0.0" data-group="$" hidden=""></figure>',
191
- '<figure data-label="fig-h" data-group="fig" data-number="5.3" id="label:fig-h"><div class="figcontent"><blockquote></blockquote></div><span class="figindex">Fig. 5.3. </span><figcaption></figcaption></figure>',
191
+ '<figure data-label="fig-h" data-group="fig" data-number="5.3" id="label:fig-h"><div class="figcontent"><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 5.3. </span></figcaption></figure>',
192
192
  '<h3 id="index:0">0</h3>',
193
- '<figure data-label="fig-i" data-group="fig" data-number="5.4" id="label:fig-i"><div class="figcontent"><blockquote></blockquote></div><span class="figindex">Fig. 5.4. </span><figcaption></figcaption></figure>',
193
+ '<figure data-label="fig-i" data-group="fig" data-number="5.4" id="label:fig-i"><div class="figcontent"><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 5.4. </span></figcaption></figure>',
194
194
  '<h1 id="index:0">0</h1>',
195
- '<figure data-label="fig-j" data-group="fig" data-number="6.1" id="label:fig-j"><div class="figcontent"><blockquote></blockquote></div><span class="figindex">Fig. 6.1. </span><figcaption></figcaption></figure>',
195
+ '<figure data-label="fig-j" data-group="fig" data-number="6.1" id="label:fig-j"><div class="figcontent"><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 6.1. </span></figcaption></figure>',
196
196
  ]);
197
197
  }
198
198
  });
@@ -219,10 +219,10 @@ describe('Unit: parser/processor/figure', () => {
219
219
  '<h2 id="index:0">0</h2>',
220
220
  '<h2 id="index:0">0</h2>',
221
221
  '<figure data-label="$-1.0" data-group="$" hidden="" data-number="1.0"></figure>',
222
- '<figure data-label="fig-a" data-group="fig" data-number="1.1" id="label:fig-a"><div class="figcontent"><blockquote></blockquote></div><span class="figindex">Fig. 1.1. </span><figcaption></figcaption></figure>',
222
+ '<figure data-label="fig-a" data-group="fig" data-number="1.1" id="label:fig-a"><div class="figcontent"><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 1.1. </span></figcaption></figure>',
223
223
  '<h2 id="index:0">0</h2>',
224
224
  '<figure data-label="$-0.0" data-group="$" hidden="" data-number="2.0"></figure>',
225
- '<figure data-label="fig-b" data-group="fig" data-number="2.1" id="label:fig-b"><div class="figcontent"><blockquote></blockquote></div><span class="figindex">Fig. 2.1. </span><figcaption></figcaption></figure>',
225
+ '<figure data-label="fig-b" data-group="fig" data-number="2.1" id="label:fig-b"><div class="figcontent"><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 2.1. </span></figcaption></figure>',
226
226
  ]);
227
227
  }
228
228
  });
@@ -238,7 +238,7 @@ describe('Unit: parser/processor/figure', () => {
238
238
  assert.deepStrictEqual(
239
239
  [...target.children].map(el => el.outerHTML),
240
240
  [
241
- '<figure data-label="fig-a" data-group="fig" data-number="1" id="label:fig-a"><div class="figcontent"><blockquote></blockquote></div><span class="figindex">Fig. 1. </span><figcaption></figcaption></figure>',
241
+ '<figure data-label="fig-a" data-group="fig" data-number="1" id="label:fig-a"><div class="figcontent"><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 1. </span></figcaption></figure>',
242
242
  '<p><a class="label" data-label="fig-a" href="#label:fig-a">Fig. 1</a></p>',
243
243
  '<p><a class="label" data-label="fig-a" href="#label:fig-a">Fig. 1</a></p>',
244
244
  ]);
@@ -255,7 +255,7 @@ describe('Unit: parser/processor/figure', () => {
255
255
  assert.deepStrictEqual(
256
256
  [...target.children].map(el => el.outerHTML),
257
257
  [
258
- '<figure data-label="fig-a" data-group="fig" data-number="1" id="label:0:fig-a"><div class="figcontent"><blockquote></blockquote></div><span class="figindex">Fig. 1. </span><figcaption></figcaption></figure>',
258
+ '<figure data-label="fig-a" data-group="fig" data-number="1" id="label:0:fig-a"><div class="figcontent"><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 1. </span></figcaption></figure>',
259
259
  '<p><a class="label" data-label="fig-a" href="#label:0:fig-a">Fig. 1</a></p>',
260
260
  ]);
261
261
  }
@@ -85,7 +85,7 @@ export function* figure(
85
85
  ? `(${number})`
86
86
  : `${capitalize(group)}${group === 'fig' ? '.' : ''} ${number}`;
87
87
  define(
88
- def.querySelector(':scope > .figindex')!,
88
+ def.querySelector(':scope > figcaption > .figindex')!,
89
89
  group === '$' ? figindex : `${figindex}. `);
90
90
  for (const ref of refs.take(label, Infinity)) {
91
91
  if (ref.hash.slice(1) === def.id && ref.innerText === figindex) continue;
@@ -46,9 +46,7 @@ export function startLoose<T extends HTMLElement | string>(parser: Parser<T>, ex
46
46
  : undefined;
47
47
  }
48
48
  export function isStartLoose(source: string, context: MarkdownParser.Context, except?: string): boolean {
49
- source &&= source.replace(/^[^\S\n]+/, '');
50
- if (source === '') return true;
51
- return isStartTight(source, context, except);
49
+ return isStartTight(source.replace(/^[^\S\n]+/, ''), context, except);
52
50
  }
53
51
  export function startTight<P extends Parser<unknown>>(parser: P, except?: string): P;
54
52
  export function startTight<T>(parser: Parser<T>, except?: string): Parser<T> {
@@ -92,10 +90,10 @@ export function isStartTightNodes(nodes: readonly (HTMLElement | string)[]): boo
92
90
  if (nodes.length === 0) return true;
93
91
  return isVisible(nodes[0], 0);
94
92
  }
95
- export function isEndTightNodes(nodes: readonly (HTMLElement | string)[]): boolean {
96
- if (nodes.length === 0) return true;
97
- return isVisible(nodes[nodes.length - 1], -1);
98
- }
93
+ //export function isEndTightNodes(nodes: readonly (HTMLElement | string)[]): boolean {
94
+ // if (nodes.length === 0) return true;
95
+ // return isVisible(nodes[nodes.length - 1], -1);
96
+ //}
99
97
  function isVisible(node: HTMLElement | string, strpos?: number): boolean {
100
98
  switch (typeof node) {
101
99
  case 'string':