securemark 0.263.1 → 0.264.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 (48) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/index.js +1205 -3025
  3. package/markdown.d.ts +1 -1
  4. package/package.json +18 -18
  5. package/src/combinator/data/parser/context.ts +3 -2
  6. package/src/parser/api/bind.test.ts +1 -1
  7. package/src/parser/api/parse.test.ts +3 -3
  8. package/src/parser/block/blockquote.test.ts +3 -3
  9. package/src/parser/block/dlist.ts +2 -3
  10. package/src/parser/block/extension/example.test.ts +1 -1
  11. package/src/parser/block/extension/fig.ts +2 -1
  12. package/src/parser/block/extension/figure.ts +2 -3
  13. package/src/parser/block/extension/table.ts +2 -3
  14. package/src/parser/block/heading.test.ts +1 -1
  15. package/src/parser/block/paragraph.test.ts +1 -1
  16. package/src/parser/block/paragraph.ts +2 -3
  17. package/src/parser/block/reply.ts +2 -3
  18. package/src/parser/context.ts +15 -19
  19. package/src/parser/inline/annotation.ts +1 -1
  20. package/src/parser/inline/bracket.test.ts +1 -1
  21. package/src/parser/inline/bracket.ts +1 -1
  22. package/src/parser/inline/deletion.test.ts +2 -2
  23. package/src/parser/inline/emphasis.test.ts +2 -2
  24. package/src/parser/inline/emphasis.ts +2 -2
  25. package/src/parser/inline/extension/index.test.ts +28 -32
  26. package/src/parser/inline/extension/index.ts +1 -1
  27. package/src/parser/inline/extension/indexee.ts +22 -12
  28. package/src/parser/inline/extension/placeholder.test.ts +10 -12
  29. package/src/parser/inline/extension/placeholder.ts +7 -7
  30. package/src/parser/inline/html.test.ts +1 -1
  31. package/src/parser/inline/html.ts +2 -2
  32. package/src/parser/inline/insertion.test.ts +2 -2
  33. package/src/parser/inline/link.test.ts +6 -5
  34. package/src/parser/inline/link.ts +43 -42
  35. package/src/parser/inline/mark.test.ts +11 -11
  36. package/src/parser/inline/mark.ts +12 -6
  37. package/src/parser/inline/strong.test.ts +2 -2
  38. package/src/parser/inline/strong.ts +2 -2
  39. package/src/parser/inline.test.ts +8 -7
  40. package/src/parser/source/escapable.test.ts +1 -1
  41. package/src/parser/source/escapable.ts +7 -1
  42. package/src/parser/source/text.test.ts +24 -35
  43. package/src/parser/source/text.ts +2 -15
  44. package/src/parser/visibility.ts +1 -6
  45. package/src/parser/locale/ja.test.ts +0 -14
  46. package/src/parser/locale/ja.ts +0 -3
  47. package/src/parser/locale.test.ts +0 -26
  48. package/src/parser/locale.ts +0 -61
