securemark 0.269.0 → 0.270.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.270.0
4
+
5
+ - Change the operator precedence of double quotation to 3.
6
+
7
+ ## 0.269.1
8
+
9
+ - Refactoring.
10
+
3
11
  ## 0.269.0
4
12
 
5
13
  - Change media syntax to line-level syntax.
package/README.md CHANGED
@@ -68,11 +68,11 @@ Secure markdown renderer working on browsers for user input data.
68
68
  |P| Operators |
69
69
  |-|------------------|
70
70
  |9| \n, \\\n |
71
- |8| `, " |
71
+ |8| ` |
72
72
  |6| (()), [[]], ${}$ |
73
73
  |5| \<tag>\</tag> |
74
74
  |4| [% %] |
75
- |3| $ |
75
+ |3| $, " |
76
76
  |2| (), [], {} |
77
77
  |1| _, *, ==, ++, ~~ |
78
78
 
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.269.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.270.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
2
2
  (function webpackUniversalModuleDefinition(root, factory) {
3
3
  if(typeof exports === 'object' && typeof module === 'object')
4
4
  module.exports = factory(require("Prism"), require("DOMPurify"));
@@ -5744,9 +5744,7 @@ const combinator_1 = __webpack_require__(2087);
5744
5744
  const inline_1 = __webpack_require__(1160);
5745
5745
  const visibility_1 = __webpack_require__(7618);
5746
5746
  const dom_1 = __webpack_require__(3252);
5747
- exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.surround)('((', (0, combinator_1.constraint)(256 /* State.annotation */, false, (0, combinator_1.syntax)(0 /* Syntax.none */, 6, 1, 256 /* State.annotation */ | 8 /* State.media */, (0, visibility_1.startLoose)((0, combinator_1.context)({
5748
- delimiters: undefined
5749
- }, (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ')', [[/^\\?\n/, 9], [')', 2], ['))', 6]])), ')'))), '))', false, ([, ns], rest) => [[(0, dom_1.html)('sup', {
5747
+ exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.surround)('((', (0, combinator_1.constraint)(256 /* State.annotation */, false, (0, combinator_1.syntax)(0 /* Syntax.none */, 6, 1, 256 /* State.annotation */ | 8 /* State.media */, (0, visibility_1.startLoose)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ')', [[/^\\?\n/, 9], [')', 2], ['))', 6]]), ')'))), '))', false, ([, ns], rest) => [[(0, dom_1.html)('sup', {
5750
5748
  class: 'annotation'
5751
5749
  }, [(0, dom_1.html)('span', (0, visibility_1.trimNode)((0, dom_1.defrag)(ns)))])], rest]));
5752
5750
 
@@ -5978,7 +5976,7 @@ exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, comb
5978
5976
  class: 'paren'
5979
5977
  }, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))], rest], ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.syntax)(8 /* Syntax.bracket */, 2, 1, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, ']', [[']', 2]])), (0, source_1.str)(']'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)([''], (0, array_1.unshift)(as, bs)), rest]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.syntax)(8 /* Syntax.bracket */, 2, 1, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, '}', [['}', 2]])), (0, source_1.str)('}'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]),
5980
5978
  // Control media blinking in editing rather than control confusion of pairs of quote marks.
5981
- (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.syntax)(0 /* Syntax.none */, 8, 1, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, '"', [['"', 8]])), (0, source_1.str)('"'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest])]));
5979
+ (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.syntax)(0 /* Syntax.none */, 3, 1, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, '"', [['"', 3]])), (0, source_1.str)('"'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest])]));
5982
5980
 
5983
5981
  /***/ }),
5984
5982
 
@@ -6146,6 +6144,7 @@ function identity(id, text, name = 'index') {
6146
6144
  case 'index':
6147
6145
  return `${name}:${id ?? ''}:${cs.slice(0, 97).join('')}...`;
6148
6146
  case 'mark':
6147
+ case 'note':
6149
6148
  return `${name}:${id ?? ''}:${cs.slice(0, 50).join('')}...${cs.slice(-47).join('')}`;
6150
6149
  }
6151
6150
  }
@@ -6701,9 +6700,7 @@ const source_1 = __webpack_require__(6743);
6701
6700
  const visibility_1 = __webpack_require__(7618);
6702
6701
  const util_1 = __webpack_require__(9437);
6703
6702
  const dom_1 = __webpack_require__(3252);
