securemark 0.276.0 → 0.276.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.276.2
4
+
5
+ - Refactoring.
6
+
7
+ ## 0.276.1
8
+
9
+ - Refactoring.
10
+
3
11
  ## 0.276.0
4
12
 
5
13
  - Change indexer syntax.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.276.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.276.2 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"));
@@ -2782,14 +2782,14 @@ Object.defineProperty(exports, "__esModule", ({
2782
2782
  }));
2783
2783
  exports.convert = void 0;
2784
2784
  const parser_1 = __webpack_require__(6728);
2785
- function convert(conv, parser) {
2785
+ function convert(conv, parser, empty = false) {
2786
2786
  return ({
2787
2787
  source,
2788
2788
  context
2789
2789
  }) => {
2790
2790
  if (source === '') return;
2791
2791
  const src = conv(source, context);
2792
- if (src === '') return [[], ''];
2792
+ if (src === '') return empty ? [[], ''] : undefined;
2793
2793
  context.offset ??= 0;
2794
2794
  context.offset += source.length - src.length;
2795
2795
  const result = parser({
@@ -2860,7 +2860,7 @@ function fence(opener, limit, separation = true) {
2860
2860
  const matches = source.match(opener);
2861
2861
  if (!matches) return;
2862
2862
  const delim = matches[1];
2863
- if (matches[0].indexOf(delim, delim.length) !== -1) return;
2863
+ if (matches[0].includes(delim, delim.length)) return;
2864
2864
  let rest = source.slice(matches[0].length);
2865
2865
  // Prevent annoying parsing in editing.
2866
2866
  if ((0, line_1.isBlank)((0, line_1.firstline)(rest)) && (0, line_1.firstline)(rest.slice((0, line_1.firstline)(rest).length)).trimEnd() !== delim) return;
@@ -4365,8 +4365,8 @@ exports.blockquote = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, co
4365
4365
  const opener = /^(?=>>+(?:$|\s))/;
4366
4366
  const indent = (0, combinator_1.block)((0, combinator_1.open)(opener, (0, combinator_1.some)(source_1.contentline, /^>(?:$|\s)/)), false);
4367
4367
  const unindent = source => source.replace(/(?<=^|\n)>(?:[^\S\n]|(?=>*(?:$|\s)))|\n$/g, '');
4368
- const source = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, combinator_1.rewrite)(indent, (0, combinator_1.convert)(unindent, source)), (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, (0, combinator_1.fmap)(autolink_1.autolink, ns => [(0, dom_1.html)('pre', (0, dom_1.defrag)(ns))])))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
4369
- const markdown = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, combinator_1.rewrite)(indent, (0, combinator_1.convert)(unindent, markdown)), (0, combinator_1.creation)(99, false, (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, ({
4368
+ const source = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, combinator_1.rewrite)(indent, (0, combinator_1.convert)(unindent, source, true)), (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, (0, combinator_1.fmap)(autolink_1.autolink, ns => [(0, dom_1.html)('pre', (0, dom_1.defrag)(ns))]), true))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
4369
+ const markdown = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, combinator_1.rewrite)(indent, (0, combinator_1.convert)(unindent, markdown, true)), (0, combinator_1.creation)(99, false, (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, ({
4370
4370
  source,
4371
4371
  context
4372
4372
  }) => {
@@ -4380,7 +4380,7 @@ const markdown = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combina
4380
4380
  }
4381
4381
  }, context);
4382
4382
  return [[(0, dom_1.html)('section', [document, (0, dom_1.html)('h2', 'References'), references])], ''];
4383
- })))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
4383
+ }, true)))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
4384
4384
 
4385
4385
  /***/ }),
4386
4386
 
@@ -4949,8 +4949,8 @@ const row = (0, combinator_1.lazy)(() => (0, combinator_1.dup)((0, combinator_1.
4949
4949
  const alignment = /^[-=<>]+(?:\/[-=^v]*)?(?=[^\S\n]*\n)/;
4950
4950
  const align = (0, combinator_1.line)((0, combinator_1.fmap)((0, combinator_1.union)([(0, source_1.str)(alignment)]), ([s]) => s.split('/').map(s => s.split(''))));
4951
4951
  const delimiter = /^[-=<>]+(?:\/[-=^v]*)?(?=[^\S\n]*\n)|^[#:](?:(?!:\D|0)\d*:(?!0)\d*)?(?:!+[+]?)?(?=\s)/;
4952
- const head = (0, combinator_1.creation)(1, false, (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)((0, source_1.str)(/^#(?:(?!:\D|0)\d*:(?!0)\d*)?(?:!+[+]?)?(?=\s)/), (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.anyline, (0, combinator_1.some)(source_1.contentline, delimiter)]), (0, combinator_1.trim)((0, visibility_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))))), true), ns => [(0, dom_1.html)('th', attributes(ns.shift()), (0, dom_1.defrag)(ns))]), false));
4953
- const data = (0, combinator_1.creation)(1, false, (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)((0, source_1.str)(/^:(?:(?!:\D|0)\d*:(?!0)\d*)?(?:!+[+]?)?(?=\s)/), (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.anyline, (0, combinator_1.some)(source_1.contentline, delimiter)]), (0, combinator_1.trim)((0, visibility_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))))), true), ns => [(0, dom_1.html)('td', attributes(ns.shift()), (0, dom_1.defrag)(ns))]), false));
4952
+ const head = (0, combinator_1.creation)(1, false, (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)((0, source_1.str)(/^#(?:(?!:\D|0)\d*:(?!0)\d*)?(?:!+[+]?)?(?=\s)/), (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.anyline, (0, combinator_1.some)(source_1.contentline, delimiter)]), (0, combinator_1.open)(/^(?:\s*\n|\s)/, (0, visibility_1.visualize)((0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline])))), true)), true), ns => [(0, dom_1.html)('th', attributes(ns.shift()), (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))]), false));
4953
+ const data = (0, combinator_1.creation)(1, false, (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)((0, source_1.str)(/^:(?:(?!:\D|0)\d*:(?!0)\d*)?(?:!+[+]?)?(?=\s)/), (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.anyline, (0, combinator_1.some)(source_1.contentline, delimiter)]), (0, combinator_1.open)(/^(?:\s*\n|\s)/, (0, visibility_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))), true)), true), ns => [(0, dom_1.html)('td', attributes(ns.shift()), (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))]), false));
4954
4954
  const dataline = (0, combinator_1.creation)(1, false, (0, combinator_1.line)((0, combinator_1.rewrite)(source_1.contentline, (0, combinator_1.union)([(0, combinator_1.validate)(/^!+\s/, (0, combinator_1.convert)(source => `:${source}`, data)), (0, combinator_1.convert)(source => `: ${source}`, data)]))));
4955
4955
  function attributes(source) {
4956
4956
  let [, rowspan = undefined, colspan = undefined, highlight = undefined, extension = undefined] = source.match(/^[#:](?:(\d+)?:(\d+)?)?(?:(!+)([+]?))?$/) ?? [];
@@ -5263,7 +5263,6 @@ const index_1 = __webpack_require__(4479);
5263
5263
  const source_1 = __webpack_require__(6743);
5264
5264
  const visibility_1 = __webpack_require__(7618);
5265
5265
  const memoize_1 = __webpack_require__(1808);
5266
- const array_1 = __webpack_require__(8112);
5267
5266
  const dom_1 = __webpack_require__(3252);
5268
5267
  const openers = {
5269
5268
  '.': /^([0-9]+|[a-z]+|[A-Z]+)(?:-(?!-)[0-9]*)*(?![^\S\n])\.?(?:$|\s)/,
@@ -5271,12 +5270,12 @@ const openers = {
5271
5270
  };
5272
5271
  exports.olist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(new RegExp([/^([0-9]+|[a-z]+|[A-Z]+)(?:-[0-9]+)*\.(?=[^\S\n]|\n[^\S\n]*\S)/.source, /^\(([0-9]+|[a-z]+)\)(?:-[0-9]+)*(?=[^\S\n]|\n[^\S\n]*\S)/.source].join('|')), (0, combinator_1.state)(8 /* State.media */, exports.olist_))));
5273
5272
  exports.olist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.union)([(0, combinator_1.match)(openers['.'], (0, memoize_1.memoize)(ms => list(type(ms[1]), '.'), ms => idx(ms[1]), [])), (0, combinator_1.match)(openers['('], (0, memoize_1.memoize)(ms => list(type(ms[1]), '('), ms => idx(ms[1]), []))])));