@@ -1,14 +0,0 @@
1
- import { japanese } from './ja';
2
-
3
- describe('Unit: parser/locale/ja', () => {
4
- describe('japanese', () => {
5
- it('ja', () => {
6
- assert(japanese('、'));
7
- assert(japanese('。'));
8
- assert(japanese('!'));
9
- assert(japanese('?'));
10
- });
11
-
12
- });
13
-
14
- });
@@ -1,3 +0,0 @@
1
- export function japanese(char: string): boolean {
2
- return /^[\p{Ideo}\p{scx=Hiragana}\p{scx=Katakana}~!?]/u.test(char);
3
- }
@@ -1,26 +0,0 @@
1
- import { block } from './block';
2
- import { some } from '../combinator';
3
- import { inspect } from '../debug.test';
4
-
5
- describe('Unit: parser/locale', () => {
6
- describe('locale', () => {
7
- const parser = (source: string) => some(block)({ source, context: {} });
8
-
9
- it('basic', () => {
10
- assert.deepStrictEqual(inspect(parser('。\\\n0')), [['<p>。<span class="linebreak"></span>0</p>'], '']);
11
- assert.deepStrictEqual(inspect(parser('。 \\\n0')), [['<p>。<span class="linebreak"></span>0</p>'], '']);
12
- assert.deepStrictEqual(inspect(parser('_。_\\\n0')), [['<p><em>。</em><span class="linebreak"></span>0</p>'], '']);
13
- assert.deepStrictEqual(inspect(parser('!> 。\\\n0')), [['<blockquote><section><p>。<span class="linebreak"></span>0</p><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
14
- assert.deepStrictEqual(inspect(parser('[。](a)\\\n0')), [['<p><ruby>。<rp>(</rp><rt>a</rt><rp>)</rp></ruby><span class="linebreak"></span>0</p>'], '']);
15
- assert.deepStrictEqual(inspect(parser('[。 ](a )\\\n0')), [['<p><ruby>。<rp>(</rp><rt>a</rt><rp>)</rp></ruby><span class="linebreak"></span>0</p>'], '']);
16
- assert.deepStrictEqual(inspect(parser('。<wbr>\\\n0')), [['<p>。<wbr><span class="linebreak"></span>0</p>'], '']);
17
- });
18
-
19
- it('ja', () => {
20
- assert.deepStrictEqual(inspect(parser('。\\\n0')), [['<p>。<span class="linebreak"></span>0</p>'], '']);
21
- assert.deepStrictEqual(inspect(parser('\\。\\\n0')), [['<p>。<span class="linebreak"></span>0</p>'], '']);
22
- });
23
-
24
- });
25
-
26
- });
@@ -1,61 +0,0 @@
1
- import { Parser } from '../combinator/data/parser';
2
- import { fmap } from '../combinator';
3
- import { japanese } from './locale/ja';
4
- import { html } from 'typed-dom/dom';
5
-
6
- export function localize<P extends Parser<HTMLElement | string>>(parser: P): P;
7
- export function localize(parser: Parser<HTMLElement | string>): Parser<HTMLElement | string> {
8
- return fmap(parser, ns => {
9
- if (ns.length === 0) return ns;
10
- const el = ns.length === 1 && typeof ns[0] === 'object'
11
- ? ns[0]
12
- : html('div', ns);
13
- for (let es = el.querySelectorAll('.linebreak:not(:empty)'),
14
- len = es.length, i = 0; i < len; ++i) {
15
- const el = es[i];
16
- assert(el.firstChild!.textContent === ' ');
17
- if (!check(el)) continue;
18
- el.firstChild!.remove();
19
- }
20
- return ns;
21
- });
22
- }
23
-
24
- function check(el: Element): boolean {
25
- const char = lastChar(el);
26
- if (!char) return false;
27
- assert([...char].length === 1);
28
- return japanese(char);
29
- }
30
-
31
- function lastChar(node: Element | Text | null): string {
32
- while (node = node?.previousSibling as typeof node) {
33
- if (!('id' in node)) return [...node.data.slice(-2)].pop() ?? '';
34
- if (node.firstChild) return [...text(node).slice(-2)].pop() ?? '';
35
- switch (node.tagName) {
36
- case 'BR':
37
- return '';
38
- case 'SPAN':
39
- switch (node.className) {
40
- case 'linebreak':
41
- return '';
42
- }
43
- }
44
- }
45
- return '';
46
- }
47
-
48
- function text(el: Element): string {
49
- switch (el.tagName) {
50
- case 'RUBY':
51
- for (let ns = el.childNodes, i = ns.length; i--;) {
52
- const child = ns[i] as Text | Element;
53
- if ('id' in child) continue;
54
- return child.data;
55
- }
56
- assert(false);
57
- return '';
58
- default:
59
- return el.textContent!;
60
- }
61
- }