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.
Files changed (57) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/index.js +1117 -646
  3. package/markdown.d.ts +0 -11
  4. package/package.json +9 -9
  5. package/src/combinator/data/parser/context/memo.ts +1 -1
  6. package/src/combinator/data/parser/inits.ts +1 -1
  7. package/src/combinator/data/parser/sequence.ts +1 -1
  8. package/src/debug.test.ts +3 -3
  9. package/src/parser/api/bind.ts +2 -2
  10. package/src/parser/api/parse.test.ts +1 -1
  11. package/src/parser/api/parse.ts +1 -1
  12. package/src/parser/block/blockquote.test.ts +31 -31
  13. package/src/parser/block/blockquote.ts +1 -1
  14. package/src/parser/block/dlist.ts +1 -1
  15. package/src/parser/block/extension/aside.test.ts +3 -3
  16. package/src/parser/block/extension/aside.ts +1 -0
  17. package/src/parser/block/extension/example.test.ts +11 -11
  18. package/src/parser/block/extension/example.ts +1 -1
  19. package/src/parser/block/extension/fig.test.ts +5 -5
  20. package/src/parser/block/extension/figure.test.ts +2 -2
  21. package/src/parser/block/extension/figure.ts +1 -1
  22. package/src/parser/block/extension/message.ts +1 -1
  23. package/src/parser/block/extension/table.ts +1 -1
  24. package/src/parser/block/olist.ts +5 -7
  25. package/src/parser/block/reply.ts +1 -1
  26. package/src/parser/block/table.ts +8 -8
  27. package/src/parser/block/ulist.ts +1 -1
  28. package/src/parser/block.ts +1 -1
  29. package/src/parser/inline/bracket.ts +1 -1
  30. package/src/parser/inline/comment.ts +1 -1
  31. package/src/parser/inline/deletion.ts +2 -2
  32. package/src/parser/inline/emphasis.ts +3 -3
  33. package/src/parser/inline/extension/indexee.ts +9 -8
  34. package/src/parser/inline/extension/placeholder.ts +1 -1
  35. package/src/parser/inline/html.ts +1 -1
  36. package/src/parser/inline/insertion.ts +2 -2
  37. package/src/parser/inline/link.ts +1 -1
  38. package/src/parser/inline/mark.ts +2 -2
  39. package/src/parser/inline/media.ts +1 -1
  40. package/src/parser/inline/ruby.ts +1 -1
  41. package/src/parser/inline/strong.ts +3 -3
  42. package/src/parser/inline/template.ts +1 -1
  43. package/src/parser/inline.ts +0 -3
  44. package/src/parser/locale/ja.ts +1 -1
  45. package/src/parser/locale.test.ts +1 -1
  46. package/src/parser/locale.ts +5 -4
  47. package/src/parser/processor/figure.test.ts +3 -3
  48. package/src/parser/processor/figure.ts +10 -8
  49. package/src/parser/processor/footnote.test.ts +2 -2
  50. package/src/parser/processor/footnote.ts +17 -12
  51. package/src/parser/source/str.ts +4 -2
  52. package/src/parser/source/text.ts +2 -2
  53. package/src/renderer/render.ts +3 -3
  54. package/src/util/info.ts +7 -5
  55. package/src/util/quote.ts +14 -12
  56. package/src/util/toc.ts +14 -8
  57. package/src/parser/inline/escape.ts +0 -21
package/src/util/toc.ts CHANGED
@@ -1,22 +1,26 @@
1
1
  import { undefined } from 'spica/global';
2
- import { html } from 'typed-dom/dom';
3
- import { duffEach, duffReduce } from 'spica/duff';
4
2
  import { push } from 'spica/array';
3
+ import { html } from 'typed-dom/dom';
4
+ import { querySelectorAll } from 'typed-dom/query';
5
5
 
6
6
  // Bug: Firefox
7
7
  //const selector = 'h1 h2 h3 h4 h5 h6 aside.aside'.split(' ').map(s => `:scope > ${s}[id]`).join();
8
8
  const selector = ':is(h1, h2, h3, h4, h5, h6, aside.aside)[id]';
9
9
 
10
10
  export function toc(source: DocumentFragment | HTMLElement | ShadowRoot): HTMLUListElement {
11
- const hs = duffReduce(source.querySelectorAll(selector), (acc, el) => {
11
+ const hs: HTMLHeadingElement[] = [];
12
+ for (let es = querySelectorAll(source, selector), i = 0; i < es.length; ++i) {
13
+ const el = es[i];
12
14
  assert(el.parentNode === source);
13
15
  switch (el.tagName) {
14
16
  case 'ASIDE':
15
- return push(acc, [html(el.firstElementChild!.tagName.toLowerCase() as 'h1', { id: el.id, class: 'aside' }, el.firstElementChild!.cloneNode(true).childNodes)]);
17
+ hs.push(html(el.firstElementChild!.tagName.toLowerCase() as 'h1', { id: el.id, class: 'aside' }, el.firstElementChild!.cloneNode(true).childNodes));
18
+ continue;
16
19
  default:
17
- return push(acc, [el as HTMLHeadingElement]);
20
+ hs.push(el as HTMLHeadingElement);
21
+ continue;
18
22
  }
19
- }, [] as HTMLHeadingElement[]);
23
+ }
20
24
  return parse(cons(hs));
21
25
  }
22
26
 
@@ -58,7 +62,9 @@ function level(h: HTMLHeadingElement): number {
58
62
  }
59
63
 
60
64
  function unlink(h: HTMLHeadingElement): Iterable<Node> {
61
- duffEach(h.getElementsByTagName('a'), el =>
62
- void el.replaceWith(...el.childNodes));
65
+ for (let es = h.getElementsByTagName('a'), len = es.length, i = 0; i < len; ++i) {
66
+ const el = es[i];
67
+ el.replaceWith(...el.childNodes);
68
+ }
63
69
  return h.childNodes;
64
70
  }
@@ -1,21 +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
- switch (source[0]) {
10
- case '+':
11
- case '~':
12
- case '=':
13
- if (!source[2]) return;
14
- return source[2] === source[0]
15
- && source[1] === source[0]
16
- ? repeat({ source, context })
17
- : undefined;
18
- default:
19
- return;
20
- }
21
- }]);