securemark 0.259.0 → 0.260.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.
Files changed (152) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/design.md +16 -5
  3. package/dist/index.js +625 -318
  4. package/package.json +1 -1
  5. package/src/combinator/control/constraint/block.test.ts +5 -5
  6. package/src/combinator/control/constraint/block.ts +2 -2
  7. package/src/combinator/control/constraint/contract.ts +4 -4
  8. package/src/combinator/control/constraint/line.test.ts +6 -6
  9. package/src/combinator/control/constraint/line.ts +5 -5
  10. package/src/combinator/control/manipulation/convert.ts +5 -5
  11. package/src/combinator/control/manipulation/fence.ts +1 -1
  12. package/src/combinator/control/manipulation/indent.test.ts +14 -14
  13. package/src/combinator/control/manipulation/indent.ts +5 -5
  14. package/src/combinator/control/manipulation/lazy.ts +2 -2
  15. package/src/combinator/control/manipulation/match.ts +2 -2
  16. package/src/combinator/control/manipulation/recovery.ts +6 -6
  17. package/src/combinator/control/manipulation/scope.ts +11 -10
  18. package/src/combinator/control/manipulation/surround.ts +9 -8
  19. package/src/combinator/control/manipulation/trim.test.ts +9 -9
  20. package/src/combinator/control/monad/bind.ts +2 -2
  21. package/src/combinator/data/parser/context/memo.ts +3 -4
  22. package/src/combinator/data/parser/context.test.ts +9 -9
  23. package/src/combinator/data/parser/context.ts +33 -33
  24. package/src/combinator/data/parser/inits.ts +2 -2
  25. package/src/combinator/data/parser/sequence.test.ts +10 -10
  26. package/src/combinator/data/parser/sequence.ts +2 -2
  27. package/src/combinator/data/parser/some.test.ts +13 -13
  28. package/src/combinator/data/parser/some.ts +2 -2
  29. package/src/combinator/data/parser/subsequence.test.ts +14 -14
  30. package/src/combinator/data/parser/union.test.ts +10 -10
  31. package/src/combinator/data/parser/union.ts +2 -2
  32. package/src/combinator/data/parser.ts +6 -1
  33. package/src/parser/api/bind.ts +3 -3
  34. package/src/parser/api/header.ts +1 -1
  35. package/src/parser/api/normalize.ts +1 -1
  36. package/src/parser/api/parse.test.ts +19 -19
  37. package/src/parser/api/parse.ts +3 -3
  38. package/src/parser/autolink.test.ts +7 -7
  39. package/src/parser/autolink.ts +2 -2
  40. package/src/parser/block/blockquote.test.ts +9 -9
  41. package/src/parser/block/blockquote.ts +1 -1
  42. package/src/parser/block/codeblock.test.ts +5 -5
  43. package/src/parser/block/codeblock.ts +1 -1
  44. package/src/parser/block/dlist.test.ts +2 -2
  45. package/src/parser/block/extension/aside.test.ts +1 -1
  46. package/src/parser/block/extension/example.test.ts +1 -1
  47. package/src/parser/block/extension/example.ts +1 -1
  48. package/src/parser/block/extension/fig.test.ts +1 -1
  49. package/src/parser/block/extension/figbase.test.ts +1 -1
  50. package/src/parser/block/extension/figure.test.ts +2 -2
  51. package/src/parser/block/extension/figure.ts +1 -1
  52. package/src/parser/block/extension/message.test.ts +1 -1
  53. package/src/parser/block/extension/message.ts +1 -1
  54. package/src/parser/block/extension/placeholder.test.ts +1 -1
  55. package/src/parser/block/extension/table.test.ts +1 -1
  56. package/src/parser/block/extension/table.ts +1 -1
  57. package/src/parser/block/extension.test.ts +1 -1
  58. package/src/parser/block/heading.test.ts +8 -8
  59. package/src/parser/block/heading.ts +1 -1
  60. package/src/parser/block/horizontalrule.test.ts +1 -1
  61. package/src/parser/block/ilist.test.ts +1 -1
  62. package/src/parser/block/mathblock.test.ts +1 -1
  63. package/src/parser/block/olist.test.ts +2 -2
  64. package/src/parser/block/olist.ts +5 -5
  65. package/src/parser/block/paragraph.test.ts +15 -15
  66. package/src/parser/block/reply/cite.test.ts +12 -12
  67. package/src/parser/block/reply/cite.ts +2 -2
  68. package/src/parser/block/reply/quote.test.ts +4 -4
  69. package/src/parser/block/reply/quote.ts +2 -2
  70. package/src/parser/block/reply.test.ts +9 -9
  71. package/src/parser/block/sidefence.test.ts +7 -7
  72. package/src/parser/block/table.test.ts +1 -1
  73. package/src/parser/block/table.ts +1 -1
  74. package/src/parser/block/ulist.test.ts +2 -2
  75. package/src/parser/block/ulist.ts +1 -1
  76. package/src/parser/block.ts +2 -2
  77. package/src/parser/context.ts +23 -13
  78. package/src/parser/header.test.ts +1 -1
  79. package/src/parser/header.ts +3 -3
  80. package/src/parser/inline/annotation.test.ts +4 -4
  81. package/src/parser/inline/annotation.ts +3 -4
  82. package/src/parser/inline/autolink/account.test.ts +12 -12
  83. package/src/parser/inline/autolink/account.ts +4 -2
  84. package/src/parser/inline/autolink/anchor.test.ts +10 -10
  85. package/src/parser/inline/autolink/anchor.ts +14 -11
  86. package/src/parser/inline/autolink/channel.test.ts +4 -4
  87. package/src/parser/inline/autolink/email.test.ts +1 -1
  88. package/src/parser/inline/autolink/email.ts +1 -1
  89. package/src/parser/inline/autolink/hashnum.test.ts +1 -1
  90. package/src/parser/inline/autolink/hashnum.ts +4 -2
  91. package/src/parser/inline/autolink/hashtag.test.ts +21 -21
  92. package/src/parser/inline/autolink/hashtag.ts +4 -2
  93. package/src/parser/inline/autolink/url.test.ts +56 -56
  94. package/src/parser/inline/autolink/url.ts +5 -3
  95. package/src/parser/inline/autolink.ts +1 -1
  96. package/src/parser/inline/bracket.test.ts +1 -1
  97. package/src/parser/inline/bracket.ts +8 -8
  98. package/src/parser/inline/code.test.ts +1 -1
  99. package/src/parser/inline/code.ts +2 -2
  100. package/src/parser/inline/comment.test.ts +1 -1
  101. package/src/parser/inline/comment.ts +2 -2
  102. package/src/parser/inline/deletion.test.ts +1 -1
  103. package/src/parser/inline/deletion.ts +2 -2
  104. package/src/parser/inline/emphasis.test.ts +1 -1
  105. package/src/parser/inline/emphasis.ts +2 -2
  106. package/src/parser/inline/emstrong.ts +4 -4
  107. package/src/parser/inline/escape.ts +3 -3
  108. package/src/parser/inline/extension/index.test.ts +1 -1
  109. package/src/parser/inline/extension/index.ts +3 -4
  110. package/src/parser/inline/extension/indexer.test.ts +1 -1
  111. package/src/parser/inline/extension/label.test.ts +1 -1
  112. package/src/parser/inline/extension/placeholder.test.ts +1 -1
  113. package/src/parser/inline/extension/placeholder.ts +2 -2
  114. package/src/parser/inline/html.test.ts +1 -3
  115. package/src/parser/inline/html.ts +3 -3
  116. package/src/parser/inline/htmlentity.test.ts +1 -1
  117. package/src/parser/inline/htmlentity.ts +1 -1
  118. package/src/parser/inline/insertion.test.ts +1 -1
  119. package/src/parser/inline/insertion.ts +2 -2
  120. package/src/parser/inline/link.test.ts +111 -111
  121. package/src/parser/inline/link.ts +12 -12
  122. package/src/parser/inline/mark.test.ts +1 -1
  123. package/src/parser/inline/mark.ts +2 -2
  124. package/src/parser/inline/math.test.ts +1 -1
  125. package/src/parser/inline/math.ts +1 -1
  126. package/src/parser/inline/media.test.ts +2 -1
  127. package/src/parser/inline/media.ts +4 -4
  128. package/src/parser/inline/reference.test.ts +4 -4
  129. package/src/parser/inline/reference.ts +3 -4
  130. package/src/parser/inline/ruby.test.ts +1 -1
  131. package/src/parser/inline/ruby.ts +5 -5
  132. package/src/parser/inline/shortmedia.test.ts +1 -1
  133. package/src/parser/inline/strong.test.ts +1 -1
  134. package/src/parser/inline/strong.ts +2 -2
  135. package/src/parser/inline/template.test.ts +1 -1
  136. package/src/parser/inline/template.ts +2 -2
  137. package/src/parser/inline.test.ts +52 -52
  138. package/src/parser/locale.test.ts +1 -1
  139. package/src/parser/segment.ts +1 -1
  140. package/src/parser/source/escapable.test.ts +1 -1
  141. package/src/parser/source/escapable.ts +1 -1
  142. package/src/parser/source/line.test.ts +1 -1
  143. package/src/parser/source/line.ts +2 -2
  144. package/src/parser/source/str.ts +4 -4
  145. package/src/parser/source/text.test.ts +1 -1
  146. package/src/parser/source/text.ts +4 -4
  147. package/src/parser/source/unescapable.test.ts +1 -1
  148. package/src/parser/source/unescapable.ts +1 -1
  149. package/src/parser/visibility.ts +13 -13
  150. package/src/renderer/render/media/pdf.ts +1 -0
  151. package/src/util/info.ts +2 -4
  152. package/src/util/quote.ts +1 -1