5274
- const list = (type, form) => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(heads[form], (0, combinator_1.subsequence)([ulist_1.checkbox, (0, combinator_1.union)([(0, combinator_1.trim)((0, combinator_1.fmap)((0, combinator_1.close)((0, combinator_1.union)([index_1.index]), /^$/), ([el]) => [(0, dom_1.define)(el, {
5273
+ const list = (type, form) => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(heads[form], (0, combinator_1.subsequence)([ulist_1.checkbox, (0, combinator_1.trim)((0, combinator_1.union)([(0, combinator_1.fmap)((0, combinator_1.close)((0, combinator_1.union)([index_1.index]), /^$/), ([el]) => [(0, dom_1.define)(el, {
5275
5274
  class: void el.classList.add('indexer'),
5276
5275
  'data-index': ''
5277
- })])), (0, visibility_1.trimBlank)((0, visibility_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline]))))])]), true)), (0, combinator_1.indent)((0, combinator_1.union)([ulist_1.ulist_, exports.olist_, ilist_1.ilist_]))]), exports.invalid), ns => [(0, dom_1.html)('li', {
5278
- 'data-marker': ns[0] || undefined
5279
- }, (0, dom_1.defrag)((0, ulist_1.fillFirstLine)((0, array_1.shift)(ns)[1])))]), true)]))), es => [format((0, dom_1.html)('ol', es), type, form)]);
5276
+ })]), (0, visibility_1.visualize)((0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline]))))]))]), true)), (0, combinator_1.indent)((0, combinator_1.union)([ulist_1.ulist_, exports.olist_, ilist_1.ilist_]))]), exports.invalid), ns => [(0, dom_1.html)('li', {
5277
+ 'data-marker': ns.shift() || undefined
5278
+ }, (0, dom_1.defrag)((0, ulist_1.fillFirstLine)(ns)))]), true)]))), es => [format((0, dom_1.html)('ol', es), type, form)]);
5280
5279
  const heads = {
5281
5280
  '.': (0, combinator_1.focus)(openers['.'], ({
5282
5281
  source
@@ -5572,7 +5571,7 @@ exports.sidefence = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, com
5572
5571
  })])));
5573
5572
  const opener = /^(?=\|\|+(?:$|\s))/;
5574
5573
  const unindent = source => source.replace(/(?<=^|\n)\|(?:[^\S\n]|(?=\|*(?:$|\s)))|\n$/g, '');
5575
- const source = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, combinator_1.focus)(/^(?:\|\|+(?:[^\S\n][^\n]*)?(?:$|\n))+/, (0, combinator_1.convert)(unindent, source)), (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, (0, combinator_1.fmap)(autolink_1.autolink, ns => [(0, dom_1.html)('pre', (0, dom_1.defrag)(ns))])))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
5574
+ const source = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, combinator_1.focus)(/^(?:\|\|+(?:[^\S\n][^\n]*)?(?:$|\n))+/, (0, combinator_1.convert)(unindent, source, true)), (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, (0, combinator_1.fmap)(autolink_1.autolink, ns => [(0, dom_1.html)('pre', (0, dom_1.defrag)(ns))]), true))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
5576
5575
 
5577
5576
  /***/ }),
5578
5577
 
@@ -5603,9 +5602,9 @@ const row = (parser, optional) => (0, combinator_1.creation)(1, false, (0, combi
5603
5602
  'data-invalid-message': 'Missing the start symbol of the table row'
5604
5603
  }, [(0, dom_1.html)('td', source.replace('\n', ''))])], ''])));
5605
5604
  const align = (0, combinator_1.creation)(1, false, (0, combinator_1.fmap)((0, combinator_1.open)('|', (0, combinator_1.union)([(0, combinator_1.focus)(/^:-+:/, () => [['center'], '']), (0, combinator_1.focus)(/^:-+/, () => [['start'], '']), (0, combinator_1.focus)(/^-+:/, () => [['end'], '']), (0, combinator_1.focus)(/^-+/, () => [[''], ''])])), ns => [(0, dom_1.html)('td', (0, dom_1.defrag)(ns))]));
5606
- const cell = (0, combinator_1.surround)(/^\|\s*(?=\S)/, (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), /^\|/, [[/^[|\\]?\s*$/, 9]]), /^[^|]*/, true);
5607
- const head = (0, combinator_1.creation)(1, false, (0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('th', (0, visibility_1.trimNode)((0, dom_1.defrag)(ns)))]));
5608
- const data = (0, combinator_1.creation)(1, false, (0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('td', (0, visibility_1.trimNode)((0, dom_1.defrag)(ns)))]));
5605
+ const cell = (0, combinator_1.surround)(/^\|\s*(?=\S)/, (0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), /^\|/, [[/^[|\\]?\s*$/, 9]])), /^[^|]*/, true);
5606
+ const head = (0, combinator_1.creation)(1, false, (0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('th', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))]));
5607
+ const data = (0, combinator_1.creation)(1, false, (0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('td', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))]));
5609
5608
  function format(rows) {
5610
5609
  const aligns = rows[0].className === 'invalid' ? [] : (0, duff_1.duffReduce)(rows.shift().children, (acc, el) => (0, array_1.push)(acc, [el.textContent]), []);
5611
5610
  for (let i = 0; i < rows.length; ++i) {
@@ -5641,10 +5640,10 @@ const visibility_1 = __webpack_require__(7618);
5641
5640
  const array_1 = __webpack_require__(8112);
5642
5641
  const dom_1 = __webpack_require__(3252);
5643
5642
  exports.ulist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(/^-(?=[^\S\n]|\n[^\S\n]*\S)/, (0, combinator_1.state)(8 /* State.media */, exports.ulist_))));
5644
- exports.ulist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^-(?=$|\s)/, (0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(/^-(?:$|\s)/, (0, combinator_1.subsequence)([exports.checkbox, (0, combinator_1.union)([(0, combinator_1.trim)((0, combinator_1.fmap)((0, combinator_1.close)((0, combinator_1.union)([index_1.index]), /^$/), ([el]) => [(0, dom_1.define)(el, {
5643
+ exports.ulist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^-(?=$|\s)/, (0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(/^-(?:$|\s)/, (0, combinator_1.subsequence)([exports.checkbox, (0, combinator_1.trim)((0, combinator_1.union)([(0, combinator_1.fmap)((0, combinator_1.close)((0, combinator_1.union)([index_1.index]), /^$/), ([el]) => [(0, dom_1.define)(el, {
5645
5644
  class: void el.classList.add('indexer'),
5646
5645
  'data-index': ''
5647
- })])), (0, visibility_1.trimBlank)((0, visibility_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline]))))])]), true)), (0, combinator_1.indent)((0, combinator_1.union)([exports.ulist_, olist_1.olist_, ilist_1.ilist_]))]), olist_1.invalid), ns => [(0, dom_1.html)('li', (0, dom_1.defrag)(fillFirstLine(ns)))]), true)])))), es => [format((0, dom_1.html)('ul', es))])));
5646
+ })]), (0, visibility_1.visualize)((0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline]))))]))]), true)), (0, combinator_1.indent)((0, combinator_1.union)([exports.ulist_, olist_1.olist_, ilist_1.ilist_]))]), olist_1.invalid), ns => [(0, dom_1.html)('li', (0, dom_1.defrag)(fillFirstLine(ns)))]), true)])))), es => [format((0, dom_1.html)('ul', es))])));
5648
5647
  exports.checkbox = (0, combinator_1.creation)(1, false, (0, combinator_1.focus)(/^\[[xX ]\](?=$|\s)/, ({
5649
5648
  source
5650
5649
  }) => [[(0, dom_1.html)('span', {
@@ -5790,9 +5789,9 @@ const combinator_1 = __webpack_require__(2087);
5790
5789
  const inline_1 = __webpack_require__(1160);
5791
5790
  const visibility_1 = __webpack_require__(7618);
5792
5791
  const dom_1 = __webpack_require__(3252);
5793
- 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', {
5792
+ 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.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ')', [[/^\\?\n/, 9], [')', 2], ['))', 6]])))), '))', false, ([, ns], rest) => [[(0, dom_1.html)('sup', {
5794
5793
  class: 'annotation'
5795
- }, [(0, dom_1.html)('span', (0, visibility_1.trimNode)((0, dom_1.defrag)(ns)))])], rest]));
5794
+ }, [(0, dom_1.html)('span', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))])], rest]));
5796
5795
 
5797
5796
  /***/ }),
5798
5797
 
