securemark 0.267.0 → 0.268.1

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.268.1
4
+
5
+ - Refactoring.
6
+
7
+ ## 0.268.0
8
+
9
+ - Add lineurl syntax.
10
+
3
11
  ## 0.267.0
4
12
 
5
13
  - Change horizontalrule syntax to pagebreak syntax.
package/README.md CHANGED
@@ -31,10 +31,6 @@ Secure markdown renderer working on browsers for user input data.
31
31
  - Audio (.oga, .ogg)
32
32
  - Images
33
33
 
34
- ## Demos
35
-
36
- https://falsandtru.github.io/securemark/
37
-
38
34
  ## APIs
39
35
 
40
36
  [index.d.ts](index.d.ts)
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.267.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.268.1 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"));
@@ -2653,7 +2653,7 @@ function block(parser, separation = true) {
2653
2653
  });
2654
2654
  if (result === undefined) return;
2655
2655
  const rest = (0, parser_1.exec)(result);
2656
- if (separation && !(0, line_1.isEmpty)((0, line_1.firstline)(rest))) return;
2656
+ if (separation && !(0, line_1.isBlank)((0, line_1.firstline)(rest))) return;
2657
2657
  return rest === '' || source[source.length - rest.length - 1] === '\n' ? result : undefined;
2658
2658
  };
2659
2659
  }
@@ -2721,7 +2721,7 @@ exports.verify = verify;
2721
2721
  Object.defineProperty(exports, "__esModule", ({
2722
2722
  value: true
2723
2723
  }));
2724
- exports.isEmpty = exports.firstline = exports.line = void 0;
2724
+ exports.isBlank = exports.firstline = exports.line = void 0;
2725
2725
  const parser_1 = __webpack_require__(6728);
2726
2726
  const memo_1 = __webpack_require__(1090);
2727
2727
  function line(parser) {
@@ -2740,7 +2740,7 @@ function line(parser) {
2740
2740
  });
2741
2741
  context.offset -= source.length - line.length;
2742
2742
  if (result === undefined) return;
2743
- return isEmpty((0, parser_1.exec)(result)) ? [(0, parser_1.eval)(result), source.slice(line.length)] : undefined;
2743
+ return isBlank((0, parser_1.exec)(result)) ? [(0, parser_1.eval)(result), source.slice(line.length)] : undefined;
2744
2744
  };
2745
2745
  }
2746
2746
  exports.line = line;
@@ -2756,10 +2756,10 @@ function firstline(source) {
2756
2756
  }
2757
2757
  }
2758
2758
  exports.firstline = firstline;
2759
- function isEmpty(line) {
2759
+ function isBlank(line) {
2760
2760
  return line === '' || line === '\n' || line.trimStart() === '';
2761
2761
  }
2762
- exports.isEmpty = isEmpty;
2762
+ exports.isBlank = isBlank;
2763
2763
 
2764
2764
  /***/ }),
2765
2765
 
@@ -2855,20 +2855,20 @@ function fence(opener, limit, separation = true) {
2855
2855
  if (matches[0].indexOf(delim, delim.length) !== -1) return;
2856
2856
  let rest = source.slice(matches[0].length);
2857
2857
  // Prevent annoying parsing in editing.
2858
- if ((0, line_1.isEmpty)((0, line_1.firstline)(rest)) && (0, line_1.firstline)(rest.slice((0, line_1.firstline)(rest).length)).trimEnd() !== delim) return;
2858
+ 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;
2859
2859
  let block = '';
2860
2860
  let closer = '';
2861
2861
  let overflow = '';
2862
2862
  for (let count = 1;; ++count) {
2863
2863
  if (rest === '') break;
2864
2864
  const line = (0, line_1.firstline)(rest);
2865
- if ((closer || count > limit + 1) && (0, line_1.isEmpty)(line)) break;
2865
+ if ((closer || count > limit + 1) && (0, line_1.isBlank)(line)) break;
2866
2866
  if (closer) {
2867
2867
  overflow += line;
2868
2868
  }
2869
2869
  if (!closer && count <= limit + 1 && line.slice(0, delim.length) === delim && line.trimEnd() === delim) {
2870
2870
  closer = line;
2871
- if ((0, line_1.isEmpty)((0, line_1.firstline)(rest.slice(line.length)))) {
2871
+ if ((0, line_1.isBlank)((0, line_1.firstline)(rest.slice(line.length)))) {
2872
2872
  rest = rest.slice(line.length);
2873
2873
  break;
2874
2874
  }
@@ -3908,7 +3908,7 @@ function bind(target, settings) {
3908
3908
  })
3909
3909
  };
3910
3910
 
3911
- if (context.id?.match(/[^0-9a-z-]/i)) throw new Error('Invalid ID: ID must be alphanumeric');
3911
+ if (context.id?.match(/[^0-9a-z/-]/i)) throw new Error('Invalid ID: ID must be alphanumeric');
3912
3912
  if (context.host?.origin === 'null') throw new Error(`Invalid host: ${context.host.href}`);
3913
3913
  const blocks = [];
3914
3914
  const adds = [];
@@ -4241,7 +4241,7 @@ function parse(source, opts = {}, context) {
4241
4241
  })
4242
4242
  };
