securemark 0.270.0 → 0.270.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.270.2
4
+
5
+ - Refactoring.
6
+
7
+ ## 0.270.1
8
+
9
+ - Refactoring.
10
+
3
11
  ## 0.270.0
4
12
 
5
13
  - Change the operator precedence of double quotation to 3.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.270.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.270.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"));
@@ -2090,7 +2090,13 @@ exports.pcg32 = exports.xorshift = exports.unique = exports.rndAf = exports.rndA
2090
2090
  const bases = Object.freeze([...Array(7)].map((_, i) => 1 << i));
2091
2091
  const masks = Object.freeze(bases.map(radix => radix - 1));
2092
2092
  const dict0_ = [...[...Array(36)].map((_, i) => i.toString(36)), ...[...Array(36)].map((_, i) => i.toString(36).toUpperCase()).slice(-26), '-', '_'].join('');
2093
+
2094
+ // eslint-disable-next-line
2095
+
2093
2096
  const dictAz = [...[...Array(36)].map((_, i) => i.toString(36).toUpperCase()).slice(-26), ...[...Array(36)].map((_, i) => i.toString(36)).slice(-26)].join('');
2097
+
2098
+ // eslint-disable-next-line
2099
+
2094
2100
  exports.rnd16 = cons(16);
2095
2101
  exports.rnd32 = cons(32);
2096
2102
  exports.rnd62 = cons(62);
@@ -2391,7 +2397,10 @@ class URL {
2391
2397
  this.source = source;
2392
2398
  this.base = base;
2393
2399
  this.url = new format_1.ReadonlyURL(source, base);
2400
+
2401
+ //assert(this.href.startsWith(this.resource));
2394
2402
  }
2403
+
2395
2404
  get href() {
2396
2405
  return this.params?.toString().replace(/^(?=.)/, `${this.url.href.slice(0, -this.url.query.length - this.url.fragment.length || this.url.href.length)}?`).concat(this.fragment) ?? this.url.href;
2397
2406
  }
@@ -4456,8 +4465,8 @@ const visibility_1 = __webpack_require__(7618);
4456
4465
  const array_1 = __webpack_require__(8112);
4457
4466
  const dom_1 = __webpack_require__(3252);
4458
4467
  exports.dlist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^~[^\S\n]+(?=\S)/, (0, combinator_1.some)((0, combinator_1.inits)([(0, combinator_1.state)(256 /* State.annotation */ | 128 /* State.reference */ | 64 /* State.index */ | 32 /* State.label */ | 16 /* State.link */ | 8 /* State.media */, (0, combinator_1.some)(term)), (0, combinator_1.some)(desc)]))), es => [(0, dom_1.html)('dl', fillTrailingDescription(es))])));
4459
- const term = (0, combinator_1.creation)(1, false, (0, combinator_1.line)((0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.open)(/^~[^\S\n]+(?=\S)/, (0, visibility_1.visualize)((0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))), true), ns => [(0, dom_1.html)('dt', (0, dom_1.defrag)(ns))]))));
4460
- const desc = (0, combinator_1.creation)(1, false, (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)(/^:[^\S\n]+(?=\S)|/, (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.anyline, /^[~:][^\S\n]+\S/), (0, visibility_1.visualize)((0, combinator_1.trimEnd)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))))), true), ns => [(0, dom_1.html)('dd', (0, dom_1.defrag)(ns))]), false));
4468
+ const term = (0, combinator_1.creation)(1, false, (0, combinator_1.line)((0, inline_1.indexee)((0, combinator_1.fmap)((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.indexer, inline_1.inline])))), true), ns => [(0, dom_1.html)('dt', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))]))));
4469
+ const desc = (0, combinator_1.creation)(1, false, (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)(/^:[^\S\n]+(?=\S)|/, (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.anyline, /^[~:][^\S\n]+\S/), (0, visibility_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline])))), true), ns => [(0, dom_1.html)('dd', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))]), false));
4461
4470
  function fillTrailingDescription(es) {
4462
4471
  return es.length > 0 && es[es.length - 1].tagName === 'DT' ? (0, array_1.push)(es, [(0, dom_1.html)('dd')]) : es;
4463
4472
  }