@@ -6390,7 +6389,7 @@ exports.html = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('<', (0,
6390
6389
  exports.attribute = (0, combinator_1.union)([(0, source_1.str)(/^[^\S\n]+[a-z]+(?:-[a-z]+)*(?:="[^"\n]*")?(?=[^\S\n]|>)/i)]);
6391
6390
  // https://developer.mozilla.org/en-US/docs/Web/HTML/Element
6392
6391
  // [...document.querySelectorAll('tbody > tr > td:first-child')].map(el => el.textContent.slice(1, -1))
6393
- const TAGS = Object.freeze(["html", "base", "head", "link", "meta", "style", "title", "body", "address", "article", "aside", "footer", "header", "h1", "h2", "h3", "h4", "h5", "h6", "main", "nav", "section", "blockquote", "dd", "div", "dl", "dt", "figcaption", "figure", "hr", "li", "menu", "ol", "p", "pre", "ul", "a", "abbr", "b", "bdi", "bdo", "br", "cite", "code", "data", "dfn", "em", "i", "kbd", "mark", "q", "rp", "rt", "ruby", "s", "samp", "small", "span", "strong", "sub", "sup", "time", "u", "var", "wbr", "area", "audio", "img", "map", "track", "video", "embed", "iframe", "object", "picture", "portal", "source", "svg", "math", "canvas", "noscript", "script", "del", "ins", "caption", "col", "colgroup", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "button", "datalist", "fieldset", "form", "input", "label", "legend", "meter", "optgroup", "option", "output", "progress", "select", "textarea", "details", "dialog", "summary", "slot", "template", "acronym", "applet", "basefont", "bgsound", "big", "blink", "center", "content", "dir", "font", "frame", "frameset", "hgroup", "image", "keygen", "marquee", "menuitem", "nobr", "noembed", "noframes", "param", "plaintext", "rb", "rtc", "shadow", "spacer", "strike", "tt", "xmp"]);
6392
+ const TAGS = Object.freeze(["html", "base", "head", "link", "meta", "style", "title", "body", "address", "article", "aside", "footer", "header", "h1", "h2", "h3", "h4", "h5", "h6", "hgroup", "main", "nav", "section", "blockquote", "dd", "div", "dl", "dt", "figcaption", "figure", "hr", "li", "menu", "ol", "p", "pre", "ul", "a", "abbr", "b", "bdi", "bdo", "br", "cite", "code", "data", "dfn", "em", "i", "kbd", "mark", "q", "rp", "rt", "ruby", "s", "samp", "small", "span", "strong", "sub", "sup", "time", "u", "var", "wbr", "area", "audio", "img", "map", "track", "video", "embed", "iframe", "object", "picture", "portal", "source", "svg", "math", "canvas", "noscript", "script", "del", "ins", "caption", "col", "colgroup", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "button", "datalist", "fieldset", "form", "input", "label", "legend", "meter", "optgroup", "option", "output", "progress", "select", "textarea", "details", "dialog", "summary", "slot", "template", "acronym", "applet", "bgsound", "big", "blink", "center", "content", "dir", "font", "frame", "frameset", "image", "keygen", "marquee", "menuitem", "nobr", "noembed", "noframes", "param", "plaintext", "rb", "rtc", "shadow", "spacer", "strike", "tt", "xmp"]);
6394
6393
  function elem(tag, as, bs, cs) {
6395
6394
  if (!tags.includes(tag)) return invalid('tag', `Invalid HTML tag name "${tag}"`, as, bs, cs);
6396
6395
  if (cs.length === 0) return invalid('tag', `Missing the closing HTML tag "</${tag}>"`, as, bs, cs);
@@ -6507,21 +6506,20 @@ const optspec = {
6507
6506
  };
6508
6507
  Object.setPrototypeOf(optspec, null);
6509
6508
  exports.link = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['[', '{'], (0, combinator_1.union)([exports.medialink, exports.textlink])));
6510
- exports.textlink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(16 /* State.link */, false, (0, combinator_1.syntax)(16 /* Syntax.link */, 2, 10, 502 /* State.linkers */ | 8 /* State.media */, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [[/^\\?\n/, 9], [']', 2]]), ']', true)), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])), ([params, content = []], rest, context) => {
6511
- return parse(content, params, rest, context);
6509
+ exports.textlink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(16 /* State.link */, false, (0, combinator_1.syntax)(16 /* Syntax.link */, 2, 10, 502 /* State.linkers */ | 8 /* State.media */, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [[/^\\?\n/, 9], [']', 2]])), ']', true)), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])), ([params, content = []], rest, context) => {
6510
+ if (content.length !== 0 && (0, visibility_1.trimNodeEnd)(content = (0, dom_1.defrag)(content)).length === 0) return;
6511
+ return [[parse(content, params, context)], rest];
6512
6512
  }))));
6513
- exports.medialink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(16 /* State.link */ | 8 /* State.media */, false, (0, combinator_1.syntax)(16 /* Syntax.link */, 2, 10, 502 /* State.linkers */, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.sequence)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.union)([inline_1.media, inline_1.shortmedia]), ']')), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])), ([params, content = []], rest, context) => parse(content, params, rest, context)))));
6513
+ exports.medialink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(16 /* State.link */ | 8 /* State.media */, false, (0, combinator_1.syntax)(16 /* Syntax.link */, 2, 10, 502 /* State.linkers */, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.sequence)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.union)([inline_1.media, inline_1.shortmedia]), ']')), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])), ([params, content = []], rest, context) => [[parse((0, dom_1.defrag)(content), params, context)], rest]))));
6514
6514
  exports.linemedialink = (0, combinator_1.surround)(source_1.linebreak, (0, combinator_1.union)([exports.medialink]), /^(?=[^\S\n]*(?:$|\n))/);
6515
- exports.unsafelink = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(10, (0, combinator_1.precedence)(2, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.some)((0, combinator_1.union)([source_1.unescsource]), ']'), ']')), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])), ([params, content = []], rest, context) => parse(content, params, rest, context)))));
6515
+ exports.unsafelink = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(10, (0, combinator_1.precedence)(2, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.some)((0, combinator_1.union)([source_1.unescsource]), ']'), ']')), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])), ([params, content = []], rest, context) => [[parse((0, dom_1.defrag)(content), params, context)], rest]))));
6516
6516
  exports.uri = (0, combinator_1.union)([(0, combinator_1.open)(/^[^\S\n]+/, (0, source_1.str)(/^\S+/)), (0, source_1.str)(/^[^\s{}]+/)]);
6517
6517
  exports.option = (0, combinator_1.union)([(0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+nofollow(?=[^\S\n]|})/), () => [` rel="nofollow"`]), (0, source_1.str)(/^[^\S\n]+[a-z]+(?:-[a-z]+)*(?:="(?:\\[^\n]|[^\\\n"])*")?(?=[^\S\n]|})/), (0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+[^\s{}]+/), opt => [` \\${opt.slice(1)}`])]);
6518
- function parse(content, params, rest, context) {
6519
- if (content.length !== 0 && (0, visibility_1.trimNode)(content).length === 0) return;
6518
+ function parse(content, params, context) {
6520
6519
  const INSECURE_URI = params.shift();
6521
6520
  const uri = new url_1.ReadonlyURL(resolve(INSECURE_URI, context.host ?? location, context.url ?? context.host ?? location), context.host?.href || location.href);
6522
- const el = elem(INSECURE_URI, (0, dom_1.defrag)(content), uri, context.host?.origin || location.origin);
6523
- if (el.className === 'invalid') return [[el], rest];
6524
- return [[(0, dom_1.define)(el, (0, html_1.attributes)('link', [], optspec, params))], rest];
6521
+ const el = elem(INSECURE_URI, content, uri, context.host?.origin || location.origin);
6522
+ return el.className === 'invalid' ? el : (0, dom_1.define)(el, (0, html_1.attributes)('link', [], optspec, params));
6525
6523
  }
6526
6524
  function elem(INSECURE_URI, content, uri, origin) {
6527
6525
  let type;
@@ -6765,9 +6763,9 @@ const inline_1 = __webpack_require__(1160);
6765
6763
  const source_1 = __webpack_require__(6743);
6766
6764
  const visibility_1 = __webpack_require__(7618);
6767
6765
  const dom_1 = __webpack_require__(3252);
6768
- 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.fmap)((0, source_1.str)('^'), ns => ['', ...ns]), (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]));
6766
+ 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, combinator_1.subsequence)([abbr, (0, visibility_1.trimBlankStart)((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.trimNodeEnd)((0, dom_1.defrag)(ns)))])], rest]));
6769
6767
  // Chicago-Style
