securemark 0.266.0 → 0.268.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +1 -1
  3. package/dist/index.js +75 -79
  4. package/index.d.ts +7 -8
  5. package/markdown.d.ts +26 -9
  6. package/package.json +7 -7
  7. package/src/combinator/control/constraint/block.ts +2 -2
  8. package/src/combinator/control/constraint/line.ts +2 -2
  9. package/src/combinator/control/manipulation/fence.ts +4 -4
  10. package/src/parser/api/bind.ts +1 -1
  11. package/src/parser/api/parse.test.ts +0 -2
  12. package/src/parser/api/parse.ts +1 -1
  13. package/src/parser/autolink.ts +15 -22
  14. package/src/parser/block/blockquote.ts +1 -1
  15. package/src/parser/block/codeblock.ts +2 -2
  16. package/src/parser/block/olist.test.ts +2 -2
  17. package/src/parser/block/olist.ts +2 -2
  18. package/src/parser/block/pagebreak.test.ts +31 -0
  19. package/src/parser/block/pagebreak.ts +7 -0
  20. package/src/parser/block/paragraph.test.ts +3 -0
  21. package/src/parser/block/reply/cite.ts +1 -2
  22. package/src/parser/block/reply/quote.test.ts +3 -0
  23. package/src/parser/block/reply/quote.ts +15 -9
  24. package/src/parser/block/sidefence.ts +1 -1
  25. package/src/parser/block/ulist.test.ts +2 -2
  26. package/src/parser/block/ulist.ts +2 -2
  27. package/src/parser/block.ts +3 -3
  28. package/src/parser/inline/autolink/account.ts +3 -5
  29. package/src/parser/inline/autolink/anchor.test.ts +2 -2
  30. package/src/parser/inline/autolink/anchor.ts +4 -3
  31. package/src/parser/inline/autolink/channel.test.ts +0 -2
  32. package/src/parser/inline/autolink/channel.ts +0 -1
  33. package/src/parser/inline/autolink/hashnum.test.ts +1 -1
  34. package/src/parser/inline/autolink/hashtag.test.ts +2 -6
  35. package/src/parser/inline/autolink/hashtag.ts +7 -20
  36. package/src/parser/inline/extension/index.ts +1 -1
  37. package/src/parser/inline/extension/indexee.ts +1 -0
  38. package/src/parser/inline/link.ts +1 -0
  39. package/src/parser/inline.test.ts +5 -2
  40. package/src/parser/source/line.ts +3 -3
  41. package/src/parser/source/str.ts +1 -1
  42. package/src/parser/util.ts +10 -0
  43. package/src/parser/visibility.ts +2 -1
  44. package/src/util/quote.ts +9 -2
  45. package/src/parser/block/horizontalrule.test.ts +0 -31
  46. package/src/parser/block/horizontalrule.ts +0 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.268.0
4
+
5
+ - Add lineurl syntax.
6
+
7
+ ## 0.267.0
8
+
9
+ - Change horizontalrule syntax to pagebreak syntax.
10
+
3
11
  ## 0.266.0
4
12
 
5
13
  - Change index schemas.
package/README.md CHANGED
@@ -50,7 +50,7 @@ https://falsandtru.github.io/securemark/
50
50
  - Table (| |)
51
51
  - Blockquote (>, !>)
52
52
  - Preformattedtext (```)
53
- - HorizontalRule (---)
53
+ - Pagebreak (===)
54
54
  - Inline markups (_, *, `, []{}, {}, ![]{}, !{}, \[](), ++, ~~, (()), ...)
55
55
  - Inline HTML tags (\<bdi>, \<bdo>)