@@ -4692,11 +4701,11 @@ const dom_1 = __webpack_require__(3252);
4692
4701
  exports.segment = (0, combinator_1.block)((0, combinator_1.match)(/^(~{3,})(?:figure[^\S\n])?(?=\[?\$)/, (0, memoize_1.memoize)(([, fence], closer = new RegExp(String.raw`^${fence}[^\S\n]*(?:$|\n)`)) => (0, combinator_1.close)((0, combinator_1.sequence)([source_1.contentline, (0, combinator_1.inits)([
4693
4702
  // All parsers which can include closing terms.
4694
4703
  (0, combinator_1.union)([codeblock_1.segment_, mathblock_1.segment_, table_2.segment_, blockquote_1.segment, placeholder_1.segment_, (0, combinator_1.some)(source_1.contentline, closer)]), source_1.emptyline, (0, combinator_1.union)([source_1.emptyline, (0, combinator_1.some)(source_1.contentline, closer)])])]), closer), ([, fence]) => fence.length, [])));
4695
- exports.figure = (0, combinator_1.block)((0, combinator_1.fallback)((0, combinator_1.rewrite)(exports.segment, (0, combinator_1.fmap)((0, combinator_1.convert)(source => source.slice(source.match(/^~+(?:\w+\s+)?/)[0].length, source.trimEnd().lastIndexOf('\n')), (0, combinator_1.sequence)([(0, combinator_1.line)((0, combinator_1.sequence)([label_1.label, (0, source_1.str)(/^(?=\s).*\n/)])), (0, combinator_1.inits)([(0, combinator_1.block)((0, combinator_1.union)([ulist_1.ulist, olist_1.olist, table_1.table, codeblock_1.codeblock, mathblock_1.mathblock, example_1.example, table_2.table, blockquote_1.blockquote, placeholder_1.placeholder, (0, combinator_1.line)(inline_1.media), (0, combinator_1.line)(inline_1.shortmedia)])), source_1.emptyline, (0, combinator_1.block)((0, combinator_1.state)(8 /* State.media */, (0, visibility_1.visualize)((0, visibility_1.trimBlank)((0, combinator_1.trimEnd)((0, combinator_1.some)(inline_1.inline))))))])])), ([label, param, content, ...caption]) => [(0, dom_1.html)('figure', attributes(label.getAttribute('data-label'), param, content, caption), [(0, dom_1.html)('figcaption', [(0, dom_1.html)('span', {
4704
+ exports.figure = (0, combinator_1.block)((0, combinator_1.fallback)((0, combinator_1.rewrite)(exports.segment, (0, combinator_1.fmap)((0, combinator_1.convert)(source => source.slice(source.match(/^~+(?:\w+\s+)?/)[0].length, source.trimEnd().lastIndexOf('\n')), (0, combinator_1.sequence)([(0, combinator_1.line)((0, combinator_1.sequence)([label_1.label, (0, source_1.str)(/^(?=\s).*\n/)])), (0, combinator_1.inits)([(0, combinator_1.block)((0, combinator_1.union)([ulist_1.ulist, olist_1.olist, table_1.table, codeblock_1.codeblock, mathblock_1.mathblock, example_1.example, table_2.table, blockquote_1.blockquote, placeholder_1.placeholder, (0, combinator_1.line)(inline_1.media), (0, combinator_1.line)(inline_1.shortmedia)])), source_1.emptyline, (0, combinator_1.block)((0, combinator_1.state)(8 /* State.media */, (0, visibility_1.visualize)((0, visibility_1.trimBlankStart)((0, combinator_1.some)(inline_1.inline)))))])])), ([label, param, content, ...caption]) => [(0, dom_1.html)('figure', attributes(label.getAttribute('data-label'), param, content, caption), [(0, dom_1.html)('figcaption', [(0, dom_1.html)('span', {
4696
4705
  class: 'figindex'
4697
4706
  }), (0, dom_1.html)('span', {
4698
4707
  class: 'figtext'
4699
- }, (0, dom_1.defrag)(caption))]), (0, dom_1.html)('div', [content])])])), (0, combinator_1.fmap)((0, combinator_1.fence)(/^(~{3,})(?:figure|\[?\$\S*)(?!\S)[^\n]*(?:$|\n)/, 300), ([body, overflow, closer, opener, delim], _, context) => [(0, dom_1.html)('pre', {
4708
+ }, (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(caption)))]), (0, dom_1.html)('div', [content])])])), (0, combinator_1.fmap)((0, combinator_1.fence)(/^(~{3,})(?:figure|\[?\$\S*)(?!\S)[^\n]*(?:$|\n)/, 300), ([body, overflow, closer, opener, delim], _, context) => [(0, dom_1.html)('pre', {
4700
4709
  class: 'invalid',
4701
4710
  translate: 'no',
4702
4711
  'data-invalid-syntax': 'figure',
@@ -5139,12 +5148,12 @@ const dom_1 = __webpack_require__(3252);
5139
5148
  exports.segment = (0, combinator_1.block)((0, combinator_1.validate)('#', (0, combinator_1.focus)(/^#+[^\S\n]+\S[^\n]*(?:\n#+(?!\S)[^\n]*)*(?:$|\n)/, (0, combinator_1.some)((0, combinator_1.line)(({
5140
5149
  source
5141
5150
  }) => [[source], ''])))));
5142
- exports.heading = (0, combinator_1.block)((0, combinator_1.rewrite)(exports.segment, (0, combinator_1.state)(256 /* State.annotation */ | 128 /* State.reference */ | 64 /* State.index */ | 32 /* State.label */ | 16 /* State.link */ | 8 /* State.media */, (0, combinator_1.line)((0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.union)([(0, combinator_1.open)((0, source_1.str)(/^##+/), (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.open)((0, source_1.str)('#'), (0, combinator_1.state)(2 /* State.autolink */, (0, visibility_1.visualize)((0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline]))))), true)]), ([h, ...ns]) => [h.length <= 6 ? (0, dom_1.html)(`h${h.length}`, (0, dom_1.defrag)(ns)) : (0, dom_1.html)(`h6`, {
5151
+ exports.heading = (0, combinator_1.block)((0, combinator_1.rewrite)(exports.segment, (0, combinator_1.state)(256 /* State.annotation */ | 128 /* State.reference */ | 64 /* State.index */ | 32 /* State.label */ | 16 /* State.link */ | 8 /* State.media */, (0, combinator_1.line)((0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.union)([(0, combinator_1.open)((0, source_1.str)(/^##+/), (0, visibility_1.visualize)((0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))), true), (0, combinator_1.open)((0, source_1.str)('#'), (0, combinator_1.state)(2 /* State.autolink */, (0, visibility_1.visualize)((0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline]))))), true)]), ([h, ...ns]) => [h.length <= 6 ? (0, dom_1.html)(`h${h.length}`, (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns))) : (0, dom_1.html)(`h6`, {
5143
5152
  class: 'invalid',
5144
5153
  'data-invalid-syntax': 'heading',
5145
5154
  'data-invalid-type': 'syntax',
5146
5155
  'data-invalid-message': 'Heading level must be up to 6'
5147
- }, (0, dom_1.defrag)(ns))]))))));
5156
+ }, (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))]))))));
5148
5157
 
5149
5158
  /***/ }),
5150
5159
 
@@ -5375,7 +5384,7 @@ const combinator_1 = __webpack_require__(2087);
5375
5384
  const inline_1 = __webpack_require__(1160);
5376
5385
  const visibility_1 = __webpack_require__(7618);
5377
5386
  const dom_1 = __webpack_require__(3252);
5378
- exports.paragraph = (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.convert)(source => `\r${source}`, (0, visibility_1.visualize)((0, combinator_1.trimEnd)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))))), ns => [(0, dom_1.html)('p', (0, dom_1.defrag)(ns))]));
5387
+ exports.paragraph = (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.convert)(source => `\r${source}`, (0, visibility_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline])))), ns => [(0, dom_1.html)('p', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))]));
5379
5388
 