6770
- const abbr = (0, combinator_1.creation)((0, combinator_1.bind)((0, combinator_1.surround)('^', (0, combinator_1.union)([(0, source_1.str)(/^(?=[A-Z])(?:[0-9A-Za-z]'?|(?:[-.:]|\.?\??,? ?)(?!['\-.:?, ]))+/)]), /^\|?(?=]])|^\|[^\S\n]*/), ([source], rest) => [['\n', source.trimEnd()], rest.replace(visibility_1.regBlankStart, '')]));
6768
+ const abbr = (0, combinator_1.creation)((0, combinator_1.surround)('^', (0, combinator_1.union)([(0, source_1.str)(/^(?=[A-Z])(?:[0-9A-Za-z]'?|(?:[-.:]|\.?\??,? ?)(?!['\-.:?, ]))+/)]), /^\|?(?=]])|^\|[^\S\n]*/, true, ([, ns], rest) => ns ? [['\n', ns[0].trimEnd()], rest.replace(visibility_1.blank.start, '')] : [[''], `^${rest}`], ([,, rest]) => [[''], `^${rest}`]));
6771
6769
  function attributes(ns) {
6772
6770
  switch (ns[0]) {
6773
6771
  case '':
@@ -6872,7 +6870,7 @@ function attributes(texts, rubies) {
6872
6870
  let attrs;
6873
6871
  for (const ss of [texts, rubies]) {
6874
6872
  for (let i = 0; i < ss.length; ++i) {
6875
- if (ss[i].indexOf('\x1B') === -1) continue;
6873
+ if (!ss[i].includes('\x1B')) continue;
6876
6874
  ss[i] = ss[i].replace(/\x1B/g, '');
6877
6875
  attrs ??= {
6878
6876
  class: 'invalid',
@@ -7630,7 +7628,7 @@ exports.stringify = stringify;
7630
7628
  Object.defineProperty(exports, "__esModule", ({
7631
7629
  value: true
7632
7630
  }));
7633
- exports.trimNodeEnd = exports.trimNode = exports.trimBlankStart = exports.trimBlank = exports.isStartTightNodes = exports.isStartLooseNodes = exports.startTight = exports.startLoose = exports.blankWith = exports.regBlankStart = exports.visualize = void 0;
7631
+ exports.trimNodeEnd = exports.trimBlankStart = exports.trimBlank = exports.isStartTightNodes = exports.isStartLooseNodes = exports.startTight = exports.blankWith = exports.visualize = exports.blank = void 0;
7634
7632
  const parser_1 = __webpack_require__(6728);
7635
7633
  const combinator_1 = __webpack_require__(2087);
7636
7634
  const htmlentity_1 = __webpack_require__(1562);
@@ -7638,9 +7636,13 @@ const source_1 = __webpack_require__(6743);
7638
7636
  const normalize_1 = __webpack_require__(185);
7639
7637
  const memoize_1 = __webpack_require__(1808);
7640
7638
  const array_1 = __webpack_require__(8112);
7639
+ var blank;
7640
+ (function (blank) {
7641
+ blank.line = new RegExp(/^(?:\\?[^\S\n]|&IHN;|<wbr[^\S\n]*>|\\$)+$/.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`), 'gm');
7642
+ blank.start = new RegExp(/^(?:\\?[^\S\n]|&IHN;|<wbr[^\S\n]*>)+/.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`));
7643
+ })(blank = exports.blank || (exports.blank = {}));
7641
7644
  function visualize(parser) {
7642
- const blankline = new RegExp(/^(?:\\$|\\?[^\S\n]|&IHN;|<wbr[^\S\n]*>)+$/.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`), 'gm');
7643
- return (0, combinator_1.union)([(0, combinator_1.convert)(source => source.replace(blankline, line => line.replace(/[\\&<]/g, '\x1B$&')), (0, combinator_1.verify)(parser, (ns, rest, context) => !rest && hasVisible(ns, context))), (0, combinator_1.some)((0, combinator_1.union)([source_1.linebreak, source_1.unescsource]))]);
7645
+ return (0, combinator_1.union)([(0, combinator_1.convert)(source => source.replace(blank.line, line => line.replace(/[\\&<]/g, '\x1B$&')), (0, combinator_1.verify)(parser, (ns, rest, context) => !rest && hasVisible(ns, context))), (0, combinator_1.some)((0, combinator_1.union)([source_1.linebreak, source_1.unescsource]))]);
7644
7646
  }
7645
7647
  exports.visualize = visualize;
7646
7648
  function hasVisible(nodes, {
@@ -7657,27 +7659,11 @@ function hasVisible(nodes, {
7657
7659
  }
7658
7660
  return false;
7659
7661
  }
7660
- exports.regBlankStart = new RegExp(/^(?:\\?[^\S\n]|&IHN;|<wbr[^\S\n]*>)+/.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`));
7661
7662
  function blankWith(starting, delimiter) {
7662
7663
  if (delimiter === undefined) return blankWith('', starting);
7663
7664
  return new RegExp(String.raw`^(?:(?=${starting})(?:\\?\s|&(?:${normalize_1.invisibleHTMLEntityNames.join('|')});|<wbr[^\S\n]*>)${starting && '+'})?${typeof delimiter === 'string' ? delimiter.replace(/[*+()\[\]]/g, '\\$&') : delimiter.source}`);
7664
7665
  }
7665
7666
  exports.blankWith = blankWith;
7666
- function startLoose(parser, except) {
7667
- return input => isStartLoose(input, except) ? parser(input) : undefined;
7668
- }
7669
- exports.startLoose = startLoose;
7670
- const isStartLoose = (0, memoize_1.reduce)(({
7671
- source,
7672
- context
7673
- }, except) => {
7674
- return isStartTight({
7675
- source: source.replace(exports.regBlankStart, ''),
7676
- context
7677
- }, except);
7678
- }, ({
7679
- source
7680
- }, except = '') => `${source}\x1E${except}`);
7681
7667
  function startTight(parser, except) {
7682
7668
  return input => isStartTight(input, except) ? parser(input) : undefined;
7683
7669
  }
@@ -7764,30 +7750,29 @@ function trimBlank(parser) {
7764
7750
  }
7765
7751
  exports.trimBlank = trimBlank;
7766
7752
  function trimBlankStart(parser) {
7767
- return (0, combinator_1.convert)((0, memoize_1.reduce)(source => source.replace(exports.regBlankStart, '')), parser);
7753
+ return (0, combinator_1.convert)(source => source.replace(blank.start, ''), parser);
7768
7754
  }
7769
7755
  exports.trimBlankStart = trimBlankStart;
7770
7756
  function trimBlankEnd(parser) {
7771
7757
  return (0, combinator_1.fmap)(parser, trimNodeEnd);
7772
7758
  }
7773
- function trimNode(nodes) {
7774
- return trimNodeStart(trimNodeEnd(nodes));
7775
- }
7776
- exports.trimNode = trimNode;
7777
- function trimNodeStart(nodes) {
7778
- for (let node = nodes[0]; nodes.length > 0 && !isVisible(node = nodes[0], 0);) {
7779
- if (nodes.length === 1 && typeof node === 'object' && node.className === 'indexer') break;
7780
- if (typeof node === 'string') {
7781
- const pos = node.trimStart().length;
7782
- if (pos > 0) {
7783
- nodes[0] = node.slice(-pos);
7784
- break;
7785
- }
7786
- }
7787
- nodes.shift();
7788
- }
7789
- return nodes;
7790
- }
7759
+ //export function trimNode<T extends HTMLElement | string>(nodes: T[]): T[] {
7760
+ // return trimNodeStart(trimNodeEnd(nodes));
7761
+ //}
7762
+ //function trimNodeStart<T extends HTMLElement | string>(nodes: T[]): T[] {
7763
+ // for (let node = nodes[0]; nodes.length > 0 && !isVisible(node = nodes[0], 0);) {
7764
+ // if (nodes.length === 1 && typeof node === 'object' && node.className === 'indexer') break;
7765
+ // if (typeof node === 'string') {
7766
+ // const pos = node.trimStart().length;
7767
+ // if (pos > 0) {
7768
+ // nodes[0] = node.slice(-pos) as T;
7769
+ // break;
7770
+ // }
7771
+ // }
7772
+ // nodes.shift();
7773
+ // }
7774
+ // return nodes;
7775
+ //}
7791
7776
  function trimNodeEnd(nodes) {
7792
7777
  const skip = nodes.length > 0 && typeof nodes[nodes.length - 1] === 'object' && nodes[nodes.length - 1]['className'] === 'indexer' ? [nodes.pop()] : [];
7793
7778
  for (let node = nodes[0]; nodes.length > 0 && !isVisible(node = nodes[nodes.length - 1], -1);) {
@@ -8446,7 +8431,7 @@ function unlink(h) {
8446
8431
  /***/ 3252:
8447
8432
  /***/ (function(module) {
8448
8433
 
8449
- /*! typed-dom v0.0.333 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
8434
+ /*! typed-dom v0.0.334 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
8450
8435
  (function webpackUniversalModuleDefinition(root, factory) {
8451
8436
  if(true)
8452
8437
  module.exports = factory();
@@ -8723,15 +8708,14 @@ exports.prepend = prepend;
8723
8708
  function defrag(nodes) {
8724
8709
  const acc = [];
8725
8710
  let appendable = false;
8726
- for (let i = 0; i < nodes.length; ++i) {
8711
+ for (let i = 0, len = nodes.length; i < len; ++i) {
8727
8712
  const node = nodes[i];
8728
- if (node === '') continue;
8729
- if (typeof node === 'string') {
8730
- appendable ? acc[acc.length - 1] += node : acc.push(node);
8731
- appendable = true;
8732
- } else {
8713
+ if (typeof node === 'object') {
8733
8714
  acc.push(node);
8734
8715
  appendable = false;
8716
+ } else if (node !== '') {
8717
+ appendable ? acc[acc.length - 1] += node : acc.push(node);
8718
+ appendable = true;
8735
8719
  }
8736
8720
  }
8737
8721
  return acc;
@@ -8746,7 +8730,7 @@ exports.defrag = defrag;
8746
8730
  /******/ var __webpack_module_cache__ = {};
8747
8731
  /******/
8748
8732
  /******/ // The require function
8749
- /******/ function __nested_webpack_require_11657__(moduleId) {
8733
+ /******/ function __nested_webpack_require_11654__(moduleId) {
8750
8734
  /******/ // Check if module is in cache
8751
8735
  /******/ var cachedModule = __webpack_module_cache__[moduleId];
8752
8736
  /******/ if (cachedModule !== undefined) {
@@ -8760,7 +8744,7 @@ exports.defrag = defrag;
8760
8744
  /******/ };
8761
8745
  /******/
8762
8746
  /******/ // Execute the module function
8763
- /******/ __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_11657__);
8747
+ /******/ __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_11654__);
8764
8748
  /******/
8765
8749
  /******/ // Return the exports of the module
8766
8750
  /******/ return module.exports;
@@ -8771,7 +8755,7 @@ exports.defrag = defrag;
8771
8755
  /******/ // startup
8772
8756
  /******/ // Load entry module and return exports
8773
8757
  /******/ // This entry module is referenced by other modules so it can't be inlined
8774
- /******/ var __nested_webpack_exports__ = __nested_webpack_require_11657__(7521);
8758
+ /******/ var __nested_webpack_exports__ = __nested_webpack_require_11654__(7521);
8775
8759
  /******/
8776
8760
  /******/ return __nested_webpack_exports__;
8777
8761
  /******/ })()
@@ -8783,7 +8767,7 @@ exports.defrag = defrag;
8783
8767
  /***/ 6120:
8784
8768
  /***/ (function(module) {
8785
8769
 
8786
- /*! typed-dom v0.0.333 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
8770
+ /*! typed-dom v0.0.334 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
8787
8771
  (function webpackUniversalModuleDefinition(root, factory) {
8788
8772
  if(true)
8789
8773
  module.exports = factory();
package/markdown.d.ts CHANGED
@@ -673,7 +673,6 @@ export namespace MarkdownParser {
673
673
  Inline<'reference'>,
674
674
  Parser<HTMLElement, Context, [
675
675
  ReferenceParser.AbbrParser,
676
- SourceParser.StrParser,
677
676
  InlineParser,
678
677
  ]> {
679
678
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securemark",
3
- "version": "0.276.0",
3
+ "version": "0.276.2",
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",
@@ -50,12 +50,12 @@
50
50
  "karma-power-assert": "^1.0.0",
51
51
  "mocha": "^10.2.0",
52
52
  "npm-check-updates": "^16.10.12",
53
- "semver": "^7.5.0",
53
+ "semver": "^7.5.1",
54
54
  "spica": "0.0.721",
55
55
  "ts-loader": "^9.4.2",
56
- "typed-dom": "^0.0.333",
56
+ "typed-dom": "0.0.334",
57
57
  "typescript": "5.0.4",
58
- "webpack": "^5.82.0",
58
+ "webpack": "^5.82.1",
59
59
  "webpack-cli": "^5.1.1",
60
60
  "webpack-merge": "^5.8.0"
61
61
  },
@@ -1,12 +1,12 @@
1
1
  import { Parser, Ctx, Context, check } from '../../data/parser';
2
2
 
3
- export function convert<P extends Parser<unknown>>(conv: (source: string, context: Context<P>) => string, parser: P): P;
4
- export function convert<T>(conv: (source: string, context: Ctx) => string, parser: Parser<T>): Parser<T> {
3
+ export function convert<P extends Parser<unknown>>(conv: (source: string, context: Context<P>) => string, parser: P, empty?: boolean): P;
4
+ export function convert<T>(conv: (source: string, context: Ctx) => string, parser: Parser<T>, empty = false): Parser<T> {
5
5
  assert(parser);
6
6
  return ({ source, context }) => {
7
7
  if (source === '') return;
8
8
  const src = conv(source, context);
9
- if (src === '') return [[], ''];
9
+ if (src === '') return empty ? [[], ''] : undefined;
10
10
  context.offset ??= 0;
11
11
  context.offset += source.length - src.length;
12
12
  const result = parser({ source: src, context });
@@ -10,7 +10,7 @@ export function fence<C extends Ctx, D extends Parser<unknown, C>[]>(opener: Reg
10
10
  assert(matches[0] === firstline(source));
11
11
  const delim = matches[1];
12
12
  assert(delim && delim === delim.trim());
13
- if (matches[0].indexOf(delim, delim.length) !== -1) return;
13
+ if (matches[0].includes(delim, delim.length)) return;
14
14
  let rest = source.slice(matches[0].length);
15
15
  // Prevent annoying parsing in editing.
16
16
  if (isBlank(firstline(rest)) && firstline(rest.slice(firstline(rest).length)).trimEnd() !== delim) return;
@@ -25,8 +25,8 @@ export function context<T>(base: Ctx, parser: Parser<T>): Parser<T> {
25
25
  apply(parser, source, context, changes, values);
26
26
  }
27
27
 
28
- function apply<P extends Parser<unknown>>(parser: P, source: string, context: Context<P>, changes: [string, any][], values: any[], reset?: boolean): Result<Tree<P>>;
29
- function apply<T>(parser: Parser<T>, source: string, context: Ctx, changes: [string, any][], values: any[], reset = false): Result<T> {
28
+ function apply<P extends Parser<unknown>>(parser: P, source: string, context: Context<P>, changes: readonly [string, unknown][], values: unknown[], reset?: boolean): Result<Tree<P>>;
29
+ function apply<T>(parser: Parser<T>, source: string, context: Ctx, changes: readonly [string, unknown][], values: unknown[], reset = false): Result<T> {
30
30
  if (context) for (let i = 0; i < changes.length; ++i) {
31
31
  const change = changes[i];
32
32
  const prop = change[0];
@@ -36,7 +36,7 @@ function apply<T>(parser: Parser<T>, source: string, context: Ctx, changes: [str
36
36
  assert(typeof change[1] === 'object');
37
37
  assert(context[prop] || !(prop in context));
38
38
  if (prop in context && !hasOwnProperty(context, prop)) break;
39
- context[prop as string] = ObjectCreate(change[1]);
39
+ context[prop as string] = ObjectCreate(change[1] as object);
40
40
  break;
41
41
  // @ts-expect-error
42
42
  case 'memo':
@@ -12,7 +12,7 @@ export function inits<T, D extends Parser<T>[]>(parsers: D, resume?: (nodes: T[]
12
12
  if (rest === '') break;
13
13
  if (context.delimiters?.match(rest, context.precedence)) break;
14
14
  const result = parsers[i]({ source: rest, context });
15
- assert(check(rest, result));
15
+ assert(check(rest, result, false));
16
16
  if (result === undefined) break;
17
17
  nodes = nodes
18
18
  ? push(nodes, eval(result))
@@ -12,7 +12,7 @@ export function sequence<T, D extends Parser<T>[]>(parsers: D, resume?: (nodes:
12
12
  if (rest === '') return;
13
13
  if (context.delimiters?.match(rest, context.precedence)) return;
14
14
  const result = parsers[i]({ source: rest, context });
15
- assert(check(rest, result));
15
+ assert(check(rest, result, false));
16
16
  if (result === undefined) return;
17
17
  nodes = nodes
18
18
  ? push(nodes, eval(result))
@@ -22,10 +22,10 @@ const source: BlockquoteParser.SourceParser = lazy(() => fmap(
22
22
  some(creation(1, false, union([
23
23
  rewrite(
24
24
  indent,
25
- convert(unindent, source)),
25
+ convert(unindent, source, true)),
26
26
  rewrite(
27
27
  some(contentline, opener),
28
- convert(unindent, fmap(autolink, ns => [html('pre', defrag(ns))]))),
28
+ convert(unindent, fmap(autolink, ns => [html('pre', defrag(ns))]), true)),
29
29
  ]))),
30
30
  ns => [html('blockquote', ns)]));
31
31
 
@@ -33,7 +33,7 @@ const markdown: BlockquoteParser.MarkdownParser = lazy(() => fmap(
33
33
  some(creation(1, false, union([
34
34
  rewrite(
35
35
  indent,
36
- convert(unindent, markdown)),
36
+ convert(unindent, markdown, true)),
37
37
  creation(99, false,
38
38
  rewrite(
39
39
  some(contentline, opener),
@@ -46,6 +46,6 @@ const markdown: BlockquoteParser.MarkdownParser = lazy(() => fmap(
46
46
  },
47
47
  }, context);
48
48
  return [[html('section', [document, html('h2', 'References'), references])], ''];
49
- }))),
49
+ }, true))),
50
50
  ]))),
51
51
  ns => [html('blockquote', ns)]));
@@ -95,6 +95,42 @@ describe('Unit: parser/block/extension/table', () => {
95
95
  ]),
96
96
  html('tfoot'),
97
97
  ]).outerHTML], '']);
98
+ assert.deepStrictEqual(
99
+ inspect(parser('~~~table\n:\n1\n~~~')),
100
+ [[html('table', [
101
+ html('thead'),
102
+ html('tbody', [
103
+ html('tr', [html('td', '1')]),
104
+ ]),
105
+ html('tfoot'),
106
+ ]).outerHTML], '']);
107
+ assert.deepStrictEqual(
108
+ inspect(parser('~~~table\n: \n1\n~~~')),
109
+ [[html('table', [
110
+ html('thead'),
111
+ html('tbody', [
112
+ html('tr', [html('td', '1')]),
113
+ ]),
114
+ html('tfoot'),
115
+ ]).outerHTML], '']);
116
+ assert.deepStrictEqual(
117
+ inspect(parser('~~~table\n: \n 1\n~~~')),
118
+ [[html('table', [
119
+ html('thead'),
120
+ html('tbody', [
121
+ html('tr', [html('td', ' 1')]),
122
+ ]),
123
+ html('tfoot'),
124
+ ]).outerHTML], '']);
125
+ assert.deepStrictEqual(
126
+ inspect(parser('~~~table\n: \n\n1\n~~~')),
127
+ [[html('table', [
128
+ html('thead'),
129
+ html('tbody', [
130
+ html('tr', [html('td'), html('td', '1')]),
131
+ ]),
132
+ html('tfoot'),
133
+ ]).outerHTML], '']);
98
134
  assert.deepStrictEqual(
99
135
  inspect(parser('~~~table\n\\ \n\\ \n~~~')),
100
136
  [[html('table', [
@@ -491,7 +527,7 @@ describe('Unit: parser/block/extension/table', () => {
491
527
  assert.deepStrictEqual(
492
528
  inspect(parser([
493
529
  '~~~table',
494
- `-\n# 1\n${[...Array(32)].map((_, i) => `: ${i + 2}`).join('\n')}`,
530
+ `-\n# 1\n${[...Array(32)].map((_, i) => `: ${i + 2}`).join('\n')}`,
495
531
  `-\n#!+ 1\n${[...Array(32)].map((_, i) => `: ${i + 2}`).join('\n')}`,
496
532
  '~~~'
497
533
  ].join('\n'))),
@@ -511,7 +547,7 @@ describe('Unit: parser/block/extension/table', () => {
511
547
  assert.deepStrictEqual(
512
548
  inspect(parser([
513
549
  '~~~table',
514
- `-\n${[...Array(32)].map((_, i) => `: ${i + 1}`).join('\n')}\n# 33`,
550
+ `-\n${[...Array(32)].map((_, i) => `: ${i + 1}`).join('\n')}\n# 33`,
515
551
  `-\n${[...Array(32)].map((_, i) => `: ${i + 1}`).join('\n')}\n#!+ 33`,
516
552
  '~~~'
517
553
  ].join('\n'))),
@@ -1,10 +1,10 @@
1
1
  import { max, min, isArray } from 'spica/alias';
2
2
  import { ExtensionParser } from '../../block';
3
3
  import { Tree, eval } from '../../../combinator/data/parser';
4
- import { union, subsequence, inits, some, creation, block, line, validate, fence, rewrite, open, clear, convert, trim, dup, lazy, fmap } from '../../../combinator';
4
+ import { union, subsequence, inits, some, creation, block, line, validate, fence, rewrite, open, clear, convert, dup, lazy, fmap } from '../../../combinator';
5
5
  import { inline } from '../../inline';
6
6
  import { str, anyline, emptyline, contentline } from '../../source';
7
- import { visualize } from '../../visibility';
7
+ import { visualize, trimBlankStart, trimNodeEnd } from '../../visibility';
8
8
  import { unshift, splice } from 'spica/array';
9
9
  import { html, define, defrag } from 'typed-dom/dom';
10
10
 
@@ -84,9 +84,9 @@ const head: CellParser.HeadParser = creation(1, false, block(fmap(open(
84
84
  anyline,
85
85
  some(contentline, delimiter),
86
86
  ]),
87
- trim(visualize(some(union([inline]))))),
87
+ open(/^(?:\s*\n|\s)/, visualize(trimBlankStart(some(union([inline])))), true)),
88
88
  true),
89
- ns => [html('th', attributes(ns.shift()! as string), defrag(ns))]),
89
+ ns => [html('th', attributes(ns.shift()! as string), trimNodeEnd(defrag(ns)))]),
90
90
  false));
91
91
 
92
92
  const data: CellParser.DataParser = creation(1, false, block(fmap(open(
@@ -96,9 +96,9 @@ const data: CellParser.DataParser = creation(1, false, block(fmap(open(
96
96
  anyline,
97
97
  some(contentline, delimiter),
98
98
  ]),
99
- trim(visualize(some(union([inline]))))),
99
+ open(/^(?:\s*\n|\s)/, visualize(some(union([inline]))), true)),
100
100
  true),
101
- ns => [html('td', attributes(ns.shift()! as string), defrag(ns))]),
101
+ ns => [html('td', attributes(ns.shift()! as string), trimNodeEnd(defrag(ns)))]),
102
102
  false));
103
103
 
104
104
  const dataline: CellParser.DatalineParser = creation(1, false, line(
@@ -9,7 +9,6 @@ import { contentline } from '../source';
9
9
  import { State } from '../context';
10
10
  import { visualize, trimBlank } from '../visibility';
11
11
  import { memoize } from 'spica/memoize';
12
- import { shift } from 'spica/array';
13
12
  import { html, define, defrag } from 'typed-dom/dom';
14
13
 
15
14
  const openers = {
@@ -38,17 +37,16 @@ const list = (type: string, form: string): OListParser.ListParser => fmap(
38
37
  some(creation(1, false, union([
39
38
  indexee(fmap(fallback(
40
39
  inits([
41
- line(open(heads[form], subsequence([checkbox, union([
42
- trim(fmap(close(union([index]), /^$/), ([el]) => [
40
+ line(open(heads[form], subsequence([checkbox, trim(union([
41
+ fmap(close(union([index]), /^$/), ([el]) => [
43
42
  define(el, { class: void el.classList.add('indexer'), 'data-index': '' })
44
- ])),
45
- trimBlank(visualize(some(union([indexer, inline])))),
46
- ])]), true)),
43
+ ]),
44
+ visualize(trimBlank(some(union([indexer, inline])))),
45
+ ]))]), true)),
47
46
  indent(union([ulist_, olist_, ilist_])),
48
47
  ]),
49
48
  invalid),
50
- (ns: [string, ...(HTMLElement | string)[]]) =>
51
- [html('li', { 'data-marker': ns[0] || undefined }, defrag(fillFirstLine(shift(ns)[1])))]), true),
49
+ ns => [html('li', { 'data-marker': ns.shift() as string || undefined }, defrag(fillFirstLine(ns)))]), true),
52
50
  ]))),
53
51
  es => [format(html('ol', es), type, form)]);
54
52
 
@@ -23,9 +23,9 @@ const source: SidefenceParser.SourceParser = lazy(() => fmap(
23
23
  some(creation(1, false, union([
24
24
  focus(
25
25
  /^(?:\|\|+(?:[^\S\n][^\n]*)?(?:$|\n))+/,
26
- convert(unindent, source)),
26
+ convert(unindent, source, true)),
27
27
  rewrite(
28
28
  some(contentline, opener),
29
- convert(unindent, fmap(autolink, ns => [html('pre', defrag(ns))]))),
29
+ convert(unindent, fmap(autolink, ns => [html('pre', defrag(ns))]), true)),
30
30
  ]))),
31
31
  ns => [html('blockquote', ns)]));
@@ -2,7 +2,7 @@ import { TableParser } from '../block';
2
2
  import { union, sequence, some, creation, block, line, validate, focus, rewrite, surround, open, fallback, lazy, fmap } from '../../combinator';
3
3
  import { inline } from '../inline';
4
4
  import { contentline } from '../source';
5
- import { trimNode } from '../visibility';
5
+ import { trimBlankStart, trimNodeEnd } from '../visibility';
6
6
  import { duffReduce } from 'spica/duff';
7
7
  import { push } from 'spica/array';
8
8
  import { html, defrag } from 'typed-dom/dom';
@@ -49,16 +49,16 @@ const align: AlignParser = creation(1, false, fmap(open(
49
49
 
50
50
  const cell: CellParser = surround(
51
51
  /^\|\s*(?=\S)/,
52
- some(union([inline]), /^\|/, [[/^[|\\]?\s*$/, 9]]),
52
+ trimBlankStart(some(union([inline]), /^\|/, [[/^[|\\]?\s*$/, 9]])),
53
53
  /^[^|]*/, true);
54
54
 
55
55
  const head: CellParser.HeadParser = creation(1, false, fmap(
56
56
  cell,
57
- ns => [html('th', trimNode(defrag(ns)))]));
57
+ ns => [html('th', trimNodeEnd(defrag(ns)))]));
58
58
 
59
59
  const data: CellParser.DataParser = creation(1, false, fmap(
60
60
  cell,
61
- ns => [html('td', trimNode(defrag(ns)))]));
61
+ ns => [html('td', trimNodeEnd(defrag(ns)))]));
62
62
 
63
63
  function format(rows: HTMLTableRowElement[]): HTMLTableRowElement[] {
64
64
  const aligns = rows[0].className === 'invalid'
@@ -19,12 +19,12 @@ export const ulist_: UListParser = lazy(() => block(fmap(validate(
19
19
  some(creation(1, false, union([
20
20
  indexee(fmap(fallback(
21
21
  inits([
22
- line(open(/^-(?:$|\s)/, subsequence([checkbox, union([
23
- trim(fmap(close(union([index]), /^$/), ([el]) => [
22
+ line(open(/^-(?:$|\s)/, subsequence([checkbox, trim(union([
23
+ fmap(close(union([index]), /^$/), ([el]) => [
24
24
  define(el, { class: void el.classList.add('indexer'), 'data-index': '' })
25
- ])),
26
- trimBlank(visualize(some(union([indexer, inline])))),
27
- ])]), true)),
25
+ ]),
26
+ visualize(trimBlank(some(union([indexer, inline])))),
27
+ ]))]), true)),
28
28
  indent(union([ulist_, olist_, ilist_])),
29
29
  ]),
30
30
  invalid),
@@ -2,15 +2,14 @@ import { AnnotationParser } from '../inline';
2
2
  import { union, some, syntax, constraint, surround, lazy } from '../../combinator';
3
3
  import { inline } from '../inline';
4
4
  import { Syntax, State } from '../context';
5
- import { startLoose, trimNode } from '../visibility';
5
+ import { trimBlankStart, trimNodeEnd } from '../visibility';
6
6
  import { html, defrag } from 'typed-dom/dom';
7
7
 
8
8
  export const annotation: AnnotationParser = lazy(() => surround(
9
9
  '((',
10
10
  constraint(State.annotation, false,
11
11
  syntax(Syntax.none, 6, 1, State.annotation | State.media,
12
- startLoose(
13
- some(union([inline]), ')', [[/^\\?\n/, 9], [')', 2], ['))', 6]]), ')'))),
12
+ trimBlankStart(some(union([inline]), ')', [[/^\\?\n/, 9], [')', 2], ['))', 6]])))),
14
13
  '))',
15
14
  false,
16
- ([, ns], rest) => [[html('sup', { class: 'annotation' }, [html('span', trimNode(defrag(ns)))])], rest]));
15
+ ([, ns], rest) => [[html('sup', { class: 'annotation' }, [html('span', trimNodeEnd(defrag(ns)))])], rest]));
@@ -83,6 +83,7 @@ const TAGS = Object.freeze([
83
83
  "footer",
84
84
  "header",
85
85
  "h1", "h2", "h3", "h4", "h5", "h6",
86
+ "hgroup",
86
87
  "main",
87
88
  "nav",
88
89
  "section",
@@ -179,7 +180,6 @@ const TAGS = Object.freeze([
179
180
  "template",
180
181
  "acronym",
181
182
  "applet",
182
- "basefont",
183
183
  "bgsound",
184
184
  "big",
185
185
  "blink",
@@ -189,7 +189,6 @@ const TAGS = Object.freeze([
189
189
  "font",
190
190
  "frame",
191
191
  "frameset",
192
- "hgroup",
193
192
  "image",
194
193
  "keygen",
195
194
  "marquee",
@@ -1,12 +1,11 @@
1
1
  import { MarkdownParser } from '../../../markdown';
2
2
  import { LinkParser } from '../inline';
3
- import { Result } from '../../combinator/data/parser';
4
3
  import { union, inits, tails, sequence, some, constraint, syntax, creation, precedence, validate, surround, open, dup, reverse, lazy, fmap, bind } from '../../combinator';
5
4
  import { inline, media, shortmedia } from '../inline';
6
5
  import { attributes } from './html';
7
6
  import { linebreak, unescsource, str } from '../source';
8
7
  import { Syntax, State } from '../context';
9
- import { trimNode } from '../visibility';
8
+ import { trimBlankStart, trimNodeEnd } from '../visibility';
10
9
  import { stringify } from '../util';
11
10
  import { ReadonlyURL } from 'spica/url';
12
11
  import { html, define, defrag } from 'typed-dom/dom';
@@ -27,14 +26,16 @@ export const textlink: LinkParser.TextLinkParser = lazy(() =>
27
26
  bind(reverse(tails([
28
27
  dup(surround(
29
28
  '[',
30
- some(union([inline]), ']', [[/^\\?\n/, 9], [']', 2]]),
29
+ trimBlankStart(some(union([inline]), ']', [[/^\\?\n/, 9], [']', 2]])),
31
30
  ']',
32
31
  true)),
33
32
  dup(surround(/^{(?![{}])/, inits([uri, some(option)]), /^[^\S\n]*}/)),
34
33
  ])),
35
34
  ([params, content = []]: [string[], (HTMLElement | string)[]], rest, context) => {
36
35
  assert(!html('div', content).querySelector('a, .media, .annotation, .reference'));
37
- return parse(content, params, rest, context);
36
+ assert(content[0] !== '');
37
+ if (content.length !== 0 && trimNodeEnd(content = defrag(content)).length === 0) return;
38
+ return [[parse(content, params, context)], rest];
38
39
  }))));
39
40
 
40
41
  export const medialink: LinkParser.MediaLinkParser = lazy(() =>
@@ -48,7 +49,7 @@ export const medialink: LinkParser.MediaLinkParser = lazy(() =>
48
49
  dup(surround(/^{(?![{}])/, inits([uri, some(option)]), /^[^\S\n]*}/)),
49
50
  ])),
50
51
  ([params, content = []]: [string[], (HTMLElement | string)[]], rest, context) =>
51
- parse(content, params, rest, context)))));
52
+ [[parse(defrag(content), params, context)], rest]))));
52
53
 
53
54
  export const linemedialink: LinkParser.LineMediaLinkParser = surround(
54
55
  linebreak,
@@ -65,7 +66,7 @@ export const unsafelink: LinkParser.UnsafeLinkParser = lazy(() =>
65
66
  dup(surround(/^{(?![{}])/, inits([uri, some(option)]), /^[^\S\n]*}/)),
66
67
  ])),
67
68
  ([params, content = []], rest, context) =>
68
- parse(content, params, rest, context)))));
69
+ [[parse(defrag(content), params, context)], rest]))));
69
70
 
