securemark 0.260.6 → 0.261.2

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 (49) 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 +983 -630
  5. package/markdown.d.ts +5 -32
  6. package/package.json +9 -9
  7. package/src/debug.test.ts +3 -3
  8. package/src/parser/api/parse.test.ts +1 -1
  9. package/src/parser/block/blockquote.test.ts +2 -2
  10. package/src/parser/block/dlist.test.ts +1 -1
  11. package/src/parser/block/extension/example.test.ts +1 -1
  12. package/src/parser/block/extension/fig.test.ts +1 -1
  13. package/src/parser/block/heading.test.ts +2 -2
  14. package/src/parser/block/olist.ts +4 -6
  15. package/src/parser/block/paragraph.test.ts +1 -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/processor/figure.ts +2 -1
  43. package/src/parser/processor/footnote.ts +2 -1
  44. package/src/parser/source/str.ts +4 -2
  45. package/src/parser/source/text.test.ts +9 -4
  46. package/src/parser/source/text.ts +9 -16
  47. package/src/renderer/render.ts +3 -3
  48. package/src/parser/inline/emstrong.ts +0 -62
  49. package/src/parser/inline/escape.ts +0 -30
@@ -3,7 +3,7 @@ import { RenderingOptions } from '../../';
3
3
  import { code } from './render/code';
4
4
  import { math } from './render/math';
5
5
  import { media } from './render/media';
6
- import { querySelectorAll } from 'typed-dom/query';
6
+ import { querySelectorAllWith } from 'typed-dom/query';
7
7
  import { reduce } from 'spica/memoize';
8
8
 
9
9
  const selector = 'img.media:not(.invalid):not([src])[data-src], a > :not(img).media:not(.invalid), pre.code:not(.invalid), .math:not(.invalid)';
@@ -14,8 +14,8 @@ const extend = reduce((opts: RenderingOptions): RenderingOptions =>
14
14
  export function render(source: HTMLElement, opts: RenderingOptions = {}): void {
15
15
  opts = extend(opts);
16
16
  const base = location.href;
17
- for (const el of querySelectorAll<HTMLElement>(source, selector)) {
18
- render_(base, el, opts);
17
+ for (let es = querySelectorAllWith<HTMLElement>(source, selector), i = 0; i < es.length; ++i) {
18
+ render_(base, es[i], opts);
19
19
  }
20
20
  }
21
21
 
@@ -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
- }]);