5380
5389
  /***/ }),
5381
5390
 
@@ -5403,7 +5412,7 @@ const dom_1 = __webpack_require__(3252);
5403
5412
  対象をURLで指定すべき(引用ツリーにルートを追加する)場合はない
5404
5413
  対象と引用は1:N(分割)、N:1(統合)のみ可能、N:N(混合)は不可能
5405
5414
  */
5406
- exports.reply = (0, combinator_1.block)((0, combinator_1.validate)('>', (0, combinator_1.fmap)((0, combinator_1.inits)([(0, combinator_1.some)((0, combinator_1.inits)([cite_1.cite, quote_1.quote])), (0, combinator_1.some)((0, combinator_1.subsequence)([(0, combinator_1.some)(quote_1.quote), (0, combinator_1.fmap)((0, combinator_1.rewrite)((0, combinator_1.some)(source_1.anyline, quote_1.syntax), (0, visibility_1.visualize)((0, combinator_1.trimEnd)((0, combinator_1.some)(inline_1.inline)))), ns => (0, array_1.push)(ns, [(0, dom_1.html)('br')]))]))]), ns => [(0, dom_1.html)('p', (0, dom_1.defrag)((0, array_1.pop)(ns)[0]))])));
5415
+ exports.reply = (0, combinator_1.block)((0, combinator_1.validate)('>', (0, combinator_1.fmap)((0, combinator_1.inits)([(0, combinator_1.some)((0, combinator_1.inits)([cite_1.cite, quote_1.quote])), (0, combinator_1.some)((0, combinator_1.subsequence)([(0, combinator_1.some)(quote_1.quote), (0, combinator_1.fmap)((0, combinator_1.rewrite)((0, combinator_1.some)(source_1.anyline, quote_1.syntax), (0, visibility_1.visualize)((0, combinator_1.some)(inline_1.inline))), ns => (0, array_1.push)(ns, [(0, dom_1.html)('br')]))]))]), ns => [(0, dom_1.html)('p', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))])));
5407
5416
 
5408
5417
  /***/ }),
5409
5418
 
@@ -6101,7 +6110,7 @@ const indexee_1 = __webpack_require__(1269);
6101
6110
  const source_1 = __webpack_require__(6743);
6102
6111
  const visibility_1 = __webpack_require__(7618);
6103
6112
  const dom_1 = __webpack_require__(3252);