4243
4243
 
4244
- if (context.id?.match(/[^0-9a-z-]/i)) throw new Error('Invalid ID: ID must be alphanumeric');
4244
+ if (context.id?.match(/[^0-9a-z/-]/i)) throw new Error('Invalid ID: ID must be alphanumeric');
4245
4245
  if (context.host?.origin === 'null') throw new Error(`Invalid host: ${context.host.href}`);
4246
4246
  const node = (0, dom_1.frag)();
4247
4247
  let index = 0;
@@ -4274,31 +4274,14 @@ exports.parse = parse;
4274
4274
  Object.defineProperty(exports, "__esModule", ({
4275
4275
  value: true
4276
4276
  }));
4277
- exports.autolink = void 0;
4277
+ exports.lineurl = exports.autolink = void 0;
4278
4278
  const combinator_1 = __webpack_require__(2087);
4279
+ const link_1 = __webpack_require__(9628);
4279
4280
  const autolink_1 = __webpack_require__(6051);
4280
4281
  const source_1 = __webpack_require__(6743);
4281
- const delimiter = /[@#>0-9A-Za-z\n]|\S[#>]/;
4282
- const autolink = ({
4283
- source,
4284
- context
4285
- }) => {
4286
- if (source === '') return;
4287
- const i = source.search(delimiter);
4288
- switch (i) {
4289
- case -1:
4290
- return [[source], ''];
4291
- case 0:
4292
- return parser({
4293
- source,
4294
- context
4295
- });
4296
- default:
4297
- return [[source.slice(0, i)], source.slice(i)];
4298
- }
4299
- };
4300
- exports.autolink = autolink;
4301
- const parser = (0, combinator_1.lazy)(() => (0, combinator_1.union)([autolink_1.autolink, source_1.linebreak, source_1.unescsource]));
4282
+ const util_1 = __webpack_require__(9437);
4283
+ exports.autolink = (0, combinator_1.lazy)(() => (0, combinator_1.some)((0, combinator_1.line)((0, combinator_1.subsequence)([exports.lineurl, (0, combinator_1.some)((0, combinator_1.union)([autolink_1.autolink, source_1.linebreak, source_1.unescsource]))]))));
4284
+ exports.lineurl = (0, combinator_1.lazy)(() => (0, combinator_1.focus)(/^!?https?:\/\/\S+(?=[^\S\n]*(?:$|\n))/, (0, util_1.format)((0, combinator_1.tails)([(0, source_1.str)('!'), link_1.link]))));
4302
4285
 
4303
4286
  /***/ }),
4304
4287
 
@@ -4377,7 +4360,7 @@ exports.blockquote = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, co
4377
4360
  const opener = /^(?=>>+(?:$|\s))/;
4378
4361
  const indent = (0, combinator_1.block)((0, combinator_1.open)(opener, (0, combinator_1.some)(source_1.contentline, /^>(?:$|\s)/)), false);
4379
4362
  const unindent = source => source.replace(/(?<=^|\n)>(?:[^\S\n]|(?=>*(?:$|\s)))|\n$/g, '');