56
56
  - Autolink (https://host, user@host, @user)
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.266.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.268.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
2
2
  (function webpackUniversalModuleDefinition(root, factory) {
3
3
  if(typeof exports === 'object' && typeof module === 'object')
4
4
  module.exports = factory(require("Prism"), require("DOMPurify"));
@@ -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?.includes(':')) throw new Error('ID must not contain ":"');
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 = [];
@@ -4226,7 +4226,6 @@ const url_1 = __webpack_require__(2261);
4226
4226
  const dom_1 = __webpack_require__(3252);
4227
4227
  function parse(source, opts = {}, context) {
4228
4228
  if (!(0, segment_1.validate)(source, segment_1.MAX_SEGMENT_SIZE)) throw new Error(`Too large input over ${segment_1.MAX_SEGMENT_SIZE.toLocaleString('en')} bytes`);
4229
- if (context?.id?.includes(':')) throw new Error('ID must not contain ":"');
4230
4229
  const url = (0, header_2.headers)(source).find(field => field.toLowerCase().startsWith('url:'))?.slice(4).trim() ?? '';
4231
4230
  source = !context ? (0, normalize_1.normalize)(source) : source;
4232
4231
  context = {
@@ -4242,6 +4241,7 @@ function parse(source, opts = {}, context) {
4242
4241
  })
4243
4242
  };
4244
4243
 
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
 
@@ -4314,7 +4297,7 @@ Object.defineProperty(exports, "__esModule", ({
4314
4297
  exports.block = void 0;
4315
4298
  const combinator_1 = __webpack_require__(2087);
4316
4299
  const source_1 = __webpack_require__(6743);
4317
- const horizontalrule_1 = __webpack_require__(9967);
4300
+ const pagebreak_1 = __webpack_require__(4107);
4318
4301
  const heading_1 = __webpack_require__(4623);
4319
4302
  const ulist_1 = __webpack_require__(5425);
4320
4303
  const olist_1 = __webpack_require__(7471);
@@ -4335,7 +4318,7 @@ exports.block = (0, combinator_1.creation)(1, false, error((0, combinator_1.rese
4335
4318
  clock: 50 * 1000,
4336
4319
  recursion: 20
4337
4320
  }
4338
- }, (0, combinator_1.union)([source_1.emptyline, horizontalrule_1.horizontalrule, heading_1.heading, ulist_1.ulist, olist_1.olist, ilist_1.ilist, dlist_1.dlist, table_1.table, codeblock_1.codeblock, mathblock_1.mathblock, extension_1.extension, sidefence_1.sidefence, blockquote_1.blockquote, reply_1.reply, paragraph_1.paragraph]))));
4321
+ }, (0, combinator_1.union)([source_1.emptyline, pagebreak_1.pagebreak, heading_1.heading, ulist_1.ulist, olist_1.olist, ilist_1.ilist, dlist_1.dlist, table_1.table, codeblock_1.codeblock, mathblock_1.mathblock, extension_1.extension, sidefence_1.sidefence, blockquote_1.blockquote, reply_1.reply, paragraph_1.paragraph]))));
4339
4322
  function error(parser) {
4340
4323
  return (0, combinator_1.recover)((0, combinator_1.fallback)((0, combinator_1.open)('\x07', ({
4341
4324
  source
@@ -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
  }), [])));
@@ -5168,22 +5151,6 @@ exports.heading = (0, combinator_1.block)((0, combinator_1.rewrite)(exports.segm
5168
5151
 
5169
5152
  /***/ }),
5170
5153
 
5171
- /***/ 9967:
5172
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5173
-
5174
- "use strict";
5175
-
5176
-
5177
- Object.defineProperty(exports, "__esModule", ({
5178
- value: true
5179
- }));
5180
- exports.horizontalrule = void 0;
5181
- const combinator_1 = __webpack_require__(2087);
5182
- const dom_1 = __webpack_require__(3252);
5183
- exports.horizontalrule = (0, combinator_1.block)((0, combinator_1.line)((0, combinator_1.focus)(/^-{3,}[^\S\n]*(?:$|\n)/, () => [[(0, dom_1.html)('hr')], ''])));
5184
-
5185
- /***/ }),
5186
-
5187
5154
  /***/ 238:
5188
5155
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5189
5156
 
@@ -5268,7 +5235,7 @@ const openers = {
5268
5235
  };
5269
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_))));
5270
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 => 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, []))])));
5271
- 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', {
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', {
5272
5239
  'data-marker': ns[0] || undefined