6104
- exports.index = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[#', (0, combinator_1.fmap)((0, indexee_1.indexee)((0, combinator_1.surround)('[#', (0, combinator_1.constraint)(64 /* State.index */, false, (0, combinator_1.syntax)(128 /* Syntax.index */, 2, 1, 502 /* State.linkers */ | 8 /* State.media */, (0, visibility_1.startTight)((0, combinator_1.open)((0, source_1.stropt)('|'), (0, visibility_1.trimBlankEnd)((0, combinator_1.some)((0, combinator_1.union)([signature, inline_1.inline]), ']', [[/^\\?\n/, 9], [']', 2]])), true)))), ']', false, ([, ns], rest) => [[(0, dom_1.html)('a', (0, dom_1.defrag)(ns))], rest])), ([el]) => [(0, dom_1.define)(el, {
6113
+ exports.index = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[#', (0, combinator_1.fmap)((0, indexee_1.indexee)((0, combinator_1.surround)('[#', (0, combinator_1.constraint)(64 /* State.index */, false, (0, combinator_1.syntax)(128 /* Syntax.index */, 2, 1, 502 /* State.linkers */ | 8 /* State.media */, (0, visibility_1.startTight)((0, combinator_1.open)((0, source_1.stropt)('|'), (0, combinator_1.some)((0, combinator_1.union)([signature, inline_1.inline]), ']', [[/^\\?\n/, 9], [']', 2]]), true)))), ']', false, ([, ns], rest) => [[(0, dom_1.html)('a', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))], rest])), ([el]) => [(0, dom_1.define)(el, {
6105
6114
  id: el.id ? null : undefined,
6106
6115
  class: 'index',
6107
6116
  href: el.id ? `#${el.id}` : undefined
@@ -6271,7 +6280,7 @@ const array_1 = __webpack_require__(8112);
6271
6280
  const dom_1 = __webpack_require__(3252);
6272
6281
  // Don't use the symbols already used: !#$%@&*+~=|
6273
6282
  // All syntax surrounded by square brackets shouldn't contain line breaks.
6274
- exports.placeholder = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[', (0, combinator_1.surround)((0, source_1.str)(/^\[[:^|]/), (0, combinator_1.syntax)(64 /* Syntax.placeholder */, 2, 1, 0 /* State.none */, (0, visibility_1.startTight)((0, visibility_1.trimBlankEnd)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [[']', 2]])))), (0, source_1.str)(']'), false, ([, bs], rest) => [[(0, dom_1.html)('span', {
6283
+ exports.placeholder = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[', (0, combinator_1.surround)((0, source_1.str)(/^\[[:^|]/), (0, combinator_1.syntax)(64 /* Syntax.placeholder */, 2, 1, 0 /* State.none */, (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [[']', 2]]))), (0, source_1.str)(']'), false, ([, bs], rest) => [[(0, dom_1.html)('span', {
6275
6284
  class: 'invalid',
6276
6285
  'data-invalid-syntax': 'extension',
6277
6286
  'data-invalid-type': 'syntax',
@@ -6700,7 +6709,7 @@ const source_1 = __webpack_require__(6743);
6700
6709
  const visibility_1 = __webpack_require__(7618);
6701
6710
  const util_1 = __webpack_require__(9437);
6702
6711
  const dom_1 = __webpack_require__(3252);
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]));
6712
+ 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]));
6704
6713
  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, '')]));
6705
6714
  function attributes(ns) {
6706
6715
  return typeof ns[0] === 'object' && ns[0].tagName === 'ABBR' ? {
@@ -7579,7 +7588,7 @@ exports.stringify = stringify;
7579
7588
  Object.defineProperty(exports, "__esModule", ({
7580
7589
  value: true
7581
7590
  }));
7582
- exports.trimNode = exports.trimBlankEnd = exports.trimBlankStart = exports.trimBlank = exports.isStartTightNodes = exports.isStartLooseNodes = exports.startTight = exports.startLoose = exports.blankWith = exports.regBlankStart = exports.visualize = void 0;
7591
+ exports.trimNodeEnd = exports.trimNode = exports.trimBlankStart = exports.trimBlank = exports.isStartTightNodes = exports.isStartLooseNodes = exports.startTight = exports.startLoose = exports.blankWith = exports.regBlankStart = exports.visualize = void 0;
7583
7592
  const parser_1 = __webpack_require__(6728);
7584
7593
  const combinator_1 = __webpack_require__(2087);
7585
7594
  const htmlentity_1 = __webpack_require__(1562);
@@ -7719,7 +7728,6 @@ exports.trimBlankStart = trimBlankStart;
7719
7728
  function trimBlankEnd(parser) {
7720
7729
  return (0, combinator_1.fmap)(parser, trimNodeEnd);
7721
7730
  }
7722
- exports.trimBlankEnd = trimBlankEnd;
7723
7731
  function trimNode(nodes) {
7724
7732
  return trimNodeStart(trimNodeEnd(nodes));
7725
7733
  }
@@ -7752,6 +7760,7 @@ function trimNodeEnd(nodes) {
7752
7760
  }
7753
7761
  return (0, array_1.push)(nodes, skip);
7754
7762
  }
7763
+ exports.trimNodeEnd = trimNodeEnd;
7755
7764
 
7756
7765
  /***/ }),