70
71
  export const uri: LinkParser.ParameterParser.UriParser = union([
71
72
  open(/^[^\S\n]+/, str(/^\S+/)),
@@ -79,14 +80,12 @@ export const option: LinkParser.ParameterParser.OptionParser = union([
79
80
  ]);
80
81
 
81
82
  function parse(
82
- content: (string | HTMLElement)[],
83
+ content: readonly (string | HTMLElement)[],
83
84
  params: string[],
84
- rest: string,
85
85
  context: MarkdownParser.Context,
86
- ): Result<HTMLAnchorElement, MarkdownParser.Context> {
86
+ ): HTMLAnchorElement {
87
87
  assert(params.length > 0);
88
88
  assert(params.every(p => typeof p === 'string'));
89
- if (content.length !== 0 && trimNode(content).length === 0) return;
90
89
  const INSECURE_URI = params.shift()!;
91
90
  assert(INSECURE_URI === INSECURE_URI.trim());
92
91
  assert(!INSECURE_URI.match(/\s/));
@@ -95,11 +94,12 @@ function parse(
95
94
  context.host?.href || location.href);
96
95
  const el = elem(
97
96
  INSECURE_URI,
98
- defrag(content),
97
+ content,
99
98
  uri,
100
99
  context.host?.origin || location.origin);
101
- if (el.className === 'invalid') return [[el], rest];
102
- return [[define(el, attributes('link', [], optspec, params))], rest];
100
+ return el.className === 'invalid'
101
+ ? el
102
+ : define(el, attributes('link', [], optspec, params));
103
103
  }
104
104
 
105
105
  function elem(
@@ -1,31 +1,31 @@
1
1
  import { ReferenceParser } from '../inline';
2
- import { union, subsequence, some, syntax, creation, constraint, surround, lazy, fmap, bind } from '../../combinator';
2
+ import { union, subsequence, some, syntax, creation, constraint, surround, lazy } from '../../combinator';
3
3
  import { inline } from '../inline';
4
4
  import { str } from '../source';
5
5
  import { Syntax, State } from '../context';
6
- import { regBlankStart, startLoose, trimNode } from '../visibility';
6
+ import { blank, trimBlankStart, trimNodeEnd } from '../visibility';
7
7
  import { html, defrag } from 'typed-dom/dom';
8
8
 
9
9
  export const reference: ReferenceParser = lazy(() => surround(
10
10
  '[[',
11
11
  constraint(State.reference, false,
12
12
  syntax(Syntax.reference, 6, 1, State.annotation | State.reference | State.media,
13
- startLoose(
14
13
  subsequence([
15
14
  abbr,
16
- fmap(str('^'), ns => ['', ...ns]),
17
- some(inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]]),
18
- ]), ']'))),
15
+ trimBlankStart(some(inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]])),
16
+ ]))),
19
17
  ']]',