5273
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)]);
5274
5241
  const heads = {
@@ -5356,6 +5323,22 @@ function format(el, type, form) {
5356
5323
 
5357
5324
  /***/ }),
5358
5325
 
5326
+ /***/ 4107:
5327
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5328
+
5329
+ "use strict";
5330
+
5331
+
5332
+ Object.defineProperty(exports, "__esModule", ({
5333
+ value: true
5334
+ }));
5335
+ exports.pagebreak = void 0;
5336
+ const combinator_1 = __webpack_require__(2087);
5337
+ const dom_1 = __webpack_require__(3252);
5338
+ exports.pagebreak = (0, combinator_1.block)((0, combinator_1.line)((0, combinator_1.focus)(/^={3,}[^\S\n]*(?:$|\n)/, () => [[(0, dom_1.html)('hr')], ''])));
5339
+
5340
+ /***/ }),
5341
+
5359
5342
  /***/ 6457:
5360
5343
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5361
5344
 
@@ -5425,9 +5408,7 @@ exports.cite = (0, combinator_1.creation)(1, false, (0, combinator_1.line)((0, c
5425
5408
  source
5426
5409
  }) => [[(0, dom_1.html)('a', {
5427
5410
  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, ({
5411
+ }, source)], '']), (0, combinator_1.focus)(/^>>https?:\/\/(?:[[]|[^\p{C}\p{S}\p{P}\s])\S*(?=\s*$)/u, ({
5431
5412
  source
5432
5413
  }) => [[(0, dom_1.html)('a', {
5433
5414
  class: 'anchor',
@@ -5454,8 +5435,9 @@ exports.quote = exports.syntax = void 0;
5454
5435
  const parser_1 = __webpack_require__(6728);
5455
5436
  const combinator_1 = __webpack_require__(2087);
5456
5437
  const math_1 = __webpack_require__(8946);
5438
+ const autolink_1 = __webpack_require__(6051);
5457
5439
  const source_1 = __webpack_require__(6743);
5458
- const autolink_1 = __webpack_require__(7185);
5440
+ const autolink_2 = __webpack_require__(7185);
5459
5441
  const dom_1 = __webpack_require__(3252);
5460
5442
  exports.syntax = /^>+(?=[^\S\n])|^>(?=[^\s>])|^>+(?=[^\s>])(?![0-9a-z]+(?:-[0-9a-z]+)*(?![0-9A-Za-z@#:]))/;
5461
5443
  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 +5455,8 @@ const qblock = ({
5473
5455
  source = source.replace(/\n$/, '');
5474
5456
  const lines = source.match(/^.*\n?/mg);
5475
5457
  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)({
5458
+ const content = lines.reduce((acc, line, i) => acc + line.slice(quotes[i].length), '');
5459
+ const nodes = (0, parser_1.eval)(text({
5478
5460
  source: content,
5479
5461
  context
5480
5462
  }), []);
@@ -5501,7 +5483,7 @@ const qblock = ({
5501
5483
  nodes.unshift('');
5502
5484
  return [nodes, ''];
5503
5485
  };
5504
- const text = (0, combinator_1.union)([math_1.math, autolink_1.autolink]);
5486
+ 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
5487
 
5506
5488
  /***/ }),
5507
5489
 
@@ -5527,7 +5509,7 @@ exports.sidefence = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, com
5527
5509
  })])));
5528
5510
  const opener = /^(?=\|\|+(?:$|\s))/;
5529
5511
  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)]));
5512
+ 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
5513
 
5532
5514
  /***/ }),
5533
5515
 
@@ -5595,7 +5577,7 @@ const visibility_1 = __webpack_require__(7618);
5595
5577
  const array_1 = __webpack_require__(8112);
5596
5578
  const dom_1 = __webpack_require__(3252);
5597
5579
  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))])));