7757
7766
 
@@ -8714,9 +8723,9 @@ exports.defrag = defrag;
8714
8723
  /******/ // startup
8715
8724
  /******/ // Load entry module and return exports
8716
8725
  /******/ // This entry module is referenced by other modules so it can't be inlined
8717
- /******/ var __webpack_exports__ = __nested_webpack_require_11449__(521);
8726
+ /******/ var __nested_webpack_exports__ = __nested_webpack_require_11449__(521);
8718
8727
  /******/
8719
- /******/ return __webpack_exports__;
8728
+ /******/ return __nested_webpack_exports__;
8720
8729
  /******/ })()
8721
8730
  ;
8722
8731
  });
@@ -8734,10 +8743,10 @@ exports.defrag = defrag;
8734
8743
  })(this, () => {
8735
8744
  return /******/ (() => { // webpackBootstrap
8736
8745
  /******/ "use strict";
8737
- var __webpack_exports__ = {};
8746
+ var __nested_webpack_exports__ = {};
8738
8747
  // This entry need to be wrapped in an IIFE because it uses a non-standard name for the exports (exports).
8739
8748
  (() => {
8740
- var exports = __webpack_exports__;
8749
+ var exports = __nested_webpack_exports__;
8741
8750
 
8742
8751
 
8743
8752
  Object.defineProperty(exports, "__esModule", ({
@@ -8769,7 +8778,7 @@ function querySelectorAll(node, selector) {
8769
8778
  exports.querySelectorAll = querySelectorAll;
8770
8779
  })();
8771
8780
 
8772
- /******/ return __webpack_exports__;
8781
+ /******/ return __nested_webpack_exports__;
8773
8782
  /******/ })()
8774
8783
  ;
8775
8784
  });
package/markdown.d.ts CHANGED
@@ -663,7 +663,7 @@ export namespace MarkdownParser {
663
663
  Inline<'reference'>,
664
664
  Parser<HTMLElement, Context, [
665
665
  ReferenceParser.AbbrParser,
666
- InlineParser,
666
+ SourceParser.StrParser,
667
667
  InlineParser,
668
668
  ]> {
669
669
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securemark",
3
- "version": "0.270.0",
3
+ "version": "0.270.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",
@@ -1,9 +1,9 @@
1
1
  import { DListParser } from '../block';
2
- import { union, inits, some, creation, state, block, line, validate, rewrite, open, trimEnd, lazy, fmap } from '../../combinator';
2
+ import { union, inits, some, creation, state, block, line, validate, rewrite, open, lazy, fmap } from '../../combinator';
3
3
  import { inline, indexee, indexer } from '../inline';
4
4
  import { anyline } from '../source';
5
5
  import { State } from '../context';
6
- import { visualize, trimBlank } from '../visibility';
6
+ import { visualize, trimBlankStart, trimNodeEnd } from '../visibility';
7
7
  import { push } from 'spica/array';
8
8
  import { html, defrag } from 'typed-dom/dom';
9
9
 
@@ -18,17 +18,17 @@ export const dlist: DListParser = lazy(() => block(fmap(validate(
18
18
 
19
19
  const term: DListParser.TermParser = creation(1, false, line(indexee(fmap(open(
20
20
  /^~[^\S\n]+(?=\S)/,
21
- visualize(trimBlank(some(union([indexer, inline])))),
21
+ visualize(trimBlankStart(some(union([indexer, inline])))),
22
22
  true),
23
- ns => [html('dt', defrag(ns))]))));
23
+ ns => [html('dt', trimNodeEnd(defrag(ns)))]))));
24
24
 
25
25
  const desc: DListParser.DescriptionParser = creation(1, false, block(fmap(open(
26
26
  /^:[^\S\n]+(?=\S)|/,
27
27
  rewrite(
28
28
  some(anyline, /^[~:][^\S\n]+\S/),
29
- visualize(trimEnd(some(union([inline]))))),
29
+ visualize(some(union([inline])))),
30
30
  true),
31
- ns => [html('dd', defrag(ns))]),
31
+ ns => [html('dd', trimNodeEnd(defrag(ns)))]),
32
32
  false));
33
33
 
34
34
  function fillTrailingDescription(es: HTMLElement[]): HTMLElement[] {
@@ -1,5 +1,5 @@
1
1
  import { ExtensionParser } from '../../block';
2
- import { union, inits, sequence, some, state, block, line, fence, rewrite, close, match, convert, trimEnd, fallback, fmap } from '../../../combinator';
2
+ import { union, inits, sequence, some, state, block, line, fence, rewrite, close, match, convert, fallback, fmap } from '../../../combinator';
3
3
  import { str, contentline, emptyline } from '../../source';
4
4
  import { label, segment as seg_label } from '../../inline/extension/label';
5
5
  import { ulist } from '../ulist';
@@ -13,7 +13,7 @@ import { blockquote, segment as seg_blockquote } from '../blockquote';
13
13
  import { placeholder, segment_ as seg_placeholder } from './placeholder';
14
14
  import { inline, media, shortmedia } from '../../inline';
15
15
  import { State } from '../../context';
16
- import { visualize, trimBlank } from '../../visibility';
16
+ import { visualize, trimBlankStart, trimNodeEnd } from '../../visibility';
17
17
  import { memoize } from 'spica/memoize';
18
18
  import { html, defrag } from 'typed-dom/dom';
19
19
 
@@ -66,7 +66,7 @@ export const figure: FigureParser = block(fallback(rewrite(segment, fmap(
66
66
  emptyline,
67
67
  block(
68
68
  state(State.media,
69
- visualize(trimBlank(trimEnd(some(inline)))))),
69
+ visualize(trimBlankStart(some(inline))))),
70
70
  ]),
71
71
  ])),
72
72
  ([label, param, content, ...caption]: [HTMLAnchorElement, string, ...HTMLElement[]]) => [
@@ -75,7 +75,7 @@ export const figure: FigureParser = block(fallback(rewrite(segment, fmap(
75
75
  [
76
76
  html('figcaption', [
77
77
  html('span', { class: 'figindex' }),
78
- html('span', { class: 'figtext' }, defrag(caption)),
78
+ html('span', { class: 'figtext' }, trimNodeEnd(defrag(caption))),
79
79
  ]),
80
80
  html('div', [content]),
81
81
  ])
@@ -3,7 +3,7 @@ import { union, some, state, block, line, validate, focus, rewrite, open, fmap }
3
3
  import { inline, indexee, indexer } from '../inline';
4
4
  import { str } from '../source';
5
5
  import { State } from '../context';
6
- import { visualize, trimBlank } from '../visibility';
6
+ import { visualize, trimBlankStart, trimNodeEnd } from '../visibility';
7
7
  import { html, defrag } from 'typed-dom/dom';
8
8
 
9
9
  export const segment: HeadingParser.SegmentParser = block(validate('#', focus(
@@ -15,19 +15,19 @@ export const heading: HeadingParser = block(rewrite(segment,
15
15
  line(indexee(fmap(union([
16
16
  open(
17
17
  str(/^##+/),
18
- visualize(trimBlank(some(union([indexer, inline])))), true),
18
+ visualize(trimBlankStart(some(union([indexer, inline])))), true),
19
19
  open(
20
20
  str('#'),
21
21
  state(State.autolink,
22
- visualize(trimBlank(some(union([indexer, inline]))))), true),
22
+ visualize(trimBlankStart(some(union([indexer, inline]))))), true),
23
23
  ]),
24
24
  ([h, ...ns]: [string, ...(HTMLElement | string)[]]) => [
25
25
  h.length <= 6
26
- ? html(`h${h.length as 1}`, defrag(ns))
26
+ ? html(`h${h.length as 1}`, trimNodeEnd(defrag(ns)))
27
27
  : html(`h6`, {
28
28
  class: 'invalid',
29
29
  'data-invalid-syntax': 'heading',
30
30
  'data-invalid-type': 'syntax',
31
31
  'data-invalid-message': 'Heading level must be up to 6',
32
- }, defrag(ns))
32
+ }, trimNodeEnd(defrag(ns)))
33
33
  ]))))));
@@ -1,10 +1,10 @@
1
1
  import { ParagraphParser } from '../block';
2
- import { union, some, block, convert, trimEnd, fmap } from '../../combinator';
2
+ import { union, some, block, convert, fmap } from '../../combinator';
3
3
  import { inline } from '../inline';
4
- import { visualize } from '../visibility';
4
+ import { visualize, trimNodeEnd } from '../visibility';
5
5
  import { html, defrag } from 'typed-dom/dom';
6
6
 
7
7
  export const paragraph: ParagraphParser = block(fmap(
8
8
  convert(source => `\r${source}`,
9
- visualize(trimEnd(some(union([inline]))))),
10
- ns => [html('p', defrag(ns))]));
9
+ visualize(some(union([inline])))),
10
+ ns => [html('p', trimNodeEnd(defrag(ns)))]));
@@ -1,11 +1,11 @@
1
1
  import { ReplyParser } from '../block';
2
- import { inits, subsequence, some, block, validate, rewrite, trimEnd, fmap } from '../../combinator';
2
+ import { inits, subsequence, some, block, validate, rewrite, fmap } from '../../combinator';
3
3
  import { cite } from './reply/cite';
4
4
  import { quote, syntax as delimiter } from './reply/quote';
5
5
  import { inline } from '../inline';
6
6
  import { anyline } from '../source';
7
- import { visualize } from '../visibility';
8
- import { push, pop } from 'spica/array';
7
+ import { visualize, trimNodeEnd } from '../visibility';
8
+ import { push } from 'spica/array';
9
9
  import { html, defrag } from 'typed-dom/dom';
10
10
 
11
11
  /*
@@ -25,8 +25,8 @@ export const reply: ReplyParser = block(validate('>', fmap(
25
25
  some(quote),
26
26
  fmap(rewrite(
27
27
  some(anyline, delimiter),
28
- visualize(trimEnd(some(inline)))),
28
+ visualize(some(inline))),
29
29
  ns => push(ns, [html('br')])),
30
30
  ])),
31
31
  ]),
32
- ns => [html('p', defrag(pop(ns)[0]))])));
32
+ ns => [html('p', trimNodeEnd(defrag(ns)))])));
@@ -4,7 +4,7 @@ import { inline } from '../../inline';
4
4
  import { indexee, identity } from './indexee';
5
5
  import { txt, str, stropt } from '../../source';
6
6
  import { Syntax, State } from '../../context';
7
- import { startTight, trimBlankEnd } from '../../visibility';
7
+ import { startTight, trimNodeEnd } from '../../visibility';
8
8
  import { html, define, defrag } from 'typed-dom/dom';
9
9
 
10
10
  import IndexParser = ExtensionParser.IndexParser;
@@ -14,13 +14,13 @@ export const index: IndexParser = lazy(() => validate('[#', fmap(indexee(surroun
14
14
  constraint(State.index, false,
15
15
  syntax(Syntax.index, 2, 1, State.linkers | State.media,
16
16
  startTight(
17
- open(stropt('|'), trimBlankEnd(some(union([
17
+ open(stropt('|'), some(union([
18
18
  signature,
19
19
  inline,
20
- ]), ']', [[/^\\?\n/, 9], [']', 2]])), true)))),
20
+ ]), ']', [[/^\\?\n/, 9], [']', 2]]), true)))),
21
21
  ']',
22
22
  false,
23
- ([, ns], rest) => [[html('a', defrag(ns))], rest])),
23
+ ([, ns], rest) => [[html('a', trimNodeEnd(defrag(ns)))], rest])),
24
24
  ([el]: [HTMLAnchorElement]) => [
25
25
  define(el,
26
26
  {
@@ -33,16 +33,16 @@ describe('Unit: parser/inline/extension/placeholder', () => {
33
33
  it('valid', () => {
34
34
  assert.deepStrictEqual(inspect(parser('[^a]')), [['<span class="invalid">a</span>'], '']);
35
35
  assert.deepStrictEqual(inspect(parser('[^a b]')), [['<span class="invalid">a b</span>'], '']);
36
- assert.deepStrictEqual(inspect(parser('[^a ]')), [['<span class="invalid">a</span>'], '']);
37
- assert.deepStrictEqual(inspect(parser('[^a ]')), [['<span class="invalid">a</span>'], '']);
38
- assert.deepStrictEqual(inspect(parser('[^a\\ ]')), [['<span class="invalid">a</span>'], '']);
39
- assert.deepStrictEqual(inspect(parser('[^a\\ \\ ]')), [['<span class="invalid">a</span>'], '']);
40
- assert.deepStrictEqual(inspect(parser('[^a\n]')), [['<span class="invalid">a</span>'], '']);
41
- assert.deepStrictEqual(inspect(parser('[^a\\\n]')), [['<span class="invalid">a</span>'], '']);
36
+ assert.deepStrictEqual(inspect(parser('[^a ]')), [['<span class="invalid">a </span>'], '']);
37
+ assert.deepStrictEqual(inspect(parser('[^a ]')), [['<span class="invalid">a </span>'], '']);
38
+ assert.deepStrictEqual(inspect(parser('[^a\\ ]')), [['<span class="invalid">a </span>'], '']);
39
+ assert.deepStrictEqual(inspect(parser('[^a\\ \\ ]')), [['<span class="invalid">a </span>'], '']);
40
+ assert.deepStrictEqual(inspect(parser('[^a\n]')), [['<span class="invalid">a<br></span>'], '']);
41
+ assert.deepStrictEqual(inspect(parser('[^a\\\n]')), [['<span class="invalid">a<br></span>'], '']);
42
42
  assert.deepStrictEqual(inspect(parser('[^a\nb]')), [['<span class="invalid">a<br>b</span>'], '']);
43
43
  assert.deepStrictEqual(inspect(parser('[^a\\\nb]')), [['<span class="invalid">a<br>b</span>'], '']);
44
- assert.deepStrictEqual(inspect(parser('[^a<wbr>]')), [['<span class="invalid">a</span>'], '']);
45
- assert.deepStrictEqual(inspect(parser('[^a<wbr><wbr>]')), [['<span class="invalid">a</span>'], '']);
44
+ assert.deepStrictEqual(inspect(parser('[^a<wbr>]')), [['<span class="invalid">a<wbr></span>'], '']);
45
+ assert.deepStrictEqual(inspect(parser('[^a<wbr><wbr>]')), [['<span class="invalid">a<wbr><wbr></span>'], '']);
46
46
  assert.deepStrictEqual(inspect(parser('[^==]')), [['<span class="invalid">==</span>'], '']);
47
47
  assert.deepStrictEqual(inspect(parser('[^a[% b %]]')), [['<span class="invalid">a<span class="comment"><input type="checkbox"><span>[% b %]</span></span></span>'], '']);
48
48
  assert.deepStrictEqual(inspect(parser('[^a[% b %][% c %]]')), [['<span class="invalid">a<span class="comment"><input type="checkbox"><span>[% b %]</span></span><span class="comment"><input type="checkbox"><span>[% c %]</span></span></span>'], '']);
@@ -3,7 +3,7 @@ import { union, some, syntax, validate, surround, lazy } from '../../../combinat
3
3
  import { inline } from '../../inline';
4
4
  import { str } from '../../source';
5
5
  import { Syntax, State } from '../../context';
6
- import { startTight, trimBlankEnd } from '../../visibility';
6
+ import { startTight } from '../../visibility';
7
7
  import { unshift } from 'spica/array';
8
8
  import { html, defrag } from 'typed-dom/dom';
9
9
 
@@ -14,7 +14,7 @@ import { html, defrag } from 'typed-dom/dom';
14
14
  export const placeholder: ExtensionParser.PlaceholderParser = lazy(() => validate('[', surround(
15
15
  str(/^\[[:^|]/),
16
16
  syntax(Syntax.placeholder, 2, 1, State.none,
17
- startTight(trimBlankEnd(some(union([inline]), ']', [[']', 2]])))),
17
+ startTight(some(union([inline]), ']', [[']', 2]]))),
18
18
  str(']'), false,
19
19
  ([, bs], rest) => [[
20
20
  html('span', {
@@ -1,7 +1,7 @@
1
1
  import { ReferenceParser } from '../inline';
2
- import { union, subsequence, some, syntax, creation, constraint, surround, open, lazy, bind } from '../../combinator';
2
+ import { union, subsequence, some, syntax, creation, constraint, surround, lazy, fmap, bind } from '../../combinator';
3
3
  import { inline } from '../inline';
4
- import { str, stropt } from '../source';
4
+ import { str } from '../source';
5
5
  import { Syntax, State } from '../context';
6
6
  import { regBlankStart, startLoose, trimNode } from '../visibility';
7
7
  import { stringify } from '../util';
@@ -14,7 +14,7 @@ export const reference: ReferenceParser = lazy(() => surround(
14
14
  startLoose(
15
15
  subsequence([
16
16
  abbr,
17
- open(stropt(/^(?=\^)/), some(inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]])),
17
+ fmap(str('^'), ns => ['', ...ns]),
18
18
  some(inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]]),
19
19
  ]), ']'))),
20
20
  ']]',
@@ -146,6 +146,7 @@ function isVisible(node: HTMLElement | string, strpos?: number): boolean {
146
146
  }
147
147
  }
148
148
 
149
+ // デフラグ前の非効率な後方トリムを避けるため必要のない限りtrimBlankStart+trimNodeEndで処理する。
149
150
  export function trimBlank<P extends Parser<HTMLElement | string>>(parser: P): P;
150
151
  export function trimBlank<T extends HTMLElement | string>(parser: Parser<T>): Parser<T> {
151
152
  return trimBlankStart(trimBlankEnd(parser));
@@ -156,8 +157,8 @@ export function trimBlankStart<T>(parser: Parser<T>): Parser<T> {
156
157
  reduce(source => source.replace(regBlankStart, '')),
157
158
  parser);
158
159
  }
159
- export function trimBlankEnd<P extends Parser<HTMLElement | string>>(parser: P): P;
160
- export function trimBlankEnd<T extends HTMLElement | string>(parser: Parser<T>): Parser<T> {
160
+ function trimBlankEnd<P extends Parser<HTMLElement | string>>(parser: P): P;
161
+ function trimBlankEnd<T extends HTMLElement | string>(parser: Parser<T>): Parser<T> {
161
162
  return fmap(
162
163
  parser,
163
164
  trimNodeEnd);
@@ -179,7 +180,7 @@ function trimNodeStart<T extends HTMLElement | string>(nodes: T[]): T[] {
179
180
  }
180
181
  return nodes;
181
182
  }
182
- function trimNodeEnd<T extends HTMLElement | string>(nodes: T[]): T[] {
183
+ export function trimNodeEnd<T extends HTMLElement | string>(nodes: T[]): T[] {
183
184
  const skip = nodes.length > 0 &&
184
185
  typeof nodes[nodes.length - 1] === 'object' &&
185
186
  nodes[nodes.length - 1]['className'] === 'indexer'
package/webpack.config.js CHANGED
@@ -81,7 +81,7 @@ module.exports = env => {
81
81
  return merge(config);
82
82
  case 'lint':
83
83
  return merge(config, {
84
- entry: glob.sync('./!(node_modules)**/*.ts'),
84
+ entry: glob.sync('./!(node_modules)/**/*.ts'),
85
85
  plugins: [
86
86
  new ESLintPlugin({
87
87
  extensions: ['ts'],