@@ -1,17 +1,19 @@
1
1
  import { AutolinkParser } from '../../inline';
2
- import { union, some, creation, precedence, validate, focus, rewrite, convert, surround, open, lazy } from '../../../combinator';
2
+ import { union, some, creation, precedence, validate, focus, rewrite, convert, surround, open, lazy, fmap } from '../../../combinator';
3
3
  import { unsafelink } from '../link';
4
4
  import { unescsource } from '../../source';
5
+ import { define } from 'typed-dom/dom';
5
6
 
6
7
  const closer = /^[-+*=~^,.;:!?]*(?=[\\"`|\[\](){}<>]|$)/;
7
8
 
8
- export const url: AutolinkParser.UrlParser = lazy(() => validate(['http://', 'https://'], rewrite(
9
+ export const url: AutolinkParser.UrlParser = lazy(() => validate(['http://', 'https://'], fmap(rewrite(
9
10
  open(
10
11
  /^https?:\/\/(?=[\x21-\x7E])/,
11
12
  focus(/^[\x21-\x7E]+/, some(union([bracket, some(unescsource, closer)])))),
12
13
  convert(
13
14
  url => `{ ${url} }`,
14
- union([unsafelink])))));
15
+ union([unsafelink]))),
16
+ ([el]) => [define(el, { class: 'url' })])));
15
17
 
16
18
  const bracket: AutolinkParser.UrlParser.BracketParser = lazy(() => creation(precedence(2, union([
17
19
  surround('(', some(union([bracket, unescsource]), ')'), ')', true),
@@ -14,7 +14,7 @@ import { stringify } from '../util';
14
14
  export const autolink: AutolinkParser = fmap(
15
15
  validate(/^(?:[@#>0-9A-Za-z]|\S[#>])/,
16
16
  constraint(State.autolink, false,
17
- syntax(Syntax.autolink, 1, 1,
17
+ syntax(Syntax.autolink, 1, 1, State.none,
18
18
  some(union([
19
19
  url,
20
20
  email,
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
4
4
 
5
5
  describe('Unit: parser/inline/bracket', () => {
6
6
  describe('bracket', () => {
7
- const parser = (source: string) => some(bracket)(source, {});
7
+ const parser = (source: string) => some(bracket)({ source, context: {} });
8
8
 
9
9
  it('(', () => {
10
10
  assert.deepStrictEqual(inspect(parser('(')), [['', '('], '']);
@@ -3,29 +3,29 @@ import { BracketParser } from '../inline';
3
3
  import { union, some, syntax, surround, lazy } from '../../combinator';
4
4
  import { inline } from '../inline';
5
5
  import { str } from '../source';
6
- import { Syntax } from '../context';
6
+ import { Syntax, State } from '../context';
7
7
  import { html, defrag } from 'typed-dom/dom';
8
8
  import { unshift, push } from 'spica/array';
9
9
 
10
10
  const index = /^[0-9A-Za-z]+(?:(?:[.-]|, )[0-9A-Za-z]+)*/;
11
11
 
12
12
  export const bracket: BracketParser = lazy(() => union([
13
- surround(str('('), syntax(Syntax.none, 2, 1, str(index)), str(')')),
14
- surround(str('('), syntax(Syntax.bracket, 2, 1, some(inline, ')', [[')', 2]])), str(')'), true,
13
+ surround(str('('), syntax(Syntax.none, 2, 1, State.none, str(index)), str(')')),
14
+ surround(str('('), syntax(Syntax.bracket, 2, 1, State.none, some(inline, ')', [[')', 2]])), str(')'), true,
15
15
  ([as, bs = [], cs], rest) => [[html('span', { class: 'paren' }, defrag(push(unshift(as, bs), cs)))], rest],
16
16
  ([as, bs = []], rest) => [unshift([''], unshift(as, bs)), rest]),
17
- surround(str('('), syntax(Syntax.none, 2, 1, str(new RegExp(index.source.replace(', ', '[,、]').replace(/[09AZaz.]|\-(?!\w)/g, c => c.trimStart() && String.fromCharCode(c.charCodeAt(0) + 0xFEE0))))), str(')')),
18
- surround(str('('), syntax(Syntax.bracket, 2, 1, some(inline, ')', [[')', 2]])), str(')'), true,
17
+ surround(str('('), syntax(Syntax.none, 2, 1, State.none, str(new RegExp(index.source.replace(', ', '[,、]').replace(/[09AZaz.]|\-(?!\w)/g, c => c.trimStart() && String.fromCharCode(c.charCodeAt(0) + 0xFEE0))))), str(')')),
18
+ surround(str('('), syntax(Syntax.bracket, 2, 1, State.none, some(inline, ')', [[')', 2]])), str(')'), true,
19
19
  ([as, bs = [], cs], rest) => [[html('span', { class: 'paren' }, defrag(push(unshift(as, bs), cs)))], rest],
20
20
  ([as, bs = []], rest) => [unshift(as, bs), rest]),
21
- surround(str('['), syntax(Syntax.bracket, 2, 1, some(inline, ']', [[']', 2]])), str(']'), true,
21
+ surround(str('['), syntax(Syntax.bracket, 2, 1, State.none, some(inline, ']', [[']', 2]])), str(']'), true,
22
22
  undefined,
23
23
  ([as, bs = []], rest) => [unshift([''], unshift(as, bs)), rest]),
24
- surround(str('{'), syntax(Syntax.bracket, 2, 1, some(inline, '}', [['}', 2]])), str('}'), true,
24
+ surround(str('{'), syntax(Syntax.bracket, 2, 1, State.none, some(inline, '}', [['}', 2]])), str('}'), true,
25
25
  undefined,
26
26
  ([as, bs = []], rest) => [unshift(as, bs), rest]),
27
27
  // Control media blinking in editing rather than control confusion of pairs of quote marks.
28
- surround(str('"'), syntax(Syntax.quote, 8, 1, some(inline, '"', [['"', 8]])), str('"'), true,
28
+ surround(str('"'), syntax(Syntax.quote, 8, 1, State.none, some(inline, '"', [['"', 8]])), str('"'), true,
29
29
  undefined,
30
30
  ([as, bs = []], rest) => [unshift(as, bs), rest]),
31
31
  ]));
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
4
4
 
5
5
  describe('Unit: parser/inline/code', () => {
6
6
  describe('code', () => {
7
- const parser = (source: string) => some(code)(source, {});
7
+ const parser = (source: string) => some(code)({ source, context: {} });
8
8
 
9
9
  it('invalid', () => {
10
10
  assert.deepStrictEqual(inspect(parser('')), undefined);
@@ -4,8 +4,8 @@ import { html } from 'typed-dom/dom';
4
4
 
5
5
  export const code: CodeParser = creation(validate('`', match(
6
6
  /^(`+)(?!`)([^\n]*?[^`\n])\1(?!`)/,
7
- ([whole, , body]) => rest =>
8
- [[html('code', { 'data-src': whole }, format(body))], rest.slice(whole.length)])));
7
+ ([whole, , body]) => ({ source }) =>
8
+ [[html('code', { 'data-src': whole }, format(body))], source.slice(whole.length)])));
9
9
 
10
10
  function format(text: string): string {
11
11
  assert(text.length > 0);
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
4
4
 
5
5
  describe('Unit: parser/inline/comment', () => {
6
6
  describe('comment', () => {
7
- const parser = (source: string) => some(comment)(source, {});
7
+ const parser = (source: string) => some(comment)({ source, context: {} });
8
8
 
9
9
  it('invalid', () => {
10
10
  assert.deepStrictEqual(inspect(parser('')), undefined);
@@ -2,12 +2,12 @@ import { CommentParser } from '../inline';
2
2
  import { union, some, syntax, validate, surround, open, close, match, lazy } from '../../combinator';
3
3
  import { inline } from '../inline';
4
4
  import { text, str } from '../source';
5
- import { Syntax } from '../context';
5
+ import { Syntax, State } from '../context';
6
6
  import { html, defrag } from 'typed-dom/dom';
7
7
  import { memoize } from 'spica/memoize';
8
8
  import { unshift, push } from 'spica/array';
9
9
 
10
- export const comment: CommentParser = lazy(() => validate('[%', syntax(Syntax.none, 4, 1, match(
10
+ export const comment: CommentParser = lazy(() => validate('[%', syntax(Syntax.none, 4, 1, State.none, match(
11
11
  /^\[(%+)\s/,
12
12
  memoize(
13
13
  ([, fence]) =>
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
4
4
 
5
5
  describe('Unit: parser/inline/deletion', () => {
6
6
  describe('deletion', () => {
7
- const parser = (source: string) => some(deletion)(source, {});
7
+ const parser = (source: string) => some(deletion)({ source, context: {} });
8
8
 
9
9
  it('invalid', () => {
10
10
  assert.deepStrictEqual(inspect(parser('')), undefined);
@@ -2,14 +2,14 @@ import { DeletionParser } from '../inline';
2
2
  import { union, some, syntax, surround, open, lazy } from '../../combinator';
3
3
  import { inline } from '../inline';
4
4
  import { str } from '../source';
5
- import { Syntax } from '../context';
5
+ import { Syntax, State } from '../context';
6
6
  import { blankWith } from '../visibility';
7
7
  import { html, defrag } from 'typed-dom/dom';
8
8
  import { unshift } from 'spica/array';
9
9
 
10
10
  export const deletion: DeletionParser = lazy(() => surround(
11
11
  str('~~'),
12
- syntax(Syntax.none, 1, 1,
12
+ syntax(Syntax.none, 1, 1, State.none,
13
13
  some(union([
14
14
  some(inline, blankWith('\n', '~~')),
15
15
  open('\n', some(inline, '~'), true),
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
4
4
 
5
5
  describe('Unit: parser/inline/emphasis', () => {
6
6
  describe('emphasis', () => {
7
- const parser = (source: string) => some(emphasis)(source, {});
7
+ const parser = (source: string) => some(emphasis)({ source, context: {} });
8
8
 
9
9
  it('invalid', () => {
10
10
  assert.deepStrictEqual(inspect(parser('*')), undefined);
@@ -4,14 +4,14 @@ import { inline } from '../inline';
4
4
  import { emstrong } from './emstrong';
5
5
  import { strong } from './strong';
6
6
  import { str } from '../source';
7
- import { Syntax } from '../context';
7
+ import { Syntax, State } from '../context';
8
8
  import { startTight, blankWith } from '../visibility';
9
9
  import { html, defrag } from 'typed-dom/dom';
10
10
  import { unshift } from 'spica/array';
11
11
 
12
12
  export const emphasis: EmphasisParser = lazy(() => surround(
13
13
  str('*'),
14
- syntax(Syntax.none, 1, 1,
14
+ syntax(Syntax.none, 1, 1, State.none,
15
15
  startTight(some(union([
16
16
  strong,
17
17
  some(inline, blankWith('*')),
@@ -5,7 +5,7 @@ import { inline } from '../inline';
5
5
  import { strong } from './strong';
6
6
  import { emphasis } from './emphasis';
7
7
  import { str } from '../source';
8
- import { Syntax } from '../context';
8
+ import { Syntax, State } from '../context';
9
9
  import { startTight, blankWith } from '../visibility';
10
10
  import { html, defrag } from 'typed-dom/dom';
11
11
  import { unshift } from 'spica/array';
@@ -29,7 +29,7 @@ const subemphasis: IntermediateParser<EmphasisParser> = lazy(() => some(union([
29
29
 
30
30
  export const emstrong: EmStrongParser = lazy(() => surround(
31
31
  str('***'),
32
- syntax(Syntax.none, 1, 1,
32
+ syntax(Syntax.none, 1, 1, State.none,
33
33
  startTight(some(union([
34
34
  some(inline, blankWith('*')),
35
35
  open(some(inline, '*'), inline),
@@ -47,7 +47,7 @@ export const emstrong: EmStrongParser = lazy(() => surround(
47
47
  rest.slice(0, 1) === '*'
48
48
  ? [[html('em', unshift([html('strong', defrag(bs))], defrag(ds)))], rest.slice(1)]
49
49
  : [unshift(['*', html('strong', defrag(bs))], ds), rest])
50
- (rest, context) ?? [['*', html('strong', defrag(bs))], rest];
50
+ ({ source: rest, context }) ?? [['*', html('strong', defrag(bs))], rest];
51
51
  case '*':
52
52
  return bind<StrongParser>(
53
53
  substrong,
@@ -55,7 +55,7 @@ export const emstrong: EmStrongParser = lazy(() => surround(
55
55
  rest.slice(0, 2) === '**'
56
56
  ? [[html('strong', unshift([html('em', defrag(bs))], defrag(ds)))], rest.slice(2)]
57
57
  : [unshift(['**', html('em', defrag(bs))], ds), rest])
58
- (rest, context) ?? [['**', html('em', defrag(bs))], rest];
58
+ ({ source: rest, context }) ?? [['**', html('em', defrag(bs))], rest];
59
59
  }
60
60
  assert(false);
61
61
  },
@@ -5,7 +5,7 @@ import { str } from '../source';
5
5
 
6
6
  const repeat = str(/^(.)\1*/);
7
7
 
8
- export const escape: EscapeParser = union([(source, context) => {
8
+ export const escape: EscapeParser = union([({ source, context }) => {
9
9
  if (source.length < 3) return;
10
10
  switch (source[0]) {
11
11
  case '*':
@@ -14,7 +14,7 @@ export const escape: EscapeParser = union([(source, context) => {
14
14
  return source[3] === source[0]
15
15
  && source[2] === source[0]
16
16
  && source[1] === source[0]
17
- ? repeat(source, context)
17
+ ? repeat({ source, context })
18
18
  : undefined;
19
19
  case '+':
20
20
  case '~':
@@ -22,7 +22,7 @@ export const escape: EscapeParser = union([(source, context) => {
22
22
  assert(source[2]);
23
23
  return source[2] === source[0]
24
24
  && source[1] === source[0]
25
- ? repeat(source, context)
25
+ ? repeat({ source, context })
26
26
  : undefined;
27
27
  default:
28
28
  return;
@@ -4,7 +4,7 @@ import { inspect } from '../../../debug.test';
4
4
 
5
5
  describe('Unit: parser/inline/extension/index', () => {
6
6
  describe('index', () => {
7
- const parser = (source: string) => some(index)(source, {});
7
+ const parser = (source: string) => some(index)({ source, context: {} });
8
8
 
9
9
  it('invalid', () => {
10
10
  assert.deepStrictEqual(inspect(parser('[]')), undefined);
@@ -1,6 +1,6 @@
1
1
  import { undefined } from 'spica/global';
2
2
  import { ExtensionParser } from '../../inline';
3
- import { union, some, syntax, creation, precedence, constraint, state, validate, surround, open, lazy, fmap } from '../../../combinator';
3
+ import { union, some, syntax, creation, precedence, constraint, validate, surround, open, lazy, fmap } from '../../../combinator';
4
4
  import { inline } from '../../inline';
5
5
  import { indexee, identity } from './indexee';
6
6
  import { txt, str, stropt } from '../../source';
@@ -13,13 +13,12 @@ import IndexParser = ExtensionParser.IndexParser;
13
13
  export const index: IndexParser = lazy(() => validate('[#', fmap(indexee(surround(
14
14
  '[#',
15
15
  constraint(State.index, false,
16
- state(State.annotation | State.reference | State.index | State.label | State.link | State.media | State.autolink,
17
- syntax(Syntax.index, 2, 1,
16
+ syntax(Syntax.index, 2, 1, State.linkable,
18
17
  startTight(
19
18
  open(stropt(/^\|?/), trimBlankEnd(some(union([
20
19
  signature,
21
20
  inline,
22
- ]), ']', [[/^\\?\n/, 9], [']', 2]])), true))))),
21
+ ]), ']', [[/^\\?\n/, 9], [']', 2]])), true)))),
23
22
  ']',
24
23
  false,
25
24
  ([, ns], rest) => [[html('a', defrag(ns))], rest])),
@@ -4,7 +4,7 @@ import { inspect } from '../../../debug.test';
4
4
 
5
5
  describe('Unit: parser/inline/extension/indexer', () => {
6
6
  describe('indexer', () => {
7
- const parser = (source: string) => some(indexer)(source, {});
7
+ const parser = (source: string) => some(indexer)({ source, context: {} });
8
8
 
9
9
  it('invalid', () => {
10
10
  assert.deepStrictEqual(inspect(parser('')), undefined);
@@ -4,7 +4,7 @@ import { inspect } from '../../../debug.test';
4
4
 
5
5
  describe('Unit: parser/inline/extension/label', () => {
6
6
  describe('label', () => {
7
- const parser = (source: string) => some(label)(source, {});
7
+ const parser = (source: string) => some(label)({ source, context: {} });
8
8
 
9
9
  it('invalid', () => {
10
10
  assert.deepStrictEqual(inspect(parser('[]')), undefined);
@@ -4,7 +4,7 @@ import { inspect } from '../../../debug.test';
4
4
 
5
5
  describe('Unit: parser/inline/extension/placeholder', () => {
6
6
  describe('placeholder', () => {
7
- const parser = (source: string) => some(placeholder)(source, {});
7
+ const parser = (source: string) => some(placeholder)({ source, context: {} });
8
8
 
9
9
  it('invalid', () => {
10
10
  assert.deepStrictEqual(inspect(parser('[]')), undefined);
@@ -2,7 +2,7 @@ import { ExtensionParser } from '../../inline';
2
2
  import { union, some, syntax, validate, surround, lazy } from '../../../combinator';
3
3
  import { inline } from '../../inline';
4
4
  import { str } from '../../source';
5
- import { Syntax } from '../../context';
5
+ import { Syntax, State } from '../../context';
6
6
  import { startTight } from '../../visibility';
7
7
  import { html, defrag } from 'typed-dom/dom';
8
8
  import { unshift } from 'spica/array';
@@ -13,7 +13,7 @@ import { unshift } from 'spica/array';
13
13
 
14
14
  export const placeholder: ExtensionParser.PlaceholderParser = lazy(() => validate(['[:', '[^'], surround(
15
15
  str(/^\[[:^]/),
16
- syntax(Syntax.none, 2, 1,
16
+ syntax(Syntax.none, 2, 1, State.none,
17
17
  startTight(some(union([inline]), ']', [[/^\\?\n/, 9], [']', 2]]))),
18
18
  str(']'), false,
19
19
  ([as, bs], rest) => [[
@@ -4,18 +4,16 @@ import { inspect } from '../../debug.test';
4
4
 
5
5
  describe('Unit: parser/inline/html', () => {
6
6
  describe('html', () => {
7
- const parser = (source: string) => some(html)(source, {});
7
+ const parser = (source: string) => some(html)({ source, context: {} });
8
8
 
9
9
  it('xss', () => {
10
10
  assert.deepStrictEqual(inspect(parser('<script>')), [['<span class="invalid">&lt;script&gt;</span>'], '']);
11
11
  assert.deepStrictEqual(inspect(parser('<script>alert()<script>')), [['<span class="invalid">&lt;script&gt;alert<span class="paren">()</span><span class="invalid">&lt;script&gt;</span></span>'], '']);
12
12
  assert.deepStrictEqual(inspect(parser('<script>alert()</script>')), [['<span class="invalid">&lt;script&gt;alert<span class="paren">()</span>&lt;/script&gt;</span>'], '']);
13
- assert.deepStrictEqual(inspect(parser('<script src="\\""></script>')), [['<span class="invalid">&lt;script src="\\""&gt;&lt;/script&gt;</span>'], '']);
14
13
  assert.deepStrictEqual(inspect(parser('<bdi onclick="alert()">')), [['<span class="invalid">&lt;bdi onclick="alert()"&gt;</span>'], '']);
15
14
  assert.deepStrictEqual(inspect(parser('<bdi onclick="alert()"></bdi>')), [['<span class="invalid">&lt;bdi onclick="alert()"&gt;&lt;/bdi&gt;</span>'], '']);
16
15
  assert.deepStrictEqual(inspect(parser('<bdi onclick="alert()">a</bdi>')), [['<span class="invalid">&lt;bdi onclick="alert()"&gt;a&lt;/bdi&gt;</span>'], '']);
17
16
  assert.deepStrictEqual(inspect(parser('<bdi><bdi onclick="alert()">a</bdi></bdi>')), [['<bdi><span class="invalid">&lt;bdi onclick="alert()"&gt;a&lt;/bdi&gt;</span></bdi>'], '']);
18
- assert.deepStrictEqual(inspect(parser('<bdo dir="rtl\\"><">a</bdo>')), [['<span class="invalid">&lt;bdo dir="rtl\\"&gt;&lt;"&gt;a&lt;/bdo&gt;</span>'], '']);
19
17
  });
20
18
 
21
19
  it('invalid', () => {
@@ -3,7 +3,7 @@ import { HTMLParser } from '../inline';
3
3
  import { union, subsequence, some, syntax, validate, focus, surround, open, match, lazy } from '../../combinator';
4
4
  import { inline } from '../inline';
5
5
  import { str } from '../source';
6
- import { Syntax } from '../context';
6
+ import { Syntax, State } from '../context';
7
7
  import { isStartLooseNodes, blankWith } from '../visibility';
8
8
  import { html as h, defrag } from 'typed-dom/dom';
9
9
  import { memoize } from 'spica/memoize';
@@ -19,7 +19,7 @@ const attrspecs = {
19
19
  Object.setPrototypeOf(attrspecs, null);
20
20
  Object.values(attrspecs).forEach(o => Object.setPrototypeOf(o, null));
21
21
 
22
- export const html: HTMLParser = lazy(() => validate('<', validate(/^<[a-z]+(?=[^\S\n]|>)/i, syntax(Syntax.none, 5, 1, union([
22
+ export const html: HTMLParser = lazy(() => validate('<', validate(/^<[a-z]+(?=[^\S\n]|>)/i, syntax(Syntax.none, 5, 1, State.none, union([
23
23
  focus(
24
24
  /^<wbr[^\S\n]*>/i,
25
25
  () => [[h('wbr')], '']),
@@ -64,7 +64,7 @@ export const html: HTMLParser = lazy(() => validate('<', validate(/^<[a-z]+(?=[^
64
64
  ])))));
65
65
 
66
66
  export const attribute: HTMLParser.AttributeParser = union([
67
- str(/^[^\S\n]+[a-z]+(?:-[a-z]+)*(?:="(?:\\[^\n]|[^\\\n"])*")?(?=[^\S\n]|>)/i),
67
+ str(/^[^\S\n]+[a-z]+(?:-[a-z]+)*(?:="[^"\n]*")?(?=[^\S\n]|>)/i),
68
68
  ]);
69
69
 
70
70
  // https://developer.mozilla.org/en-US/docs/Web/HTML/Element
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
4
4
 
5
5
  describe('Unit: parser/inline/htmlentity', () => {
6
6
  describe('htmlentity', () => {
7
- const parser = (source: string) => some(htmlentity)(source, {});
7
+ const parser = (source: string) => some(htmlentity)({ source, context: {} });
8
8
 
9
9
  it('invalid', () => {
10
10
  assert.deepStrictEqual(inspect(parser('')), undefined);
@@ -6,7 +6,7 @@ import { reduce } from 'spica/memoize';
6
6
 
7
7
  export const unsafehtmlentity: UnsafeHTMLEntityParser = creation(validate('&', focus(
8
8
  /^&[0-9A-Za-z]+;/,
9
- entity => [[parse(entity) ?? `\x1B${entity}`], ''])));
9
+ ({ source }) => [[parse(source) ?? `\x1B${source}`], ''])));
10
10
 
11
11
  export const htmlentity: HTMLEntityParser = fmap(
12
12
  union([unsafehtmlentity]),
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
4
4
 
5
5
  describe('Unit: parser/inline/insertion', () => {
6
6
  describe('insertion', () => {
7
- const parser = (source: string) => some(insertion)(source, {});
7
+ const parser = (source: string) => some(insertion)({ source, context: {} });
8
8
 
9
9
  it('invalid', () => {
10
10
  assert.deepStrictEqual(inspect(parser('')), undefined);
@@ -2,14 +2,14 @@ import { InsertionParser } from '../inline';
2
2
  import { union, some, syntax, surround, open, lazy } from '../../combinator';
3
3
  import { inline } from '../inline';
4
4
  import { str } from '../source';
5
- import { Syntax } from '../context';
5
+ import { Syntax, State } from '../context';
6
6
  import { blankWith } from '../visibility';
7
7
  import { html, defrag } from 'typed-dom/dom';
8
8
  import { unshift } from 'spica/array';
9
9
 
10
10
  export const insertion: InsertionParser = lazy(() => surround(
11
11
  str('++'),
12
- syntax(Syntax.none, 1, 1,
12
+ syntax(Syntax.none, 1, 1, State.none,
13
13
  some(union([
14
14
  some(inline, blankWith('\n', '++')),
15
15
  open('\n', some(inline, '+'), true),