4380
- 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)((0, combinator_1.some)(autolink_1.autolink), ns => [(0, dom_1.html)('pre', (0, dom_1.defrag)(ns))])))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
4363
+ 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)]));
4381
4364
  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, ({
4382
4365
  source,
4383
4366
  context
@@ -4450,7 +4433,7 @@ exports.codeblock = (0, combinator_1.block)((0, combinator_1.validate)('```', (0
4450
4433
  'data-lang': params.lang || undefined,
4451
4434
  'data-line': params.line || undefined,
4452
4435
  'data-path': params.path || undefined
4453
- }, params.lang ? context.caches?.code?.get(`${params.lang ?? ''}\n${body.slice(0, -1)}`)?.cloneNode(true).childNodes || body.slice(0, -1) || undefined : (0, dom_1.defrag)((0, parser_1.eval)((0, combinator_1.some)(autolink_1.autolink)({
4436
+ }, params.lang ? context.caches?.code?.get(`${params.lang ?? ''}\n${body.slice(0, -1)}`)?.cloneNode(true).childNodes || body.slice(0, -1) || undefined : (0, dom_1.defrag)((0, parser_1.eval)((0, autolink_1.autolink)({
4454
4437
  source: body.slice(0, -1),
4455
4438
  context
4456
4439
  }), [])));
@@ -5251,8 +5234,8 @@ const openers = {
5251
5234
  '(': /^\(([0-9]*|[a-z]*)(?![^)\n])\)?(?:-(?!-)[0-9]*)*(?:$|\s)/
5252
5235
  };
5253
5236
  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_))));
5254
- 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 => type(ms[1]).charCodeAt(0) || 0, [])), (0, combinator_1.match)(openers['('], (0, memoize_1.memoize)(ms => list(type(ms[1]), '('), ms => type(ms[1]).charCodeAt(0) || 0, []))])));
5255
- 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, 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', {
5237
+ 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 => index(ms[1]), [])), (0, combinator_1.match)(openers['('], (0, memoize_1.memoize)(ms => list(type(ms[1]), '('), ms => index(ms[1]), []))])));
5238
+ 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, 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', {
5256
5239
  'data-marker': ns[0] || undefined
5257
5240
  }, (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)]);
5258
5241
  const heads = {
@@ -5269,12 +5252,26 @@ exports.invalid = (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.co
5269
5252
  source
5270
5253
  }) => [['', (0, dom_1.html)('span', {
5271
5254
  class: 'invalid',
5272
- 'data-invalid-syntax': 'listitem',
5255
+ 'data-invalid-syntax': 'list',
5273
5256
  'data-invalid-type': 'syntax',
5274
5257
  'data-invalid-message': 'Fix the indent or the head of the list item'
5275
5258
  }, source.replace('\n', ''))], '']);