5580
+ 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
5581
  exports.checkbox = (0, combinator_1.creation)(1, false, (0, combinator_1.focus)(/^\[[xX ]\](?=$|\s)/, ({
5600
5582
  source
5601
5583
  }) => [[(0, dom_1.html)('span', {
@@ -5805,7 +5787,7 @@ const link_1 = __webpack_require__(9628);
5805
5787
  const source_1 = __webpack_require__(6743);
5806
5788
  const dom_1 = __webpack_require__(3252);
5807
5789
  // https://example/@user must be a user page or a redirect page going there.
5808
- exports.account = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.rewrite)((0, combinator_1.constraint)(1 /* State.shortcut */, false, (0, combinator_1.open)('@', (0, combinator_1.tails)([(0, combinator_1.verify)((0, source_1.str)(/^[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?(?:\.[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?)*\//i), ([source]) => source.length <= 253 + 1), (0, source_1.str)(/^[a-z](?:-(?=[0-9a-z])|[0-9a-z]){0,63}/i)]))), (0, combinator_1.convert)(source => `[${source}]{ ${source.includes('/') ? `https://${source.slice(1).replace('/', '/@')}` : `/${source}`} }`, (0, combinator_1.union)([link_1.unsafelink]))), ([el]) => [(0, dom_1.define)(el, {
5790
+ exports.account = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.rewrite)((0, combinator_1.constraint)(1 /* State.shortcut */, false, (0, combinator_1.open)('@', (0, combinator_1.tails)([(0, source_1.str)(/^[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?(?:\.[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?)*\//i), (0, source_1.str)(/^[a-z][0-9a-z]*(?:-[0-9a-z]+)*/i)]))), (0, combinator_1.convert)(source => `[${source}]{ ${source.includes('/') ? `https://${source.slice(1).replace('/', '/@')}` : `/${source}`} }`, (0, combinator_1.union)([link_1.unsafelink]))), ([el]) => [(0, dom_1.define)(el, {
5809
5791
  class: 'account'
5810
5792
  })]));
5811
5793
 
@@ -5826,11 +5808,12 @@ const link_1 = __webpack_require__(9628);
5826
5808
  const dom_1 = __webpack_require__(3252);
5827
5809
  // Timeline(pseudonym): user/tid
5828
5810
  // Thread(anonymous): cid
5829
- // tid: YYYY-MM-DD-HH-MM-SS-TMZ
5830
- // cid: YYYY-MM-DD-HH-MM-SS-mmm-TMZ
5811
+ // UTC
5812
+ // tid: YYYY-MMDD-HHMM-SS
5813
+ // cid: YYYY-MMDD-HHMM-SSmmm
5831
5814
  // 内部表現はUnixTimeに統一する(時系列順)
5832
5815
  // 外部表現は投稿ごとに投稿者の投稿時のタイムゾーンに統一する(非時系列順)
5833
- exports.anchor = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('>>', (0, combinator_1.fmap)((0, combinator_1.constraint)(1 /* State.shortcut */, false, (0, combinator_1.focus)(/^>>(?:[a-z][0-9a-z]*(?:-[0-9a-z]+)*\/)?[0-9a-z]+(?:-[0-9a-z]+)*(?![0-9a-z@#:])/i, (0, combinator_1.convert)(source => `[${source}]{ ${source.includes('/') ? `/@${source.slice(2).replace('/', '/timeline/')}` : `?at=${source.slice(2)}`} }`, (0, combinator_1.union)([link_1.unsafelink])))), ([el]) => [(0, dom_1.define)(el, {
5816
+ exports.anchor = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('>>', (0, combinator_1.fmap)((0, combinator_1.constraint)(1 /* State.shortcut */, false, (0, combinator_1.focus)(/^>>(?:[a-z][0-9a-z]*(?:-[0-9a-z]+)*\/)?[0-9a-z]+(?:-[0-9a-z]+)*(?![0-9a-z@#:])/i, (0, combinator_1.convert)(source => `[${source}]{ ${source.includes('/') ? `/@${source.slice(2).replace('/', '/timeline?at=')}` : `?at=${source.slice(2)}`} }`, (0, combinator_1.union)([link_1.unsafelink])))), ([el]) => [(0, dom_1.define)(el, {
5834
5817
  class: 'anchor'
5835
5818
  })])));
5836
5819
 
@@ -5854,7 +5837,6 @@ const dom_1 = __webpack_require__(3252);
5854
5837
  // https://example/@user?ch=a+b must be a user channel page or a redirect page going there.
5855
5838
  exports.channel = (0, combinator_1.validate)('@', (0, combinator_1.bind)((0, combinator_1.sequence)([account_1.account, (0, combinator_1.some)(hashtag_1.hashtag)]), (es, rest) => {
5856
5839
  const source = (0, util_1.stringify)(es);
5857
- if (source.includes('/', source.indexOf('#'))) return;
5858
5840
  const el = es[0];
5859
5841
  const url = `${el.getAttribute('href')}?ch=${source.slice(source.indexOf('#') + 1).replace(/#/g, '+')}`;
5860
5842
  return [[(0, dom_1.define)(el, {
@@ -5927,9 +5909,9 @@ const dom_1 = __webpack_require__(3252);
5927
5909
  // https://example/hashtags/a must be a hashtag page or a redirect page going there.
5928
5910
  // https://github.com/tc39/proposal-regexp-unicode-property-escapes#matching-emoji
5929
5911
  exports.emoji = String.raw`\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F`;
5930
- exports.hashtag = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.rewrite)((0, combinator_1.constraint)(1 /* State.shortcut */, false, (0, combinator_1.open)('#', (0, combinator_1.tails)([(0, combinator_1.verify)((0, source_1.str)(/^[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?(?:\.[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?)*\//i), ([source]) => source.length <= 253 + 1), (0, combinator_1.verify)((0, source_1.str)(new RegExp([/^(?=(?:[0-9]{1,127}_?)?(?:[^\d\p{C}\p{S}\p{P}\s]|emoji|'))/u.source, /(?:[^\p{C}\p{S}\p{P}\s]|emoji|(?<!')'|_(?=[^\p{C}\p{S}\p{P}\s]|emoji|')){1,128}/u.source, /(?!_?(?:[^\p{C}\p{S}\p{P}\s]|emoji|(?<!')'))/u.source].join('').replace(/emoji/g, exports.emoji), 'u')), ([source]) => source.length <= 128)]))), (0, combinator_1.convert)(source => `[${source}]{ ${source.includes('/') ? `https://${source.slice(1).replace('/', '/hashtags/')}` : `/hashtags/${source.slice(1)}`} }`, (0, combinator_1.union)([link_1.unsafelink]))), ([el]) => [(0, dom_1.define)(el, {
5912
+ exports.hashtag = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.rewrite)((0, combinator_1.constraint)(1 /* State.shortcut */, false, (0, combinator_1.open)('#', (0, source_1.str)(new RegExp([/^(?=(?:[0-9]{1,15})?(?:[^\d\p{C}\p{S}\p{P}\s]|emoji|'))/u.source, /(?:[^\p{C}\p{S}\p{P}\s]|emoji|(?<!')'|_(?=[^\p{C}\p{S}\p{P}\s]|emoji|'))+/u.source].join('').replace(/emoji/g, exports.emoji), 'u')))), (0, combinator_1.convert)(source => `[${source}]{ ${`/hashtags/${source.slice(1)}`} }`, (0, combinator_1.union)([link_1.unsafelink]))), ([el]) => [(0, dom_1.define)(el, {
5931
5913
  class: 'hashtag'
5932
- }, el.innerText)]));
5914
+ })]));
5933
5915
 
5934
5916
  /***/ }),
5935
5917
 
@@ -6099,7 +6081,7 @@ const indexee_1 = __webpack_require__(1269);
6099
6081
  const source_1 = __webpack_require__(6743);
6100
6082
  const visibility_1 = __webpack_require__(7618);
6101
6083
  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, {
6084
+ 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
6085
  id: el.id ? null : undefined,
6104
6086
  class: 'index',
6105
6087
  href: el.id ? `#${el.id}` : undefined
@@ -6489,6 +6471,7 @@ function resolve(uri, host, source) {
6489
6471
  case uri.slice(0, 2) === '^/':
6490
6472
  const last = host.pathname.slice(host.pathname.lastIndexOf('/') + 1);
6491
6473
  return last.includes('.') // isFile
6474
+ // Exclude ISO 6709.
6492
6475
  && /^[0-9]*[a-z][0-9a-z]*$/i.test(last.slice(last.lastIndexOf('.') + 1)) ? `${host.pathname.slice(0, -last.length)}${uri.slice(2)}` : `${host.pathname.replace(/\/?$/, '/')}${uri.slice(2)}`;
6493
6476
  case host.origin === source.origin && host.pathname === source.pathname:
6494
6477
  case uri.slice(0, 2) === '//':
@@ -7375,8 +7358,8 @@ Object.defineProperty(exports, "__esModule", ({
7375
7358
  exports.contentline = exports.emptyline = exports.anyline = void 0;
7376
7359
  const combinator_1 = __webpack_require__(2087);
7377
7360
  exports.anyline = (0, combinator_1.line)(() => [[], '']);
7378
- exports.emptyline = (0, combinator_1.line)(i => (0, combinator_1.isEmpty)(i.source) ? [[], ''] : undefined);
7379
- exports.contentline = (0, combinator_1.line)(i => !(0, combinator_1.isEmpty)(i.source) ? [[], ''] : undefined);
7361
+ exports.emptyline = (0, combinator_1.line)(i => (0, combinator_1.isBlank)(i.source) ? [[], ''] : undefined);
7362
+ exports.contentline = (0, combinator_1.line)(i => !(0, combinator_1.isBlank)(i.source) ? [[], ''] : undefined);
7380
7363
 
7381
7364
  /***/ }),
7382
7365
 
@@ -7413,7 +7396,7 @@ function stropt(pattern) {
7413
7396
  source
7414
7397
  }) => {
7415
7398
  if (source === '') return;
7416
- return source.slice(0, pattern.length) === pattern ? [[pattern], source.slice(pattern.length)] : undefined;
7399
+ return source.slice(0, pattern.length) === pattern ? [[pattern], source.slice(pattern.length)] : [[''], source];
7417
7400
  }) : (0, combinator_1.creation)(1, false, ({
7418
7401
  source
7419
7402
  }) => {
@@ -7528,7 +7511,7 @@ exports.unescsource = (0, combinator_1.creation)(1, false, ({
7528
7511
  /***/ }),
7529
7512
 
7530
7513
  /***/ 9437:
7531
- /***/ ((__unused_webpack_module, exports) => {
7514
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
7532
7515
 
7533
7516
  "use strict";
7534
7517
 
@@ -7536,7 +7519,12 @@ exports.unescsource = (0, combinator_1.creation)(1, false, ({
7536
7519
  Object.defineProperty(exports, "__esModule", ({
7537
7520
  value: true
7538
7521
  }));
7539
- exports.stringify = void 0;
7522
+ exports.stringify = exports.format = void 0;
7523
+ const combinator_1 = __webpack_require__(2087);
7524
+ function format(parser) {
7525
+ return (0, combinator_1.convert)(source => source.replace(/(?<=^!?)https?:\/\/(?:[[]|[^\p{C}\p{S}\p{P}\s])\S*(?=[^\S\n]*(?:$|\n))/gm, '{ $& }'), parser);
7526
+ }
7527
+ exports.format = format;
7540
7528
  function stringify(nodes) {
7541
7529
  let acc = '';
7542
7530
  for (let i = 0; i < nodes.length; ++i) {
@@ -7568,12 +7556,13 @@ const parser_1 = __webpack_require__(6728);
7568
7556
  const combinator_1 = __webpack_require__(2087);
7569
7557
  const htmlentity_1 = __webpack_require__(1562);
7570
7558
  const source_1 = __webpack_require__(6743);
7559
+ const util_1 = __webpack_require__(9437);
7571
7560
  const normalize_1 = __webpack_require__(185);
7572
7561
  const memoize_1 = __webpack_require__(1808);
7573
7562
  const array_1 = __webpack_require__(8112);
7574
7563
  function visualize(parser) {
7575
7564
  const blankline = new RegExp(/^(?:\\$|\\?[^\S\n]|&IHN;|<wbr[^\S\n]*>)+$/.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`), 'gm');
7576
- 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]))]);
7565
+ 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]))]);
7577
7566
  }
7578
7567
  exports.visualize = visualize;
7579
7568
  function hasVisible(nodes, {
@@ -8200,7 +8189,7 @@ Object.defineProperty(exports, "__esModule", ({
8200
8189
  exports.quote = void 0;
8201
8190
  const parser_1 = __webpack_require__(6728);
8202
8191
  const cite_1 = __webpack_require__(6315);
8203
- const dom_1 = __webpack_require__(3252);
8192
+ //import { url } from '../parser/inline/autolink/url';
8204
8193
  function quote(anchor, range) {
8205
8194
  if ((0, parser_1.exec)((0, cite_1.cite)({
8206
8195
  source: `>>${anchor}`,
@@ -8214,8 +8203,15 @@ function quote(anchor, range) {
8214
8203
  switch (true) {
8215
8204
  case el.matches('code'):
8216
8205
  case el.matches('.math'):
8217
- (0, dom_1.define)(el, el.getAttribute('data-src'));
8206
+ el.replaceWith(el.getAttribute('data-src'));
8218
8207
  continue;
8208
+ //case el.matches('.url'):
8209
+ // if (exec(url({ source: el.getAttribute('href')!, context: {} })) === '') continue;
8210
+ // el.replaceWith(
8211
+ // /[\s{}]/.test(el.getAttribute('href')!)
8212
+ // ? `{ ${el.getAttribute('href')} }`
8213
+ // : `{${el.getAttribute('href')}}`);
8214
+ // continue;
8219
8215
  case el.matches('.media'):
8220
8216
  el.replaceWith(/[\s{}]/.test(el.getAttribute('data-src')) ? `!{ ${el.getAttribute('data-src')} }` : `!{${el.getAttribute('data-src')}}`);
8221
8217
  continue;
package/index.d.ts CHANGED
@@ -28,8 +28,7 @@ export type ParserOptions = Omit<Partial<ParserSettings>, 'chunk'>;
28
28
  export interface ParserSettings {
29
29
  // Host URL.
30
30
  readonly host?: URL;
31
- // ID of comments and timelines.
32
- // Must not contain ":".
31
+ // Alphanumeric ID of comments and timelines.
33
32
  readonly id?: string;
34
33
  // For editing.
35
34
  readonly caches?: Partial<Caches>;
@@ -40,12 +39,12 @@ export interface ParserSettings {
40
39
  }
41
40
 
42
41
  export type Progress =
43
- | { type: 'segment', value: string; }
44
- | { type: 'block', value: HTMLElement }
45
- | { type: 'figure', value: HTMLAnchorElement }
46
- | { type: 'footnote', value: HTMLLIElement | HTMLElement }
47
- | { type: 'break' }
48
- | { type: 'cancel' };
42
+ | { readonly type: 'segment'; readonly value: string; }
43
+ | { readonly type: 'block'; readonly value: HTMLElement; }
44
+ | { readonly type: 'figure'; readonly value: HTMLAnchorElement; }
45
+ | { readonly type: 'footnote'; readonly value: HTMLLIElement | HTMLElement; }
46
+ | { readonly type: 'break'; }
47
+ | { readonly type: 'cancel'; };
49
48
 
50
49
  export interface RenderingOptions {
51
50
  readonly code?: (target: HTMLElement, cache?: Dict<string, HTMLElement>) => void;
package/markdown.d.ts CHANGED
@@ -59,7 +59,7 @@ export namespace MarkdownParser {
59
59
  Markdown<'block'>,
60
60
  Parser<HTMLElement, Context, [
61
61
  SourceParser.EmptyLineParser,
62
- BlockParser.HorizontalRuleParser,
62
+ BlockParser.PagebreakParser,
63
63
  BlockParser.HeadingParser,
64
64
  BlockParser.UListParser,
65
65
  BlockParser.OListParser,
@@ -77,9 +77,9 @@ export namespace MarkdownParser {
77
77
  }
78
78
  export namespace BlockParser {
79
79
  interface Block<T extends string> extends Markdown<`block/${T}`> { }
80
- export interface HorizontalRuleParser extends
81
- // ---
82
- Block<'horizontalrule'>,
80
+ export interface PagebreakParser extends
81
+ // ===
82
+ Block<'pagebreak'>,
83
83
  Parser<HTMLHRElement, Context, [
84
84
  SourceParser.StrParser,
85
85
  ]> {
@@ -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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securemark",
3
- "version": "0.266.0",
3
+ "version": "0.268.0",
4
4
  "description": "Secure markdown renderer working on browsers for user input data.",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/falsandtru/securemark",
@@ -34,13 +34,13 @@
34
34
  "@types/mocha": "10.0.1",
35
35
  "@types/power-assert": "1.5.8",
36
36
  "@types/prismjs": "1.26.0",
37
- "@typescript-eslint/parser": "^5.49.0",
37
+ "@typescript-eslint/parser": "^5.52.0",
38
38
  "babel-loader": "^9.1.2",
39
39
  "babel-plugin-unassert": "^3.2.0",
40
40
  "concurrently": "^7.6.0",
41
- "eslint": "^8.32.0",
42
- "eslint-plugin-redos": "^4.4.3",
43
- "eslint-webpack-plugin": "^3.2.0",
41
+ "eslint": "^8.34.0",
42
+ "eslint-plugin-redos": "^4.4.5",
43
+ "eslint-webpack-plugin": "^4.0.0",
44
44
  "glob": "^8.1.0",
45
45
  "karma": "^6.4.1",
46
46
  "karma-chrome-launcher": "^3.1.1",
@@ -49,12 +49,12 @@
49
49
  "karma-mocha": "^2.0.1",
50
50
  "karma-power-assert": "^1.0.0",
51
51
  "mocha": "^10.2.0",
52
- "npm-check-updates": "^16.6.3",
52
+ "npm-check-updates": "^16.7.4",
53
53
  "semver": "^7.3.8",
54
54
  "spica": "0.0.719",
55
55
  "ts-loader": "^9.4.2",
56
56
  "typed-dom": "^0.0.315",
57
- "typescript": "4.9.4",
57
+ "typescript": "4.9.5",
58
58
  "webpack": "^5.75.0",
59
59
  "webpack-cli": "^5.0.1",
60
60
  "webpack-merge": "^5.8.0"
@@ -1,6 +1,6 @@
1
1
  import { Parser, exec } from '../../data/parser';
2
2
  import { Memo } from '../../data/parser/context/memo';
3
- import { firstline, isEmpty } from './line';
3
+ import { firstline, isBlank } from './line';
4
4
 
5
5
  export function block<P extends Parser<unknown>>(parser: P, separation?: boolean): P;
6
6
  export function block<T>(parser: Parser<T>, separation = true): Parser<T> {
@@ -11,7 +11,7 @@ export function block<T>(parser: Parser<T>, separation = true): Parser<T> {
11
11
  const result = parser({ source, context });
12
12
  if (result === undefined) return;
13
13
  const rest = exec(result);
14
- if (separation && !isEmpty(firstline(rest))) return;
14
+ if (separation && !isBlank(firstline(rest))) return;
15
15
  assert(rest === '' || source[source.length - rest.length - 1] === '\n');
16
16
  return rest === '' || source[source.length - rest.length - 1] === '\n'
17
17
  ? result
@@ -14,7 +14,7 @@ export function line<T>(parser: Parser<T>): Parser<T> {
14
14
  assert(check(line, result));
15
15
  context.offset -= source.length - line.length;
16
16
  if (result === undefined) return;
17
- return isEmpty(exec(result))
17
+ return isBlank(exec(result))
18
18
  ? [eval(result), source.slice(line.length)]
19
19
  : undefined;
20
20
  };
@@ -32,7 +32,7 @@ export function firstline(source: string): string {
32
32
  }
33
33
  }
34
34
 
35
- export function isEmpty(line: string): boolean {
35
+ export function isBlank(line: string): boolean {
36
36
  return line === ''
37
37
  || line === '\n'
38
38
  || line.trimStart() === '';