20
18
  false,
21
- ([, ns], rest) => [[html('sup', attributes(ns), [html('span', trimNode(defrag(ns)))])], rest]));
19
+ ([, ns], rest) => [[html('sup', attributes(ns), [html('span', trimNodeEnd(defrag(ns)))])], rest]));
22
20
 
23
21
  // Chicago-Style
24
- const abbr: ReferenceParser.AbbrParser = creation(bind(surround(
22
+ const abbr: ReferenceParser.AbbrParser = creation(surround(
25
23
  '^',
26
24
  union([str(/^(?=[A-Z])(?:[0-9A-Za-z]'?|(?:[-.:]|\.?\??,? ?)(?!['\-.:?, ]))+/)]),
27
- /^\|?(?=]])|^\|[^\S\n]*/),
28
- ([source], rest) => [['\n', source.trimEnd()], rest.replace(regBlankStart, '')]));
25
+ /^\|?(?=]])|^\|[^\S\n]*/,
26
+ true,
27
+ ([, ns], rest) => ns ? [['\n', ns[0].trimEnd()], rest.replace(blank.start, '')] : [[''], `^${rest}`],
28
+ ([, , rest]) => [[''], `^${rest}`]));
29
29
 
30
30
  function attributes(ns: (string | HTMLElement)[]): Record<string, string | undefined> {
31
31
  switch (ns[0]) {
@@ -89,7 +89,7 @@ function attributes(texts: string[], rubies: string[]): Record<string, string> {
89
89
  let attrs: Record<string, string> | undefined;
90
90
  for (const ss of [texts, rubies]) {
91
91
  for (let i = 0; i < ss.length; ++i) {
92
- if (ss[i].indexOf('\x1B') === -1) continue;
92
+ if (!ss[i].includes('\x1B')) continue;
93
93
  ss[i] = ss[i].replace(/\x1B/g, '');
94
94
  attrs ??= {
95
95
  class: 'invalid',
@@ -8,14 +8,21 @@ import { invisibleHTMLEntityNames } from './api/normalize';
8
8
  import { reduce } from 'spica/memoize';
9
9
  import { push } from 'spica/array';
10
10
 
11
+ export namespace blank {
12
+ export const line = new RegExp(
13
+ /^(?:\\?[^\S\n]|&IHN;|<wbr[^\S\n]*>|\\$)+$/.source
14
+ .replace('IHN', `(?:${invisibleHTMLEntityNames.join('|')})`),
15
+ 'gm');
16
+ export const start = new RegExp(
17
+ /^(?:\\?[^\S\n]|&IHN;|<wbr[^\S\n]*>)+/.source
18
+ .replace('IHN', `(?:${invisibleHTMLEntityNames.join('|')})`));
19
+ }
20
+
11
21
  export function visualize<P extends Parser<HTMLElement | string>>(parser: P): P;
12
22
  export function visualize<T extends HTMLElement | string>(parser: Parser<T>): Parser<T> {
13
- const blankline = new RegExp(
14
- /^(?:\\$|\\?[^\S\n]|&IHN;|<wbr[^\S\n]*>)+$/.source.replace('IHN', `(?:${invisibleHTMLEntityNames.join('|')})`),
15
- 'gm');
16
23
  return union([
17
24
  convert(
18
- source => source.replace(blankline, line => line.replace(/[\\&<]/g, '\x1B$&')),
25
+ source => source.replace(blank.line, line => line.replace(/[\\&<]/g, '\x1B$&')),
19
26
  verify(parser, (ns, rest, context) => !rest && hasVisible(ns, context))),
20
27
  some(union([linebreak, unescsource])),
21
28
  ]);
@@ -38,9 +45,6 @@ function hasVisible(
38
45
  return false;
39
46
  }
40
47
 
41
- export const regBlankStart = new RegExp(
42
- /^(?:\\?[^\S\n]|&IHN;|<wbr[^\S\n]*>)+/.source.replace('IHN', `(?:${invisibleHTMLEntityNames.join('|')})`));
43
-
44
48
  export function blankWith(delimiter: string | RegExp): RegExp;
45
49
  export function blankWith(starting: '' | '\n', delimiter: string | RegExp): RegExp;
46
50
  export function blankWith(starting: '' | '\n', delimiter?: string | RegExp): RegExp {
@@ -53,16 +57,16 @@ export function blankWith(starting: '' | '\n', delimiter?: string | RegExp): Reg
53
57
  }`);
54
58
  }
55
59
 
56
- export function startLoose<P extends Parser<HTMLElement | string>>(parser: P, except?: string): P;
57
- export function startLoose<T extends HTMLElement | string>(parser: Parser<T>, except?: string): Parser<T> {
58
- return input =>
59
- isStartLoose(input, except)
60
- ? parser(input)
61
- : undefined;
62
- }
63
- const isStartLoose = reduce(({ source, context }: Input<MarkdownParser.Context>, except?: string): boolean => {
64
- return isStartTight({ source: source.replace(regBlankStart, ''), context }, except);
65
- }, ({ source }, except = '') => `${source}\x1E${except}`);
60
+ //export function startLoose<P extends Parser<HTMLElement | string>>(parser: P, except?: string): P;
61
+ //export function startLoose<T extends HTMLElement | string>(parser: Parser<T>, except?: string): Parser<T> {
62
+ // return input =>
63
+ // isStartLoose(input, except)
64
+ // ? parser(input)
65
+ // : undefined;
66
+ //}
67
+ //const isStartLoose = reduce(({ source, context }: Input<MarkdownParser.Context>, except?: string): boolean => {
68
+ // return isStartTight({ source: source.replace(blank.start, ''), context }, except);
69
+ //}, ({ source }, except = '') => `${source}\x1E${except}`);
66
70
 
67
71
  export function startTight<P extends Parser<unknown>>(parser: P, except?: string): P;
68
72
  export function startTight<T>(parser: Parser<T>, except?: string): Parser<T> {
@@ -154,7 +158,7 @@ export function trimBlank<T extends HTMLElement | string>(parser: Parser<T>): Pa
154
158
  export function trimBlankStart<P extends Parser<unknown>>(parser: P): P;
155
159
  export function trimBlankStart<T>(parser: Parser<T>): Parser<T> {
156
160
  return convert(
157
- reduce(source => source.replace(regBlankStart, '')),
161
+ source => source.replace(blank.start, ''),
158
162
  parser);
159
163
  }
160
164
  function trimBlankEnd<P extends Parser<HTMLElement | string>>(parser: P): P;
@@ -163,23 +167,23 @@ function trimBlankEnd<T extends HTMLElement | string>(parser: Parser<T>): Parser
163
167
  parser,
164
168
  trimNodeEnd);
165
169
  }
166
- export function trimNode<T extends HTMLElement | string>(nodes: T[]): T[] {
167
- return trimNodeStart(trimNodeEnd(nodes));
168
- }
169
- function trimNodeStart<T extends HTMLElement | string>(nodes: T[]): T[] {
170
- for (let node = nodes[0]; nodes.length > 0 && !isVisible(node = nodes[0], 0);) {
171
- if (nodes.length === 1 && typeof node === 'object' && node.className === 'indexer') break;
172
- if (typeof node === 'string') {
173
- const pos = node.trimStart().length;
174
- if (pos > 0) {
175
- nodes[0] = node.slice(-pos) as T;
176
- break;
177
- }
178
- }
179
- nodes.shift();
180
- }
181
- return nodes;
182
- }
170
+ //export function trimNode<T extends HTMLElement | string>(nodes: T[]): T[] {
171
+ // return trimNodeStart(trimNodeEnd(nodes));
172
+ //}
173
+ //function trimNodeStart<T extends HTMLElement | string>(nodes: T[]): T[] {
174
+ // for (let node = nodes[0]; nodes.length > 0 && !isVisible(node = nodes[0], 0);) {
175
+ // if (nodes.length === 1 && typeof node === 'object' && node.className === 'indexer') break;
176
+ // if (typeof node === 'string') {
177
+ // const pos = node.trimStart().length;
178
+ // if (pos > 0) {
179
+ // nodes[0] = node.slice(-pos) as T;
180
+ // break;
181
+ // }
182
+ // }
183
+ // nodes.shift();
184
+ // }
185
+ // return nodes;
186
+ //}
183
187
  export function trimNodeEnd<T extends HTMLElement | string>(nodes: T[]): T[] {
184
188
  const skip = nodes.length > 0 &&
185
189
  typeof nodes[nodes.length - 1] === 'object' &&