5276
- function type(index) {
5277
- switch (index) {
5259
+ function index(value) {
5260
+ switch (value) {
5261
+ case 'i':
5262
+ return 1;
5263
+ case 'a':
5264
+ return 2;
5265
+ case 'I':
5266
+ return 3;
5267
+ case 'A':
5268
+ return 4;
5269
+ default:
5270
+ return 0;
5271
+ }
5272
+ }
5273
+ function type(value) {
5274
+ switch (value) {
5278
5275
  case 'i':
5279
5276
  return 'i';
5280
5277
  case 'a':
@@ -5301,7 +5298,7 @@ function style(type) {
5301
5298
  return '';
5302
5299
  }
5303
5300
  }
5304
- function initial(type) {
5301
+ function pattern(type) {
5305
5302
  switch (type) {
5306
5303
  case 'i':
5307
5304
  return /^\(?i[).]?$/;
@@ -5315,27 +5312,38 @@ function initial(type) {
5315
5312
  return /^\(?[01][).]?$/;
5316
5313
  }
5317
5314
  }
5318
- function format(el, type, form) {
5319
- if (el.firstElementChild?.firstElementChild?.className === 'checkbox') {
5320
- el.setAttribute('class', 'checklist');
5315
+ function format(list, type, form) {
5316
+ if (list.firstElementChild?.firstElementChild?.classList.contains('checkbox')) {
5317
+ list.classList.add('checklist');
5321
5318
  }
5322
- (0, dom_1.define)(el, {
5319
+ (0, dom_1.define)(list, {
5323
5320
  type: type || undefined,
5324
5321
  'data-format': form === '.' ? undefined : 'paren',
5325
5322
  'data-type': style(type) || undefined
5326
5323
  });
5327
- const marker = el.firstElementChild?.getAttribute('data-marker').match(initial(type))?.[0] ?? '';
5328
- for (let es = el.children, len = es.length, i = 0; i < len; ++i) {
5329
- const el = es[i];
5330
- switch (el.getAttribute('data-marker')) {
5331
- case '':
5332
- case marker:
5333
- el.removeAttribute('data-marker');
5324
+ const marker = list.firstElementChild?.getAttribute('data-marker') ?? '';
5325
+ // TODO: CSSカウンターをattr(start)でリセットできるようになればstart値からのオートインクリメントに対応させる。
5326
+ const start = marker.match(pattern(type))?.[0] ?? '';
5327
+ for (let es = list.children, len = es.length, i = 0; i < len; ++i) {
5328
+ const item = es[i];
5329
+ switch (item.getAttribute('data-marker')) {
5330
+ case null:
5334
5331
  continue;
5332
+ case start:
5333
+ item.removeAttribute('data-marker');
5334
+ continue;
5335
+ case marker:
5336
+ if (i === 0 || item.classList.contains('invalid')) continue;
5337
+ (0, dom_1.define)(item, {
5338
+ class: 'invalid',
5339
+ 'data-invalid-syntax': 'list',
5340
+ 'data-invalid-type': 'index',
5341
+ 'data-invalid-message': 'Fix the duplicate index'
5342
+ });
5335
5343
  }
5336
5344
  break;
5337
5345
  }
5338
- return el;
5346
+ return list;
5339
5347
  }
5340
5348
 
5341
5349
  /***/ }),
@@ -5425,9 +5433,7 @@ exports.cite = (0, combinator_1.creation)(1, false, (0, combinator_1.line)((0, c
5425
5433
  source
5426
5434
  }) => [[(0, dom_1.html)('a', {
5427
5435
  class: 'anchor'
5428
- }, source)], '']),
5429
- // Support all domains, but don't support IP(v6) addresses.
5430
- (0, combinator_1.focus)(/^>>https?:\/\/[^\p{C}\p{S}\p{P}\s]\S*(?=\s*$)/u, ({
5436
+ }, source)], '']), (0, combinator_1.focus)(/^>>https?:\/\/(?:[[]|[^\p{C}\p{S}\p{P}\s])\S*(?=\s*$)/u, ({
5431
5437
  source
5432
5438
  }) => [[(0, dom_1.html)('a', {
5433
5439
  class: 'anchor',
@@ -5454,8 +5460,9 @@ exports.quote = exports.syntax = void 0;
5454
5460
  const parser_1 = __webpack_require__(6728);
5455
5461
  const combinator_1 = __webpack_require__(2087);
5456
5462
  const math_1 = __webpack_require__(8946);
5463
+ const autolink_1 = __webpack_require__(6051);
5457
5464
  const source_1 = __webpack_require__(6743);
5458
- const autolink_1 = __webpack_require__(7185);
5465
+ const autolink_2 = __webpack_require__(7185);
5459
5466
  const dom_1 = __webpack_require__(3252);
5460
5467
  exports.syntax = /^>+(?=[^\S\n])|^>(?=[^\s>])|^>+(?=[^\s>])(?![0-9a-z]+(?:-[0-9a-z]+)*(?![0-9A-Za-z@#:]))/;
5461
5468
  exports.quote = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(1, false, (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)('>', (0, combinator_1.union)([(0, combinator_1.rewrite)((0, combinator_1.some)((0, combinator_1.validate)(new RegExp(exports.syntax.source.split('|')[0]), source_1.anyline)), qblock), (0, combinator_1.rewrite)((0, combinator_1.validate)(new RegExp(exports.syntax.source.split('|').slice(1).join('|')), source_1.anyline), (0, combinator_1.line)((0, combinator_1.union)([(0, source_1.str)(/^.+/)])))])), ns => [(0, dom_1.html)('span', ns.length > 1 ? {
@@ -5473,8 +5480,8 @@ const qblock = ({
5473
5480
  source = source.replace(/\n$/, '');
5474
5481
  const lines = source.match(/^.*\n?/mg);
5475
5482
  const quotes = source.match(/^>+[^\S\n]/mg);
5476
- const content = lines.reduce((acc, line, row) => acc + line.slice(quotes[row].length), '');
5477
- const nodes = (0, parser_1.eval)((0, combinator_1.some)(text)({
5483
+ const content = lines.reduce((acc, line, i) => acc + line.slice(quotes[i].length), '');
5484
+ const nodes = (0, parser_1.eval)(text({
5478
5485
  source: content,
5479
5486
  context
5480
5487
  }), []);
@@ -5501,7 +5508,7 @@ const qblock = ({
5501
5508
  nodes.unshift('');
5502
5509
  return [nodes, ''];
5503
5510
  };
5504
- const text = (0, combinator_1.union)([math_1.math, autolink_1.autolink]);
5511
+ const text = (0, combinator_1.some)((0, combinator_1.line)((0, combinator_1.subsequence)([autolink_2.lineurl, (0, combinator_1.some)((0, combinator_1.union)([math_1.math, autolink_1.autolink, source_1.linebreak, source_1.unescsource]))])));
5505
5512
 
5506
5513
  /***/ }),
5507
5514
 
@@ -5527,7 +5534,7 @@ exports.sidefence = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, com
5527
5534
  })])));
5528
5535
  const opener = /^(?=\|\|+(?:$|\s))/;
5529
5536
  const unindent = source => source.replace(/(?<=^|\n)\|(?:[^\S\n]|(?=\|*(?:$|\s)))|\n$/g, '');
5530
- 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)((0, combinator_1.some)(autolink_1.autolink), ns => [(0, dom_1.html)('pre', (0, dom_1.defrag)(ns))])))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
5537
+ 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)]));
5531
5538
 
5532
5539
  /***/ }),
5533
5540
 
@@ -5595,7 +5602,7 @@ const visibility_1 = __webpack_require__(7618);
5595
5602
  const array_1 = __webpack_require__(8112);
5596
5603
  const dom_1 = __webpack_require__(3252);
5597
5604
  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_))));
5598
- 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, 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))])));
5605
+ 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, 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))])));
5599
5606
  exports.checkbox = (0, combinator_1.creation)(1, false, (0, combinator_1.focus)(/^\[[xX ]\](?=$|\s)/, ({
5600
5607
  source
5601
5608
  }) => [[(0, dom_1.html)('span', {
@@ -5605,11 +5612,11 @@ function fillFirstLine(ns) {
5605
5612
  return ns.length === 1 && typeof ns[0] === 'object' && ['UL', 'OL'].includes(ns[0].tagName) ? (0, array_1.unshift)([(0, dom_1.html)('br')], ns) : ns;
5606
5613
  }
5607
5614
  exports.fillFirstLine = fillFirstLine;
5608
- function format(el) {
5609
- if (el.firstElementChild?.firstElementChild?.className === 'checkbox') {
5610
- el.setAttribute('class', 'checklist');
5615
+ function format(list) {
5616
+ if (list.firstElementChild?.firstElementChild?.classList.contains('checkbox')) {
5617
+ list.classList.add('checklist');
5611
5618
  }
5612
- return el;
5619
+ return list;
5613
5620
  }
5614
5621
 
5615
5622
  /***/ }),
@@ -6099,7 +6106,7 @@ const indexee_1 = __webpack_require__(1269);
6099
6106
  const source_1 = __webpack_require__(6743);
6100
6107
  const visibility_1 = __webpack_require__(7618);
6101
6108
  const dom_1 = __webpack_require__(3252);
6102
- 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, {
6109
+ 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, {
6103
6110
  id: el.id ? null : undefined,
6104
6111
  class: 'index',
6105
6112
  href: el.id ? `#${el.id}` : undefined
@@ -6146,6 +6153,7 @@ function identity(id, text, name = 'index') {
6146
6153
  }
6147
6154
  exports.identity = identity;
6148
6155
  function text(source, optional = false) {
6156
+ if (!source.firstChild) return '';
6149
6157
  const indexer = source.querySelector(':scope > .indexer');
6150
6158
  const index = indexer?.getAttribute('data-index');
6151
6159
  if (index) return index;
@@ -6977,8 +6985,7 @@ function* figure(target, footnotes, opts = {}) {
6977
6985
  }
6978
6986
  labels.add(label);
6979
6987
  opts.id !== '' && def.setAttribute('id', `label:${opts.id ? `${opts.id}:` : ''}${label}`);
6980
- for (let rs = refs.take(label, Infinity), i = 0; i < rs.length; ++i) {
6981
- const ref = rs[i];
6988
+ for (const ref of refs.take(label, Infinity)) {
6982
6989
  if (ref.getAttribute('data-invalid-message') === messages.reference) {
6983
6990
  (0, dom_1.define)(ref, {
6984
6991
  class: void ref.classList.remove('invalid'),
@@ -7044,7 +7051,6 @@ Object.defineProperty(exports, "__esModule", ({
7044
7051
  }));
7045
7052
  exports.reference = exports.annotation = exports.footnote = void 0;
7046
7053
  const indexee_1 = __webpack_require__(1269);
7047
- const queue_1 = __webpack_require__(4934);
7048
7054
  const dom_1 = __webpack_require__(3252);
7049
7055
  function* footnote(target, footnotes, opts = {}, bottom = null) {
7050
7056
  for (let es = target.querySelectorAll(`.annotations`), len = es.length, i = 0; i < len; ++i) {
@@ -7058,23 +7064,35 @@ function* footnote(target, footnotes, opts = {}, bottom = null) {
7058
7064
  exports.footnote = footnote;
7059
7065
  exports.annotation = build('annotation', n => `*${n}`, 'h1, h2, h3, h4, h5, h6, aside.aside, hr');
7060
7066
  exports.reference = build('reference', (n, abbr) => `[${abbr || n}]`);
7061
- function build(syntax, marker, splitter) {
7067
+ function build(syntax, marker, splitter = '_') {
7062
7068
  // Referenceを含むAnnotationの重複排除は両構文が互いに処理済みであることを必要とするため
7063
7069
  // 構文ごとに各1回の処理では不可能
7064
7070
  return function* (target, footnote, opts = {}, bottom = null) {
7065
7071
  const defs = new Map();
7066
- const buffer = new queue_1.MultiQueue();
7067
- const titles = new Map();
7068
7072
  const splitters = [];
7069
- for (let es = target.querySelectorAll(splitter ?? '_'), len = es.length, i = 0; i < len; ++i) {
7073
+ for (let es = target.querySelectorAll(splitter), len = es.length, i = 0; i < len; ++i) {
7074
+ if (i % 100 === 0) yield;
7070
7075
  const el = es[i];
7071
7076
  el.parentNode === target && splitters.push(el);
7072
7077
  }
7078
+ const refs = target.querySelectorAll(`sup.${syntax}:not(.disabled)`);
7079
+ const titles = new Map();
7080
+ const contents = new Map();
7081
+ for (let len = refs.length, i = 0; i < len; ++i) {
7082
+ if (i % 10 === 9) yield;
7083
+ const ref = refs[i];
7084
+ const identifier = ref.getAttribute('data-abbr') || ` ${ref.firstElementChild.innerHTML}`;
7085
+ if (titles.has(identifier)) continue;
7086
+ const content = (0, dom_1.frag)(ref.firstElementChild.cloneNode(true).childNodes);
7087
+ const title = (0, indexee_1.text)(content).trim();
7088
+ if (!title) continue;
7089
+ titles.set(identifier, title);
7090
+ contents.set(identifier, content);
7091
+ }
7073
7092
  let count = 0;
7074
7093
  let total = 0;
7075
7094
  let style;
7076
- for (let refs = target.querySelectorAll(`sup.${syntax}:not(.disabled)`), len = refs.length, i = 0; i < len; ++i) {
7077
- yield;
7095
+ for (let len = refs.length, i = 0; i < len; ++i) {
7078
7096
  const ref = refs[i];
7079
7097
  while (splitters.length > 0 && splitters[0].compareDocumentPosition(ref) & Node.DOCUMENT_POSITION_FOLLOWING) {
7080
7098
  if (defs.size > 0) {
@@ -7089,7 +7107,6 @@ function build(syntax, marker, splitter) {
7089
7107
  }
7090
7108
  const identifier = ref.getAttribute('data-abbr') || ` ${ref.firstElementChild.innerHTML}`;
7091
7109
  const abbr = ref.getAttribute('data-abbr') || undefined;
7092
- const content = (0, dom_1.frag)(ref.firstElementChild.cloneNode(true).childNodes);
7093
7110
  style ??= abbr ? 'abbr' : 'count';
7094
7111
  if (style === 'count' ? abbr : !abbr) {
7095
7112
  (0, dom_1.define)(ref, {
@@ -7111,29 +7128,14 @@ function build(syntax, marker, splitter) {
7111
7128
  } else {
7112
7129
  ref.lastChild?.remove();
7113
7130
  }
7114
- const title = titles.get(identifier) || (0, indexee_1.text)(content).trim() || undefined;
7115
- title ? !titles.has(identifier) && titles.set(identifier, title) : buffer.set(identifier, ref);
7116
- const blank = !!abbr && !content.firstChild;
7131
+ const title = titles.get(identifier);
7132
+ const content = (0, dom_1.frag)(ref.firstElementChild.cloneNode(true).childNodes);
7117
7133
  const refIndex = ++count;
7118
7134
  const refId = opts.id !== '' ? `${syntax}:${opts.id ?? ''}:ref:${refIndex}` : undefined;
7119
7135
  const def = false || defs.get(identifier) || defs.set(identifier, (0, dom_1.html)('li', {
7120
7136
  id: opts.id !== '' ? `${syntax}:${opts.id ?? ''}:def:${total + defs.size + 1}` : undefined,
7121
7137
  'data-marker': !footnote ? marker(total + defs.size + 1, abbr) : undefined
7122
- }, [content.cloneNode(true), (0, dom_1.html)('sup')])).get(identifier);
7123
- if (title && !blank && def.childNodes.length === 1) {
7124
- def.insertBefore(content.cloneNode(true), def.lastChild);
7125
- for (let refs = buffer.take(identifier, Infinity), i = 0; i < refs.length; ++i) {
7126
- const ref = refs[i];
7127
- if (ref.getAttribute('data-invalid-type') !== 'content') continue;
7128
- (0, dom_1.define)(ref, {
7129
- title,
7130
- class: void ref.classList.remove('invalid'),
7131
- 'data-invalid-syntax': null,
7132
- 'data-invalid-type': null,
7133
- 'data-invalid-message': null
7134
- });
7135
- }
7136
- }
7138
+ }, [contents.get(identifier) ?? (0, dom_1.frag)(), (0, dom_1.html)('sup')])).get(identifier);
7137
7139
  const defIndex = +def.id.slice(def.id.lastIndexOf(':') + 1) || total + defs.size;
7138
7140
  const defId = def.id || undefined;
7139
7141
  (0, dom_1.define)(ref, {
@@ -7153,7 +7155,7 @@ function build(syntax, marker, splitter) {
7153
7155
  }, marker(defIndex, abbr)));
7154
7156
  def.lastChild.appendChild((0, dom_1.html)('a', {
7155
7157
  href: refId && `#${refId}`,
7156
- title: abbr && !blank ? title : undefined
7158
+ title: abbr && (0, indexee_1.text)(content).trim() || undefined
7157
7159
  }, `^${refIndex}`));
7158
7160
  }
7159
7161
  if (defs.size > 0 || footnote) {
@@ -7376,8 +7378,8 @@ Object.defineProperty(exports, "__esModule", ({
7376
7378
  exports.contentline = exports.emptyline = exports.anyline = void 0;
7377
7379
  const combinator_1 = __webpack_require__(2087);
7378
7380
  exports.anyline = (0, combinator_1.line)(() => [[], '']);
7379
- exports.emptyline = (0, combinator_1.line)(i => (0, combinator_1.isEmpty)(i.source) ? [[], ''] : undefined);
7380
- exports.contentline = (0, combinator_1.line)(i => !(0, combinator_1.isEmpty)(i.source) ? [[], ''] : undefined);
7381
+ exports.emptyline = (0, combinator_1.line)(i => (0, combinator_1.isBlank)(i.source) ? [[], ''] : undefined);
7382
+ exports.contentline = (0, combinator_1.line)(i => !(0, combinator_1.isBlank)(i.source) ? [[], ''] : undefined);
7381
7383
 
7382
7384
  /***/ }),
7383
7385
 
@@ -7414,7 +7416,7 @@ function stropt(pattern) {
7414
7416
  source
7415
7417
  }) => {
7416
7418
  if (source === '') return;
7417
- return source.slice(0, pattern.length) === pattern ? [[pattern], source.slice(pattern.length)] : undefined;
7419
+ return source.slice(0, pattern.length) === pattern ? [[pattern], source.slice(pattern.length)] : [[''], source];
7418
7420
  }) : (0, combinator_1.creation)(1, false, ({
7419
7421
  source
7420
7422
  }) => {
@@ -7529,7 +7531,7 @@ exports.unescsource = (0, combinator_1.creation)(1, false, ({
7529
7531
  /***/ }),
7530
7532
 
7531
7533
  /***/ 9437:
7532
- /***/ ((__unused_webpack_module, exports) => {
7534
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
7533
7535
 
7534
7536
  "use strict";
7535
7537
 
@@ -7537,7 +7539,12 @@ exports.unescsource = (0, combinator_1.creation)(1, false, ({
7537
7539
  Object.defineProperty(exports, "__esModule", ({
7538
7540
  value: true
7539
7541
  }));
7540
- exports.stringify = void 0;
7542
+ exports.stringify = exports.format = void 0;
7543
+ const combinator_1 = __webpack_require__(2087);
7544
+ function format(parser) {
7545
+ return (0, combinator_1.convert)(source => source.replace(/(?<=^!?)https?:\/\/(?:[[]|[^\p{C}\p{S}\p{P}\s])\S*(?=[^\S\n]*(?:$|\n))/gm, '{ $& }'), parser);
7546
+ }
7547
+ exports.format = format;
7541
7548
  function stringify(nodes) {
7542
7549
  let acc = '';
7543
7550
  for (let i = 0; i < nodes.length; ++i) {
@@ -7569,12 +7576,13 @@ const parser_1 = __webpack_require__(6728);
7569
7576
  const combinator_1 = __webpack_require__(2087);
7570
7577
  const htmlentity_1 = __webpack_require__(1562);
7571
7578
  const source_1 = __webpack_require__(6743);
7579
+ const util_1 = __webpack_require__(9437);
7572
7580
  const normalize_1 = __webpack_require__(185);
7573
7581
  const memoize_1 = __webpack_require__(1808);
7574
7582
  const array_1 = __webpack_require__(8112);
7575
7583
  function visualize(parser) {
7576
7584
  const blankline = new RegExp(/^(?:\\$|\\?[^\S\n]|&IHN;|<wbr[^\S\n]*>)+$/.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`), 'gm');
7577
- 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]))]);
7585
+ return (0, combinator_1.union)([(0, combinator_1.convert)(source => source.replace(blankline, line => line.replace(/[\\&<]/g, '\x1B$&')), (0, combinator_1.verify)((0, util_1.format)(parser), (ns, rest, context) => !rest && hasVisible(ns, context))), (0, combinator_1.some)((0, combinator_1.union)([source_1.linebreak, source_1.unescsource]))]);
7578
7586
  }
7579
7587
  exports.visualize = visualize;
7580
7588
  function hasVisible(nodes, {
@@ -8201,7 +8209,7 @@ Object.defineProperty(exports, "__esModule", ({
8201
8209
  exports.quote = void 0;
8202
8210
  const parser_1 = __webpack_require__(6728);
8203
8211
  const cite_1 = __webpack_require__(6315);
8204
- const dom_1 = __webpack_require__(3252);
8212
+ //import { url } from '../parser/inline/autolink/url';
8205
8213
  function quote(anchor, range) {
8206
8214
  if ((0, parser_1.exec)((0, cite_1.cite)({
8207
8215
  source: `>>${anchor}`,
@@ -8215,8 +8223,15 @@ function quote(anchor, range) {
8215
8223
  switch (true) {
8216
8224
  case el.matches('code'):
8217
8225
  case el.matches('.math'):
8218
- (0, dom_1.define)(el, el.getAttribute('data-src'));
8226
+ el.replaceWith(el.getAttribute('data-src'));
8219
8227
  continue;
8228
+ //case el.matches('.url'):
8229
+ // if (exec(url({ source: el.getAttribute('href')!, context: {} })) === '') continue;
8230
+ // el.replaceWith(
8231
+ // /[\s{}]/.test(el.getAttribute('href')!)
8232
+ // ? `{ ${el.getAttribute('href')} }`
8233
+ // : `{${el.getAttribute('href')}}`);
8234
+ // continue;
8220
8235
  case el.matches('.media'):
8221
8236
  el.replaceWith(/[\s{}]/.test(el.getAttribute('data-src')) ? `!{ ${el.getAttribute('data-src')} }` : `!{${el.getAttribute('data-src')}}`);
8222
8237
  continue;
@@ -8373,7 +8388,7 @@ function unlink(h) {
8373
8388
  /***/ 3252:
8374
8389
  /***/ (function(module) {
8375
8390
 
8376
- /*! typed-dom v0.0.315 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
8391
+ /*! typed-dom v0.0.316 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
8377
8392
  (function webpackUniversalModuleDefinition(root, factory) {
8378
8393
  if(true)
8379
8394
  module.exports = factory();
@@ -8704,7 +8719,7 @@ exports.defrag = defrag;
8704
8719
  /***/ 6120:
8705
8720
  /***/ (function(module) {
8706
8721
 
8707
- /*! typed-dom v0.0.315 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
8722
+ /*! typed-dom v0.0.316 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
8708
8723
  (function webpackUniversalModuleDefinition(root, factory) {
8709
8724
  if(true)
8710
8725
  module.exports = factory();
package/markdown.d.ts CHANGED
@@ -598,8 +598,13 @@ export namespace MarkdownParser {
598
598
  export interface TextParser extends
599
599
  Block<'reply/quote/text'>,
600
600
  Parser<string | HTMLElement, Context, [
601
- InlineParser.MathParser,
602
- AutolinkParser,
601
+ AutolinkParser.LineUrlParser,
602
+ Parser<string | HTMLElement, Context, [
603
+ InlineParser.MathParser,
604
+ InlineParser.AutolinkParser,
605
+ SourceParser.LinebreakParser,
606
+ SourceParser.UnescapableSourceParser,
607
+ ]>,
603
608
  ]> {
604
609
  }
605
610
  export interface PlaceholderParser extends
@@ -1171,11 +1176,23 @@ export namespace MarkdownParser {
1171
1176
  export interface AutolinkParser extends
1172
1177
  Markdown<'autolink'>,
1173
1178
  Parser<string | HTMLElement, Context, [
1174
- InlineParser.AutolinkParser,
1175
- SourceParser.LinebreakParser,
1176
- SourceParser.UnescapableSourceParser,
1179
+ AutolinkParser.LineUrlParser,
1180
+ Parser<string | HTMLElement, Context, [
1181
+ InlineParser.AutolinkParser,
1182
+ SourceParser.LinebreakParser,
1183
+ SourceParser.UnescapableSourceParser,
1184
+ ]>,
1177
1185
  ]> {
1178
1186
  }
1187
+ export namespace AutolinkParser {
1188
+ export interface LineUrlParser extends
1189
+ Markdown<'autolink/lineurl'>,
1190
+ Parser<string | HTMLElement, Context, [
1191
+ SourceParser.StrParser,
1192
+ InlineParser.LinkParser,
1193
+ ]> {
1194
+ }
1195
+ }
1179
1196
  export namespace SourceParser {
1180
1197
  interface Source<T extends string> extends Markdown<`source/${T}`> { }
1181
1198
  export interface TextParser extends