securemark 0.260.5 → 0.261.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 (46) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +12 -12
  3. package/design.md +0 -4
  4. package/dist/index.js +199 -245
  5. package/markdown.d.ts +5 -32
  6. package/package.json +6 -6
  7. package/src/parser/api/parse.test.ts +1 -1
  8. package/src/parser/block/blockquote.test.ts +2 -2
  9. package/src/parser/block/dlist.test.ts +1 -1
  10. package/src/parser/block/extension/example.test.ts +1 -1
  11. package/src/parser/block/extension/fig.test.ts +1 -1
  12. package/src/parser/block/heading.test.ts +2 -2
  13. package/src/parser/block/paragraph.test.ts +1 -4
  14. package/src/parser/block/reply/cite.test.ts +5 -0
  15. package/src/parser/block/reply/cite.ts +5 -4
  16. package/src/parser/inline/autolink/anchor.test.ts +1 -0
  17. package/src/parser/inline/autolink/email.test.ts +3 -0
  18. package/src/parser/inline/autolink/email.ts +1 -1
  19. package/src/parser/inline/autolink/hashnum.test.ts +1 -2
  20. package/src/parser/inline/autolink/hashnum.ts +1 -1
  21. package/src/parser/inline/autolink/hashtag.test.ts +15 -12
  22. package/src/parser/inline/autolink/hashtag.ts +3 -3
  23. package/src/parser/inline/autolink/url.test.ts +1 -1
  24. package/src/parser/inline/autolink/url.ts +1 -1
  25. package/src/parser/inline/autolink.ts +13 -4
  26. package/src/parser/inline/deletion.test.ts +2 -2
  27. package/src/parser/inline/deletion.ts +1 -1
  28. package/src/parser/inline/emphasis.test.ts +26 -35
  29. package/src/parser/inline/emphasis.ts +5 -12
  30. package/src/parser/inline/extension/index.test.ts +2 -2
  31. package/src/parser/inline/insertion.test.ts +2 -2
  32. package/src/parser/inline/insertion.ts +1 -1
  33. package/src/parser/inline/link.test.ts +1 -1
  34. package/src/parser/inline/mark.test.ts +1 -1
  35. package/src/parser/inline/mark.ts +1 -1
  36. package/src/parser/inline/strong.test.ts +25 -32
  37. package/src/parser/inline/strong.ts +5 -9
  38. package/src/parser/inline.test.ts +18 -91
  39. package/src/parser/inline.ts +0 -6
  40. package/src/parser/locale/ja.ts +1 -9
  41. package/src/parser/locale.test.ts +1 -1
  42. package/src/parser/source/str.ts +4 -2
  43. package/src/parser/source/text.test.ts +9 -4
  44. package/src/parser/source/text.ts +9 -16
  45. package/src/parser/inline/emstrong.ts +0 -62
  46. package/src/parser/inline/escape.ts +0 -30
@@ -1,62 +0,0 @@
1
- import { EmStrongParser, EmphasisParser, StrongParser } from '../inline';
2
- import { Result, IntermediateParser } from '../../combinator/data/parser';
3
- import { union, syntax, some, surround, open, lazy, bind } from '../../combinator';
4
- import { inline } from '../inline';
5
- import { strong } from './strong';
6
- import { emphasis } from './emphasis';
7
- import { str } from '../source';
8
- import { Syntax, State } from '../context';
9
- import { startTight, blankWith } from '../visibility';
10
- import { html, defrag } from 'typed-dom/dom';
11
- import { unshift } from 'spica/array';
12
-
13
- const substrong: IntermediateParser<StrongParser> = lazy(() => some(union([
14
- some(inline, blankWith('**')),
15
- open(some(inline, '*'), union([
16
- emstrong,
17
- strong,
18
- ])),
19
- ])));
20
- const subemphasis: IntermediateParser<EmphasisParser> = lazy(() => some(union([
21
- strong,
22
- some(inline, blankWith('*')),
23
- open(some(inline, '*'), union([
24
- emstrong,
25
- strong,
26
- emphasis,
27
- ])),
28
- ])));
29
-
30
- export const emstrong: EmStrongParser = lazy(() => surround(
31
- str('***'),
32
- syntax(Syntax.none, 1, 1, State.none,
33
- startTight(some(union([
34
- some(inline, blankWith('*')),
35
- open(some(inline, '*'), inline),
36
- ])))),
37
- str(/^\*{1,3}/), false,
38
- ([, bs, cs], rest, context): Result<HTMLElement | string, typeof context> => {
39
- assert(cs.length === 1);
40
- switch (cs[0]) {
41
- case '***':
42
- return [[html('em', [html('strong', defrag(bs))])], rest];
43
- case '**':
44
- return bind<EmphasisParser>(
45
- subemphasis,
46
- (ds, rest) =>
47
- rest.slice(0, 1) === '*'
48
- ? [[html('em', unshift([html('strong', defrag(bs))], defrag(ds)))], rest.slice(1)]
49
- : [unshift(['*', html('strong', defrag(bs))], ds), rest])
50
- ({ source: rest, context }) ?? [['*', html('strong', defrag(bs))], rest];
51
- case '*':
52
- return bind<StrongParser>(
53
- substrong,
54
- (ds, rest) =>
55
- rest.slice(0, 2) === '**'
56
- ? [[html('strong', unshift([html('em', defrag(bs))], defrag(ds)))], rest.slice(2)]
57
- : [unshift(['**', html('em', defrag(bs))], ds), rest])
58
- ({ source: rest, context }) ?? [['**', html('em', defrag(bs))], rest];
59
- }
60
- assert(false);
61
- },
62
- ([as, bs], rest) => [unshift(as, bs), rest]));
@@ -1,30 +0,0 @@
1
- import { undefined } from 'spica/global';
2
- import { EscapeParser } from '../inline';
3
- import { union } from '../../combinator';
4
- import { str } from '../source';
5
-
6
- const repeat = str(/^(.)\1*/);
7
-
8
- export const escape: EscapeParser = union([({ source, context }) => {
9
- if (source.length < 3) return;
10
- switch (source[0]) {
11
- case '*':
12
- if (source.length < 4) return;
13
- assert(source[3]);
14
- return source[3] === source[0]
15
- && source[2] === source[0]
16
- && source[1] === source[0]
17
- ? repeat({ source, context })
18
- : undefined;
19
- case '+':
20
- case '~':
21
- case '=':
22
- assert(source[2]);
23
- return source[2] === source[0]
24
- && source[1] === source[0]
25
- ? repeat({ source, context })
26
- : undefined;
27
- default:
28
- return;
29
- }
30
- }]);