6704
- exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.surround)('[[', (0, combinator_1.constraint)(128 /* State.reference */, false, (0, combinator_1.syntax)(256 /* Syntax.reference */, 6, 1, 256 /* State.annotation */ | 128 /* State.reference */ | 8 /* State.media */, (0, visibility_1.startLoose)((0, combinator_1.context)({
6705
- delimiters: undefined
6706
- }, (0, combinator_1.subsequence)([abbr, (0, combinator_1.open)((0, source_1.stropt)(/^(?=\^)/), (0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]])), (0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]])])), ']'))), ']]', false, ([, ns], rest) => [[(0, dom_1.html)('sup', attributes(ns), [(0, dom_1.html)('span', (0, visibility_1.trimNode)((0, dom_1.defrag)(ns)))])], rest]));
6703
+ exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.surround)('[[', (0, combinator_1.constraint)(128 /* State.reference */, false, (0, combinator_1.syntax)(256 /* Syntax.reference */, 6, 1, 256 /* State.annotation */ | 128 /* State.reference */ | 8 /* State.media */, (0, visibility_1.startLoose)((0, combinator_1.subsequence)([abbr, (0, combinator_1.open)((0, source_1.stropt)(/^(?=\^)/), (0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]])), (0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]])]), ']'))), ']]', false, ([, ns], rest) => [[(0, dom_1.html)('sup', attributes(ns), [(0, dom_1.html)('span', (0, visibility_1.trimNode)((0, dom_1.defrag)(ns)))])], rest]));
6707
6704
  const abbr = (0, combinator_1.creation)((0, combinator_1.bind)((0, combinator_1.surround)('^', (0, combinator_1.union)([(0, source_1.str)(/^(?![0-9]+\s?[|\]])[0-9A-Za-z]+(?:(?:-|(?=\W)(?!'\d)'?(?!\.\d)\.?(?!,\S),? ?)[0-9A-Za-z]+)*(?:-|'?\.?,? ?)?/)]), /^\|?(?=]])|^\|[^\S\n]*/), ([source], rest) => [[(0, dom_1.html)('abbr', source)], rest.replace(visibility_1.regBlankStart, '')]));
6708
6705
  function attributes(ns) {
6709
6706
  return typeof ns[0] === 'object' && ns[0].tagName === 'ABBR' ? {
@@ -7085,7 +7082,9 @@ function build(syntax, marker, splitter = '_') {
7085
7082
  const ref = refs[i];
7086
7083
  const identifier = ref.getAttribute('data-abbr') || ` ${ref.firstElementChild.innerHTML}`;
7087
7084
  if (titles.has(identifier)) continue;
7088
- const content = (0, dom_1.frag)(ref.firstElementChild.cloneNode(true).childNodes);
7085
+ const content = (0, dom_1.html)('span', {
7086
+ id: (0, indexee_1.identity)(opts.id, (0, indexee_1.text)(ref.firstElementChild), 'note')
7087
+ }, ref.firstElementChild.cloneNode(true).childNodes);
7089
7088
  const title = (0, indexee_1.text)(content).trim();
7090
7089
  if (!title) continue;
7091
7090
  titles.set(identifier, title);
@@ -7131,7 +7130,6 @@ function build(syntax, marker, splitter = '_') {
7131
7130
  ref.lastChild?.remove();
7132
7131
  }
7133
7132
  const title = titles.get(identifier);
7134
- const content = (0, dom_1.frag)(ref.firstElementChild.cloneNode(true).childNodes);
7135
7133
  const refIndex = ++count;
7136
7134
  const refId = opts.id !== '' ? `${syntax}:${opts.id ?? ''}:ref:${refIndex}` : undefined;
7137
7135
  const def = false || defs.get(identifier) || defs.set(identifier, (0, dom_1.html)('li', {
@@ -7157,7 +7155,7 @@ function build(syntax, marker, splitter = '_') {
7157
7155
  }, marker(defIndex, abbr)));
7158
7156
  def.lastChild.appendChild((0, dom_1.html)('a', {
7159
7157
  href: refId && `#${refId}`,
7160
- title: abbr && (0, indexee_1.text)(content).trim() || undefined
7158
+ title: abbr && (0, indexee_1.text)((0, dom_1.frag)(ref.firstElementChild.cloneNode(true).childNodes)).trim() || undefined
7161
7159
  }, `^${refIndex}`));
7162
7160
  }
7163
7161
  if (defs.size > 0 || footnote) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securemark",
3
- "version": "0.269.0",
3
+ "version": "0.270.0",
4
4
  "description": "Secure markdown renderer working on browsers for user input data.",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/falsandtru/securemark",
@@ -28,17 +28,17 @@
28
28
  "LICENSE"
29
29
  ],
30
30
  "devDependencies": {
31
- "@types/dompurify": "2.4.0",
31
+ "@types/dompurify": "3.0.0",
32
32
  "@types/jquery": "3.5.16",
33
33
  "@types/mathjax": "0.0.37",
34
34
  "@types/mocha": "10.0.1",
35
35
  "@types/power-assert": "1.5.8",
36
36
  "@types/prismjs": "1.26.0",
37
- "@typescript-eslint/parser": "^5.54.0",
37
+ "@typescript-eslint/parser": "^5.55.0",
38
38
  "babel-loader": "^9.1.2",
39
39
  "babel-plugin-unassert": "^3.2.0",
40
40
  "concurrently": "^7.6.0",
41
- "eslint": "^8.35.0",
41
+ "eslint": "^8.36.0",
42
42
  "eslint-plugin-redos": "^4.4.5",
43
43
  "eslint-webpack-plugin": "^4.0.0",
44
44
  "glob": "^8.1.0",
@@ -49,13 +49,13 @@
49
49
  "karma-mocha": "^2.0.1",
50
50
  "karma-power-assert": "^1.0.0",
51
51
  "mocha": "^10.2.0",
52
- "npm-check-updates": "^16.7.10",
52
+ "npm-check-updates": "^16.7.12",
53
53
  "semver": "^7.3.8",
54
54
  "spica": "0.0.719",
55
55
  "ts-loader": "^9.4.2",
56
56
  "typed-dom": "^0.0.317",
57
57
  "typescript": "4.9.5",
58
- "webpack": "^5.75.0",
58
+ "webpack": "^5.76.1",
59
59
  "webpack-cli": "^5.0.1",
60
60
  "webpack-merge": "^5.8.0"
61
61
  },
@@ -214,15 +214,15 @@ describe('Unit: parser/api/bind', () => {
214
214
  cfgs.footnotes.references?.outerHTML,
215
215
  html('ol', [
216
216
  html('li', { id: 'reference::def:1' }, [
217
- '1',
217
+ html('span', { id: 'note::1' }, '1'),
218
218
  html('sup', [html('a', { href: '#reference::ref:1' }, '^1')]),
219
219
  ]),
220
220
  html('li', { id: 'reference::def:2' }, [
221
- '2',
221
+ html('span', { id: 'note::2' }, '2'),
222
222
  html('sup', [html('a', { href: '#reference::ref:2' }, '^2')]),
223
223
  ]),
224
224
  html('li', { id: 'reference::def:3' }, [
225
- '3',
225
+ html('span', { id: 'note::3' }, '3'),
226
226
  html('sup', [html('a', { href: '#reference::ref:3' }, '^3')]),
227
227
  ]),
228
228
  ]).outerHTML);
@@ -135,7 +135,7 @@ describe('Unit: parser/api/parse', () => {
135
135
  '<p><a href="https://source/x/a" target="_blank"><img class="media" data-src="https://source/x/a" alt=""></a></p>',
136
136
  '<p><a href="/z/a" target="_blank"><img class="media" data-src="/z/a" alt=""></a></p>',
137
137
  '<p><a href="https://source/a" target="_blank"><img class="media" data-src="https://source/a" alt=""></a></p>',
138
- '<ol class="annotations"><li id="annotation::def:1" data-marker="*1">a<sup><a href="#annotation::ref:1">^1</a></sup></li></ol>',
138
+ '<ol class="annotations"><li id="annotation::def:1" data-marker="*1"><span id="note::a">a</span><sup><a href="#annotation::ref:1">^1</a></sup></li></ol>',
139
139
  ]);
140
140
  assert.deepStrictEqual(
141
141
  [...parse([
@@ -208,11 +208,11 @@ describe('Unit: parser/api/parse', () => {
208
208
  [
209
209
  '<figure data-type="math" data-label="$-a" data-group="$" data-number="1" id="label:$-a"><figcaption><span class="figindex">(1)</span><span class="figtext"></span></figcaption><div><div class="math" translate="no">$$\n$$</div></div></figure>',
210
210
  '<p><sup class="annotation" id="annotation::ref:1" title="(1)"><span hidden=""><a class="label" data-label="$-a" href="#label:$-a">(1)</a><sup class="reference" id="reference::ref:1" title="b"><span hidden="">b</span><a href="#reference::def:1">[1]</a></sup><sup class="reference" id="reference::ref:2" title="cd"><span hidden="">c<em>d</em></span><a href="#reference::def:2">[2]</a></sup></span><a href="#annotation::def:1">*1</a></sup></p>',
211
- '<ol class="annotations"><li id="annotation::def:1" data-marker="*1"><a class="label" data-label="$-a" href="#label:$-a">(1)</a><sup class="reference" id="reference::ref:1" title="b"><span hidden="">b</span><a href="#reference::def:1">[1]</a></sup><sup class="reference" id="reference::ref:2" title="cd"><span hidden="">c<em>d</em></span><a href="#reference::def:2">[2]</a></sup><sup><a href="#annotation::ref:1">^1</a></sup></li></ol>',
211
+ '<ol class="annotations"><li id="annotation::def:1" data-marker="*1"><span id="note::(1)"><a class="label" data-label="$-a" href="#label:$-a">(1)</a><sup class="reference" id="reference::ref:1" title="b"><span hidden="">b</span><a href="#reference::def:1">[1]</a></sup><sup class="reference" id="reference::ref:2" title="cd"><span hidden="">c<em>d</em></span><a href="#reference::def:2">[2]</a></sup></span><sup><a href="#annotation::ref:1">^1</a></sup></li></ol>',
212
212
  ]);
213
213
  assert.deepStrictEqual(
214
214
  footnotes.references.outerHTML,
215
- '<ol><li id="reference::def:1">b<sup><a href="#reference::ref:1">^1</a></sup></li><li id="reference::def:2">c<em>d</em><sup><a href="#reference::ref:2">^2</a></sup></li></ol>');
215
+ '<ol><li id="reference::def:1"><span id="note::b">b</span><sup><a href="#reference::ref:1">^1</a></sup></li><li id="reference::def:2"><span id="note::cd">c<em>d</em></span><sup><a href="#reference::ref:2">^2</a></sup></li></ol>');
216
216
  });
217
217
 
218
218
  it('normalize', () => {
@@ -96,7 +96,7 @@ describe('Unit: parser/block/blockquote', () => {
96
96
  assert.deepStrictEqual(inspect(parser('!>> ## a\n> ## a')), [['<blockquote><blockquote><section><h2>a</h2><h2>References</h2><ol class="references"></ol></section></blockquote><section><h2>a</h2><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
97
97
  assert.deepStrictEqual(inspect(parser('!>> ~ a\n> ~ a')), [['<blockquote><blockquote><section><dl><dt>a</dt><dd></dd></dl><h2>References</h2><ol class="references"></ol></section></blockquote><section><dl><dt>a</dt><dd></dd></dl><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
98
98
  assert.deepStrictEqual(inspect(parser('!>> ~~~figure $test-a\n>> > \n>>\n~~~\n> ~~~figure $test-a\n> > \n>\n[#a]\n~~~')), [['<blockquote><blockquote><section><figure data-type="quote" data-label="test-a" data-group="test" data-number="1"><figcaption><span class="figindex">Test 1. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure><h2>References</h2><ol class="references"></ol></section></blockquote><section><figure data-type="quote" data-label="test-a" data-group="test" data-number="1"><figcaption><span class="figindex">Test 1. </span><span class="figtext"><a class="index">a</a></span></figcaption><div><blockquote></blockquote></div></figure><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
99
- assert.deepStrictEqual(inspect(parser('!>> ((a))\n> ((a))')), [['<blockquote><blockquote><section><p><sup class="annotation disabled" title="a"><span hidden="">a</span><a>*1</a></sup></p><ol class="annotations"><li data-marker="*1">a<sup><a>^1</a></sup></li></ol><h2>References</h2><ol class="references"></ol></section></blockquote><section><p><sup class="annotation disabled" title="a"><span hidden="">a</span><a>*1</a></sup></p><ol class="annotations"><li data-marker="*1">a<sup><a>^1</a></sup></li></ol><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
99
+ assert.deepStrictEqual(inspect(parser('!>> ((a))\n> ((a))')), [['<blockquote><blockquote><section><p><sup class="annotation disabled" title="a"><span hidden="">a</span><a>*1</a></sup></p><ol class="annotations"><li data-marker="*1"><span>a</span><sup><a>^1</a></sup></li></ol><h2>References</h2><ol class="references"></ol></section></blockquote><section><p><sup class="annotation disabled" title="a"><span hidden="">a</span><a>*1</a></sup></p><ol class="annotations"><li data-marker="*1"><span>a</span><sup><a>^1</a></sup></li></ol><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
100
100
  });
101
101
 
102
102
  });
@@ -23,7 +23,7 @@ describe('Unit: parser/block/extension/example', () => {
23
23
  assert.deepStrictEqual(inspect(parser('~~~example/markdown\n[$fig-a]\n!https://host\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">[$fig-a]\n!https://host</pre><hr><section><figure data-type="media" data-label="fig-a" data-group="fig" data-number="1"><figcaption><span class="figindex">Fig. 1. </span><span class="figtext"></span></figcaption><div><a href="https://host" target="_blank"><img class="media" data-src="https://host" alt=""></a></div></figure><h2>References</h2><ol class="references"></ol></section></aside>'], '']);
24
24
  assert.deepStrictEqual(inspect(parser('~~~example/markdown\n## a\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">## a</pre><hr><section><h2>a</h2><h2>References</h2><ol class="references"></ol></section></aside>'], '']);
25
25
  assert.deepStrictEqual(inspect(parser('~~~example/markdown\n~ a\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">~ a</pre><hr><section><dl><dt>a</dt><dd></dd></dl><h2>References</h2><ol class="references"></ol></section></aside>'], '']);
26
- assert.deepStrictEqual(inspect(parser('~~~example/markdown\n((a))[[b]]\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">((a))[[b]]</pre><hr><section><p><sup class="annotation disabled" title="a"><span hidden="">a</span><a>*1</a></sup><sup class="reference disabled" title="b"><span hidden="">b</span><a>[1]</a></sup></p><ol class="annotations"><li data-marker="*1">a<sup><a>^1</a></sup></li></ol><h2>References</h2><ol class="references"><li>b<sup><a>^1</a></sup></li></ol></section></aside>'], '']);
26
+ assert.deepStrictEqual(inspect(parser('~~~example/markdown\n((a))[[b]]\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">((a))[[b]]</pre><hr><section><p><sup class="annotation disabled" title="a"><span hidden="">a</span><a>*1</a></sup><sup class="reference disabled" title="b"><span hidden="">b</span><a>[1]</a></sup></p><ol class="annotations"><li data-marker="*1"><span>a</span><sup><a>^1</a></sup></li></ol><h2>References</h2><ol class="references"><li><span>b</span><sup><a>^1</a></sup></li></ol></section></aside>'], '']);
27
27
  assert.deepStrictEqual(inspect(parser('~~~~example/markdown\na\n~~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">a</pre><hr><section><p>a</p><h2>References</h2><ol class="references"></ol></section></aside>'], '']);
28
28
  assert.deepStrictEqual(inspect(parser('~~~example/math\na\n~~~')), [['<aside class="example" data-type="math"><pre translate="no">a</pre><hr><div class="math" translate="no">$$\na\n$$</div></aside>'], '']);
29
29
  assert.deepStrictEqual(inspect(parser(`~~~example/math\n0${'\n'.repeat(100)}~~~`), '>'), [['<aside class="example" data-type="math">'], '']);
@@ -1,5 +1,5 @@
1
1
  import { AnnotationParser } from '../inline';
2
- import { union, some, context, syntax, constraint, surround, lazy } from '../../combinator';
2
+ import { union, some, syntax, constraint, surround, lazy } from '../../combinator';
3
3
  import { inline } from '../inline';
4
4
  import { Syntax, State } from '../context';
5
5
  import { startLoose, trimNode } from '../visibility';
@@ -10,8 +10,7 @@ export const annotation: AnnotationParser = lazy(() => surround(
10
10
  constraint(State.annotation, false,
11
11
  syntax(Syntax.none, 6, 1, State.annotation | State.media,
12
12
  startLoose(
13
- context({ delimiters: undefined },
14
- some(union([inline]), ')', [[/^\\?\n/, 9], [')', 2], ['))', 6]])), ')'))),
13
+ some(union([inline]), ')', [[/^\\?\n/, 9], [')', 2], ['))', 6]]), ')'))),
15
14
  '))',
16
15
  false,
17
16
  ([, ns], rest) => [[html('sup', { class: 'annotation' }, [html('span', trimNode(defrag(ns)))])], rest]));
@@ -24,7 +24,7 @@ export const bracket: BracketParser = lazy(() => union([
24
24
  undefined,
25
25
  ([as, bs = []], rest) => [unshift(as, bs), rest]),
26
26
  // Control media blinking in editing rather than control confusion of pairs of quote marks.
27
- surround(str('"'), syntax(Syntax.none, 8, 1, State.none, some(inline, '"', [['"', 8]])), str('"'), true,
27
+ surround(str('"'), syntax(Syntax.none, 3, 1, State.none, some(inline, '"', [['"', 3]])), str('"'), true,
28
28
  undefined,
29
29
  ([as, bs = []], rest) => [unshift(as, bs), rest]),
30
30
  ]));
@@ -8,7 +8,7 @@ export function indexee(parser: Parser<HTMLElement, MarkdownParser.Context>, opt
8
8
  return fmap(parser, ([el], _, { id }) => [define(el, { id: identity(id, text(el, optional)) })]);
9
9
  }
10
10
 
11
- export function identity(id: string | undefined, text: string, name: 'index' | 'mark' = 'index'): string | undefined {
11
+ export function identity(id: string | undefined, text: string, name: 'index' | 'mark' | 'note' = 'index'): string | undefined {
12
12
  assert(!id?.match(/[^0-9a-z/-]/i));
13
13
  assert(!text.includes('\n'));
14
14
  if (id === '') return undefined;
@@ -20,6 +20,7 @@ export function identity(id: string | undefined, text: string, name: 'index' | '
20
20
  case 'index':
21
21
  return `${name}:${id ?? ''}:${cs.slice(0, 97).join('')}...`;
22
22
  case 'mark':
23
+ case 'note':
23
24
  return `${name}:${id ?? ''}:${cs.slice(0, 50).join('')}...${cs.slice(-47).join('')}`;
24
25
  }
25
26
  assert(false);
@@ -31,7 +32,7 @@ assert(identity(undefined, '0'.repeat(100 - 1) + 1, 'mark')!.slice(6) === '0'.re
31
32
  assert(identity(undefined, '0'.repeat(100) + 1, 'mark')!.slice(6) === '0'.repeat(50) + '...' + '0'.repeat(47 - 1) + 1);
32
33
  assert(identity(undefined, '0'.repeat(200) + 1, 'mark')!.slice(6) === '0'.repeat(50) + '...' + '0'.repeat(47 - 1) + 1);
33
34
 
34
- export function text(source: HTMLElement | DocumentFragment, optional = false): string {
35
+ export function text(source: Element | DocumentFragment, optional = false): string {
35
36
  assert(source instanceof DocumentFragment || !source.matches('.indexer'));
36
37
  assert(source.querySelectorAll(':scope > .indexer').length <= 1);
37
38
  if (!source.firstChild) return '';
@@ -1,5 +1,5 @@
1
1
  import { ReferenceParser } from '../inline';
2
- import { union, subsequence, some, context, syntax, creation, constraint, surround, open, lazy, bind } from '../../combinator';
2
+ import { union, subsequence, some, syntax, creation, constraint, surround, open, lazy, bind } from '../../combinator';
3
3
  import { inline } from '../inline';
4
4
  import { str, stropt } from '../source';
5
5
  import { Syntax, State } from '../context';
@@ -12,12 +12,11 @@ export const reference: ReferenceParser = lazy(() => surround(
12
12
  constraint(State.reference, false,
13
13
  syntax(Syntax.reference, 6, 1, State.annotation | State.reference | State.media,
14
14
  startLoose(
15
- context({ delimiters: undefined },
16
15
  subsequence([
17
16
  abbr,
18
17
  open(stropt(/^(?=\^)/), some(inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]])),
19
18
  some(inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]]),
20
- ])), ']'))),
19
+ ]), ']'))),
21
20
  ']]',
22
21
  false,
23
22
  ([, ns], rest) => [[html('sup', attributes(ns), [html('span', trimNode(defrag(ns)))])], rest]));
@@ -97,7 +97,7 @@ describe('Unit: parser/inline', () => {
97
97
  assert.deepStrictEqual(inspect(parser('[++[a\nb++]')), [['', '[', '++', '[', 'a', '<br>', 'b', '++', ']'], '']);
98
98
  assert.deepStrictEqual(inspect(parser('[[++a\nb++]]')), [['[', '[', '<ins>a<br>b</ins>', ']', ']'], '']);
99
99
  assert.deepStrictEqual(inspect(parser('"[% *"*"*')), [['"', '[%', ' ', '*', '"', '*', '"', '*'], '']);
100
- assert.deepStrictEqual(inspect(parser('"[% "*"* %]')), [['"', '[%', ' ', '"', '*', '"', '*', ' ', '%', ']'], '']);
100
+ assert.deepStrictEqual(inspect(parser('"[% "*"* %]')), [['"', '<span class="comment"><input type="checkbox"><span>[% "*"* %]</span></span>'], '']);
101
101
  });
102
102
 
103
103
  it('uri', () => {
@@ -37,7 +37,7 @@ describe('Unit: parser/processor/footnote', () => {
37
37
  footnote.outerHTML,
38
38
  html('ol', [
39
39
  html('li', { id: 'annotation::def:1' }, [
40
- 'a b',
40
+ html('span', { id: 'note::a_b' }, 'a b'),
41
41
  html('sup', [html('a', { href: '#annotation::ref:1' }, '^1')])
42
42
  ]),
43
43
  ]).outerHTML);
@@ -67,11 +67,11 @@ describe('Unit: parser/processor/footnote', () => {
67
67
  footnote.outerHTML,
68
68
  html('ol', [
69
69
  html('li', { id: 'annotation::def:1' }, [
70
- '1',
70
+ html('span', { id: 'note::1' }, '1'),
71
71
  html('sup', [html('a', { href: '#annotation::ref:1' }, '^1')])
72
72
  ]),
73
73
  html('li', { id: 'annotation::def:2' }, [
74
- '12345678901234567890',
74
+ html('span', { id: 'note::12345678901234567890' }, '12345678901234567890'),
75
75
  html('sup', [html('a', { href: '#annotation::ref:2' }, '^2')])
76
76
  ]),
77
77
  ]).outerHTML);
@@ -113,22 +113,22 @@ describe('Unit: parser/processor/footnote', () => {
113
113
  footnote.outerHTML,
114
114
  html('ol', [
115
115
  html('li', { id: 'annotation::def:1' }, [
116
- '1',
116
+ html('span', { id: 'note::1' }, '1'),
117
117
  html('sup', [html('a', { href: '#annotation::ref:1' }, '^1')])
118
118
  ]),
119
119
  html('li', { id: 'annotation::def:2' }, [
120
- '2',
120
+ html('span', { id: 'note::2' }, '2'),
121
121
  html('sup', [
122
122
  html('a', { href: '#annotation::ref:2' }, '^2'),
123
123
  html('a', { href: '#annotation::ref:4' }, '^4'),
124
124
  ]),
125
125
  ]),
126
126
  html('li', { id: 'annotation::def:3' }, [
127
- '3',
127
+ html('span', { id: 'note::3' }, '3'),
128
128
  html('sup', [html('a', { href: '#annotation::ref:3' }, '^3')])
129
129
  ]),
130
130
  html('li', { id: 'annotation::def:4' }, [
131
- '4',
131
+ html('span', { id: 'note::4' }, '4'),
132
132
  html('sup', [html('a', { href: '#annotation::ref:5' }, '^5')])
133
133
  ]),
134
134
  ]).outerHTML);
@@ -151,13 +151,13 @@ describe('Unit: parser/processor/footnote', () => {
151
151
  assert.deepStrictEqual(
152
152
  [...target.children].map(el => el.outerHTML),
153
153
  [
154
- '<blockquote><blockquote><section><p><sup class="annotation disabled" title="a"><span hidden="">a</span><a>*1</a></sup></p><ol class="annotations"><li data-marker="*1">a<sup><a>^1</a></sup></li></ol><h2>References</h2><ol class="references"></ol></section></blockquote><section><p><sup class="annotation disabled" title="a"><span hidden="">a</span><a>*1</a></sup><br>~~~</p><ol class="annotations"><li data-marker="*1">a<sup><a>^1</a></sup></li></ol><h2>References</h2><ol class="references"></ol></section></blockquote>',
155
- '<aside class="example" data-type="markdown"><pre translate="no">((a))</pre><hr><section><p><sup class="annotation disabled" title="a"><span hidden="">a</span><a>*1</a></sup></p><ol class="annotations"><li data-marker="*1">a<sup><a>^1</a></sup></li></ol><h2>References</h2><ol class="references"></ol></section></aside>',
154
+ '<blockquote><blockquote><section><p><sup class="annotation disabled" title="a"><span hidden="">a</span><a>*1</a></sup></p><ol class="annotations"><li data-marker="*1"><span>a</span><sup><a>^1</a></sup></li></ol><h2>References</h2><ol class="references"></ol></section></blockquote><section><p><sup class="annotation disabled" title="a"><span hidden="">a</span><a>*1</a></sup><br>~~~</p><ol class="annotations"><li data-marker="*1"><span>a</span><sup><a>^1</a></sup></li></ol><h2>References</h2><ol class="references"></ol></section></blockquote>',
155
+ '<aside class="example" data-type="markdown"><pre translate="no">((a))</pre><hr><section><p><sup class="annotation disabled" title="a"><span hidden="">a</span><a>*1</a></sup></p><ol class="annotations"><li data-marker="*1"><span>a</span><sup><a>^1</a></sup></li></ol><h2>References</h2><ol class="references"></ol></section></aside>',
156
156
  '<p><sup class="annotation" id="annotation::ref:1" title="a"><span hidden="">a</span><a href="#annotation::def:1">*1</a></sup></p>',
157
157
  ]);
158
158
  assert.deepStrictEqual(
159
159
  footnote.outerHTML,
160
- '<ol><li id="annotation::def:1">a<sup><a href="#annotation::ref:1">^1</a></sup></li></ol>');
160
+ '<ol><li id="annotation::def:1"><span id="note::a">a</span><sup><a href="#annotation::ref:1">^1</a></sup></li></ol>');
161
161
  }
162
162
  });
163
163
 
@@ -180,7 +180,7 @@ describe('Unit: parser/processor/footnote', () => {
180
180
  footnote.outerHTML,
181
181
  html('ol', [
182
182
  html('li', { id: 'annotation:0:def:1' }, [
183
- 'a b',
183
+ html('span', { id: 'note:0:a_b' }, 'a b'),
184
184
  html('sup', [html('a', { href: '#annotation:0:ref:1' }, '^1')])
185
185
  ]),
186
186
  ]).outerHTML);
@@ -202,7 +202,7 @@ describe('Unit: parser/processor/footnote', () => {
202
202
  ]).outerHTML,
203
203
  html('ol', { class: 'annotations' }, [
204
204
  html('li', { id: 'annotation::def:1', 'data-marker': '*1' }, [
205
- '1',
205
+ html('span', { id: 'note::1' }, '1'),
206
206
  html('sup', [html('a', { href: '#annotation::ref:1' }, '^1')])
207
207
  ]),
208
208
  ]).outerHTML,
@@ -220,11 +220,11 @@ describe('Unit: parser/processor/footnote', () => {
220
220
  ]).outerHTML,
221
221
  html('ol', { class: 'annotations' }, [
222
222
  html('li', { id: 'annotation::def:2', 'data-marker': '*2' }, [
223
- '2',
223
+ html('span', { id: 'note::2' }, '2'),
224
224
  html('sup', [html('a', { href: '#annotation::ref:2' }, '^2')])
225
225
  ]),
226
226
  html('li', { id: 'annotation::def:3', 'data-marker': '*3' }, [
227
- '3',
227
+ html('span', { id: 'note::3' }, '3'),
228
228
  html('sup', [html('a', { href: '#annotation::ref:3' }, '^3')])
229
229
  ]),
230
230
  ]).outerHTML,
@@ -237,7 +237,7 @@ describe('Unit: parser/processor/footnote', () => {
237
237
  ]).outerHTML,
238
238
  html('ol', { class: 'annotations' }, [
239
239
  html('li', { id: 'annotation::def:4', 'data-marker': '*4' }, [
240
- '4',
240
+ html('span', { id: 'note::4' }, '4'),
241
241
  html('sup', [html('a', { href: '#annotation::ref:4' }, '^4')])
242
242
  ]),
243
243
  ]).outerHTML,
@@ -267,7 +267,7 @@ describe('Unit: parser/processor/footnote', () => {
267
267
  footnote.outerHTML,
268
268
  html('ol', [
269
269
  html('li', { id: 'reference::def:1' }, [
270
- 'a b',
270
+ html('span', { id: 'note::a_b' }, 'a b'),
271
271
  html('sup', [html('a', { href: '#reference::ref:1' }, '^1')])
272
272
  ]),
273
273
  ]).outerHTML);
@@ -301,7 +301,7 @@ describe('Unit: parser/processor/footnote', () => {
301
301
  footnote.outerHTML,
302
302
  html('ol', [
303
303
  html('li', { id: 'reference::def:1' }, [
304
- 'b',
304
+ html('span', { id: 'note::b' }, 'b'),
305
305
  html('sup', [
306
306
  html('a', { href: '#reference::ref:1' }, '^1'),
307
307
  html('a', { href: '#reference::ref:2', title: 'b' }, '^2'),
@@ -1,4 +1,4 @@
1
- import { text } from '../inline/extension/indexee';
1
+ import { identity, text } from '../inline/extension/indexee';
2
2
  import { frag, html, define } from 'typed-dom/dom';
3
3
 
4
4
  export function* footnote(
@@ -44,13 +44,15 @@ function build(
44
44
  }
45
45
  const refs = target.querySelectorAll(`sup.${syntax}:not(.disabled)`);
46
46
  const titles = new Map<string, string>();
47
- const contents = new Map<string, DocumentFragment>();
47
+ const contents = new Map<string, HTMLSpanElement>();
48
48
  for (let len = refs.length, i = 0; i < len; ++i) {
49
49
  if (i % 10 === 9) yield;
50
50
  const ref = refs[i];
51
51
  const identifier = ref.getAttribute('data-abbr') || ` ${ref.firstElementChild!.innerHTML}`;
52
52
  if (titles.has(identifier)) continue;
53
- const content = frag(ref.firstElementChild!.cloneNode(true).childNodes);
53
+ const content = html('span',
54
+ { id: identity(opts.id, text(ref.firstElementChild!), 'note') },
55
+ ref.firstElementChild!.cloneNode(true).childNodes);
54
56
  const title = text(content).trim();
55
57
  if (!title) continue;
56
58
  titles.set(identifier, title);
@@ -100,7 +102,6 @@ function build(
100
102
  const title = titles.get(identifier);
101
103
  assert(title !== '');
102
104
  assert(syntax !== 'annotation' || title);
103
- const content = frag(ref.firstElementChild!.cloneNode(true).childNodes);
104
105
  const refIndex = ++count;
105
106
  const refId = opts.id !== ''
106
107
  ? `${syntax}:${opts.id ?? ''}:ref:${refIndex}`
@@ -134,7 +135,7 @@ function build(
134
135
  html('a',
135
136
  {
136
137
  href: refId && `#${refId}`,
137
- title: abbr && text(content).trim() || undefined,
138
+ title: abbr && text(frag(ref.firstElementChild!.cloneNode(true).childNodes)).trim() || undefined,
138
139
  },
139
140
  `^${refIndex}`));
140
141
  }