securemark 0.277.0 → 0.279.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.279.0
4
+
5
+ - Change media syntax not to be included in inline syntax.
6
+
7
+ ## 0.278.0
8
+
9
+ - Extend account syntax.
10
+
3
11
  ## 0.277.0
4
12
 
5
13
  - Revert emphasis syntax and strong syntax.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.277.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.279.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"));
@@ -4350,6 +4350,7 @@ const mathblock_1 = __webpack_require__(3754);
4350
4350
  const extension_1 = __webpack_require__(4751);
4351
4351
  const sidefence_1 = __webpack_require__(4078);
4352
4352
  const blockquote_1 = __webpack_require__(7859);
4353
+ const mediablock_1 = __webpack_require__(785);
4353
4354
  const reply_1 = __webpack_require__(9978);
4354
4355
  const paragraph_1 = __webpack_require__(6457);
4355
4356
  const random_1 = __webpack_require__(7325);
@@ -4359,7 +4360,7 @@ exports.block = (0, combinator_1.creation)(1, false, error((0, combinator_1.rese
4359
4360
  clock: 50 * 1000,
4360
4361
  recursion: 20
4361
4362
  }
4362
- }, (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]))));
4363
+ }, (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, mediablock_1.mediablock, reply_1.reply, paragraph_1.paragraph]))));
4363
4364
  function error(parser) {
4364
4365
  return (0, combinator_1.recover)((0, combinator_1.fallback)((0, combinator_1.open)('\x07', ({
4365
4366
  source
@@ -4736,7 +4737,7 @@ const dom_1 = __webpack_require__(3252);
4736
4737
  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)([
4737
4738
  // All parsers which can include closing terms.
4738
4739
  (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, [])));
4739
- 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', {
4740
+ 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, 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', {
4740
4741
  class: 'figindex'
4741
4742
  }), (0, dom_1.html)('span', {
4742
4743
  class: 'figtext'
@@ -4857,6 +4858,7 @@ const codeblock_1 = __webpack_require__(1849);
4857
4858
  const mathblock_1 = __webpack_require__(3754);
4858
4859
  const sidefence_1 = __webpack_require__(4078);
4859
4860
  const blockquote_1 = __webpack_require__(7859);
4861
+ const mediablock_1 = __webpack_require__(785);
4860
4862
  const paragraph_1 = __webpack_require__(6457);
4861
4863
  const array_1 = __webpack_require__(8112);
4862
4864
  const dom_1 = __webpack_require__(3252);
@@ -4903,7 +4905,7 @@ function title(type) {
4903
4905
  }
4904
4906
  }
4905
4907
  // Must not have indexed blocks.
4906
- const content = (0, combinator_1.union)([source_1.emptyline, ulist_1.ulist, olist_1.olist, ilist_1.ilist, table_1.table, codeblock_1.codeblock, mathblock_1.mathblock, sidefence_1.sidefence, blockquote_1.blockquote, paragraph_1.paragraph]);
4908
+ const content = (0, combinator_1.union)([source_1.emptyline, ulist_1.ulist, olist_1.olist, ilist_1.ilist, table_1.table, codeblock_1.codeblock, mathblock_1.mathblock, sidefence_1.sidefence, blockquote_1.blockquote, mediablock_1.mediablock, paragraph_1.paragraph]);
4907
4909
 
4908
4910
  /***/ }),
4909
4911
 
@@ -4985,8 +4987,8 @@ const row = (0, combinator_1.lazy)(() => (0, combinator_1.dup)((0, combinator_1.
4985
4987
  const alignment = /^[-=<>]+(?:\/[-=^v]*)?(?=[^\S\n]*\n)/;
4986
4988
  const align = (0, combinator_1.line)((0, combinator_1.fmap)((0, combinator_1.union)([(0, source_1.str)(alignment)]), ([s]) => s.split('/').map(s => s.split(''))));
4987
4989
  const delimiter = /^[-=<>]+(?:\/[-=^v]*)?(?=[^\S\n]*\n)|^[#:](?:(?!:\D|0)\d*:(?!0)\d*)?(?:!+[+]?)?(?=\s)/;
4988
- const head = (0, combinator_1.creation)(1, false, (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)((0, source_1.str)(/^#(?:(?!:\D|0)\d*:(?!0)\d*)?(?:!+[+]?)?(?=\s)/), (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.anyline, (0, combinator_1.some)(source_1.contentline, delimiter)]), (0, combinator_1.open)(/^(?:\s*\n|\s)/, (0, visibility_1.visualize)((0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline])))), true)), true), ns => [(0, dom_1.html)('th', attributes(ns.shift()), (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))]), false));
4989
- const data = (0, combinator_1.creation)(1, false, (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)((0, source_1.str)(/^:(?:(?!:\D|0)\d*:(?!0)\d*)?(?:!+[+]?)?(?=\s)/), (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.anyline, (0, combinator_1.some)(source_1.contentline, delimiter)]), (0, combinator_1.open)(/^(?:\s*\n|\s)/, (0, visibility_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))), true)), true), ns => [(0, dom_1.html)('td', attributes(ns.shift()), (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))]), false));
4990
+ const head = (0, combinator_1.creation)(1, false, (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)((0, source_1.str)(/^#(?:(?!:\D|0)\d*:(?!0)\d*)?(?:!+[+]?)?(?=\s)/), (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.anyline, (0, combinator_1.some)(source_1.contentline, delimiter)]), (0, combinator_1.union)([(0, combinator_1.block)((0, combinator_1.surround)(/^[^\n]/, inline_1.medialink, /^\s*$/)), (0, combinator_1.block)((0, combinator_1.surround)(/^[^\n]/, inline_1.media, /^\s*$/)), (0, combinator_1.block)((0, combinator_1.surround)(/^[^\n]/, inline_1.shortmedia, /^\s*$/)), (0, combinator_1.open)(/^(?:\s*\n|\s)/, (0, visibility_1.visualize)((0, visibility_1.trimBlankStart)((0, combinator_1.some)(inline_1.inline))), true)])), true), ns => [(0, dom_1.html)('th', attributes(ns.shift()), (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))]), false));
4991
+ const data = (0, combinator_1.creation)(1, false, (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)((0, source_1.str)(/^:(?:(?!:\D|0)\d*:(?!0)\d*)?(?:!+[+]?)?(?=\s)/), (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.anyline, (0, combinator_1.some)(source_1.contentline, delimiter)]), (0, combinator_1.union)([(0, combinator_1.block)((0, combinator_1.surround)(/^[^\n]/, inline_1.medialink, /^\s*$/)), (0, combinator_1.block)((0, combinator_1.surround)(/^[^\n]/, inline_1.media, /^\s*$/)), (0, combinator_1.block)((0, combinator_1.surround)(/^[^\n]/, inline_1.shortmedia, /^\s*$/)), (0, combinator_1.open)(/^(?:\s*\n|\s)/, (0, visibility_1.visualize)((0, combinator_1.some)(inline_1.inline)), true)])), true), ns => [(0, dom_1.html)('td', attributes(ns.shift()), (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))]), false));
4990
4992
  const dataline = (0, combinator_1.creation)(1, false, (0, combinator_1.line)((0, combinator_1.rewrite)(source_1.contentline, (0, combinator_1.union)([(0, combinator_1.validate)(/^!+\s/, (0, combinator_1.convert)(source => `:${source}`, data)), (0, combinator_1.convert)(source => `: ${source}`, data)]))));
4991
4993
  function attributes(source) {
4992
4994
  let [, rowspan = undefined, colspan = undefined, highlight = undefined, extension = undefined] = source.match(/^[#:](?:(\d+)?:(\d+)?)?(?:(!+)([+]?))?$/) ?? [];
@@ -5237,8 +5239,8 @@ const ulist_1 = __webpack_require__(5425);
5237
5239
  const olist_1 = __webpack_require__(7471);
5238
5240
  const inline_1 = __webpack_require__(1160);
5239
5241
  const dom_1 = __webpack_require__(3252);
5240
- exports.ilist = (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.ilist_))));
5241
- exports.ilist_ = (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, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(/^[-+*](?:$|\s)/, (0, combinator_1.some)(inline_1.inline), true)), (0, combinator_1.indent)((0, combinator_1.union)([ulist_1.ulist_, olist_1.olist_, exports.ilist_]))]), olist_1.invalid), ns => [(0, dom_1.html)('li', (0, dom_1.defrag)((0, ulist_1.fillFirstLine)(ns)))])])))), es => [(0, dom_1.html)('ul', {
5242
+ exports.ilist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(/^[-+*](?=[^\S\n]|\n[^\S\n]*\S)/, exports.ilist_)));
5243
+ exports.ilist_ = (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, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(/^[-+*](?:$|\s)/, (0, combinator_1.some)(inline_1.inline), true)), (0, combinator_1.indent)((0, combinator_1.union)([ulist_1.ulist_, olist_1.olist_, exports.ilist_]))]), ulist_1.invalid), ns => [(0, dom_1.html)('li', (0, dom_1.defrag)((0, ulist_1.fillFirstLine)(ns)))])])))), es => [(0, dom_1.html)('ul', {
5242
5244
  class: 'invalid',
5243
5245
  'data-invalid-syntax': 'list',
5244
5246
  'data-invalid-type': 'syntax',
@@ -5281,6 +5283,31 @@ exports.mathblock = (0, combinator_1.block)((0, combinator_1.validate)('$$', (0,
5281
5283
 
5282
5284
  /***/ }),
5283
5285
 
5286
+ /***/ 785:
5287
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5288
+
5289
+ "use strict";
5290
+
5291
+
5292
+ Object.defineProperty(exports, "__esModule", ({
5293
+ value: true
5294
+ }));
5295
+ exports.mediablock = void 0;
5296
+ const combinator_1 = __webpack_require__(2087);
5297
+ const inline_1 = __webpack_require__(1160);
5298
+ const dom_1 = __webpack_require__(3252);
5299
+ exports.mediablock = (0, combinator_1.block)((0, combinator_1.validate)(['[!', '!'], (0, combinator_1.fmap)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.union)([inline_1.medialink, inline_1.media, inline_1.shortmedia])), (0, combinator_1.some)((0, combinator_1.line)((0, combinator_1.fallback)((0, combinator_1.union)([inline_1.medialink, inline_1.media, inline_1.shortmedia]), ({
5300
+ source
5301
+ }) => [[(0, dom_1.html)('div', [(0, dom_1.html)('span', attrs, source.replace('\n', ''))])], ''])))]), ns => [(0, dom_1.html)('div', ns)])));
5302
+ const attrs = {
5303
+ class: 'invalid',
5304
+ 'data-invalid-syntax': 'mediablock',
5305
+ 'data-invalid-type': 'syntax',
5306
+ 'data-invalid-message': 'Not media syntax'
5307
+ };
5308
+
5309
+ /***/ }),
5310
+
5284
5311
  /***/ 7471:
5285
5312
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5286
5313
 
@@ -5290,13 +5317,12 @@ exports.mathblock = (0, combinator_1.block)((0, combinator_1.validate)('$$', (0,
5290
5317
  Object.defineProperty(exports, "__esModule", ({
5291
5318
  value: true
5292
5319
  }));
5293
- exports.invalid = exports.olist_ = exports.olist = void 0;
5320
+ exports.olist_ = exports.olist = void 0;
5294
5321
  const combinator_1 = __webpack_require__(2087);
5295
5322
  const ulist_1 = __webpack_require__(5425);
5296
5323
  const ilist_1 = __webpack_require__(238);
5297
5324
  const inline_1 = __webpack_require__(1160);
5298
5325
  const index_1 = __webpack_require__(4479);
5299
- const source_1 = __webpack_require__(6743);
5300
5326
  const visibility_1 = __webpack_require__(7618);
5301
5327
  const memoize_1 = __webpack_require__(1808);
5302
5328
  const dom_1 = __webpack_require__(3252);
@@ -5304,12 +5330,12 @@ const openers = {
5304
5330
  '.': /^([0-9]+|[a-z]+|[A-Z]+)(?:-(?!-)[0-9]*)*(?![^\S\n])\.?(?:$|\s)/,
5305
5331
  '(': /^\(([0-9]*|[a-z]*)(?![^)\n])\)?(?:-(?!-)[0-9]*)*(?:$|\s)/
5306
5332
  };
5307
- 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_))));
5333
+ 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('|')), exports.olist_)));
5308
5334
  exports.olist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.union)([(0, combinator_1.match)(openers['.'], (0, memoize_1.memoize)(ms => list(type(ms[1]), '.'), ms => idx(ms[1]), [])), (0, combinator_1.match)(openers['('], (0, memoize_1.memoize)(ms => list(type(ms[1]), '('), ms => idx(ms[1]), []))])));
5309
5335
  const list = (type, form) => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(heads[form], (0, combinator_1.subsequence)([ulist_1.checkbox, (0, combinator_1.trim)((0, combinator_1.union)([(0, combinator_1.fmap)((0, combinator_1.close)((0, combinator_1.union)([index_1.index]), /^$/), ([el]) => [(0, dom_1.define)(el, {
5310
5336
  class: void el.classList.add('indexer'),
5311
5337
  'data-index': ''
5312
- })]), (0, visibility_1.visualize)((0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline]))))]))]), true)), (0, combinator_1.indent)((0, combinator_1.union)([ulist_1.ulist_, exports.olist_, ilist_1.ilist_]))]), exports.invalid), ns => [(0, dom_1.html)('li', {
5338
+ })]), (0, visibility_1.visualize)((0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline]))))]))]), true)), (0, combinator_1.indent)((0, combinator_1.union)([ulist_1.ulist_, exports.olist_, ilist_1.ilist_]))]), ulist_1.invalid), ns => [(0, dom_1.html)('li', {
5313
5339
  'data-marker': ns.shift() || undefined
5314
5340
  }, (0, dom_1.defrag)((0, ulist_1.fillFirstLine)(ns)))]), true)]))), es => [format((0, dom_1.html)('ol', es), type, form)]);
5315
5341
  const heads = {
@@ -5320,16 +5346,6 @@ const heads = {
5320
5346
  source
5321
5347
  }) => [[source.trimEnd().replace(/^\($/, '(1)').replace(/^\((\w+)$/, '($1)')], ''])
5322
5348
  };
5323
- exports.invalid = (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.contentline, (0, combinator_1.indent)(({
5324
- source
5325
- }) => [[source], ''])]), ({
5326
- source
5327
- }) => [['', (0, dom_1.html)('span', {
5328
- class: 'invalid',
5329
- 'data-invalid-syntax': 'list',
5330
- 'data-invalid-type': 'syntax',
5331
- 'data-invalid-message': 'Fix the indent or the head of the list item'
5332
- }, source.replace('\n', ''))], '']);
5333
5349
  function idx(value) {
5334
5350
  switch (value) {
5335
5351
  case 'i':
@@ -5638,7 +5654,7 @@ const row = (parser, optional) => (0, combinator_1.creation)(1, false, (0, combi
5638
5654
  'data-invalid-message': 'Missing the start symbol of the table row'
5639
5655
  }, [(0, dom_1.html)('td', source.replace('\n', ''))])], ''])));
5640
5656
  const align = (0, combinator_1.creation)(1, false, (0, combinator_1.fmap)((0, combinator_1.open)('|', (0, combinator_1.union)([(0, combinator_1.focus)(/^:-+:/, () => [['center'], '']), (0, combinator_1.focus)(/^:-+/, () => [['start'], '']), (0, combinator_1.focus)(/^-+:/, () => [['end'], '']), (0, combinator_1.focus)(/^-+/, () => [[''], ''])])), ns => [(0, dom_1.html)('td', (0, dom_1.defrag)(ns))]));
5641
- const cell = (0, combinator_1.surround)(/^\|\s*(?=\S)/, (0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), /^\|/, [[/^[|\\]?\s*$/, 9]])), /^[^|]*/, true);
5657
+ const cell = (0, combinator_1.surround)(/^\|\s*(?=\S)/, (0, combinator_1.trimStart)((0, combinator_1.union)([(0, combinator_1.close)(inline_1.medialink, /^\s*(?=\||$)/), (0, combinator_1.close)(inline_1.media, /^\s*(?=\||$)/), (0, combinator_1.close)(inline_1.shortmedia, /^\s*(?=\||$)/), (0, visibility_1.trimBlankStart)((0, combinator_1.some)(inline_1.inline, /^\|/, [[/^[|\\]?\s*$/, 9]]))])), /^[^|]*/, true);
5642
5658
  const head = (0, combinator_1.creation)(1, false, (0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('th', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))]));
5643
5659
  const data = (0, combinator_1.creation)(1, false, (0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('td', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))]));
5644
5660
  function format(rows) {
@@ -5666,25 +5682,36 @@ function format(rows) {
5666
5682
  Object.defineProperty(exports, "__esModule", ({
5667
5683
  value: true
5668
5684
  }));
5669
- exports.fillFirstLine = exports.checkbox = exports.ulist_ = exports.ulist = void 0;
5685
+ exports.fillFirstLine = exports.invalid = exports.checkbox = exports.ulist_ = exports.ulist = void 0;
5670
5686
  const combinator_1 = __webpack_require__(2087);
5671
5687
  const olist_1 = __webpack_require__(7471);
5672
5688
  const ilist_1 = __webpack_require__(238);
5673
5689
  const inline_1 = __webpack_require__(1160);
5674
5690
  const index_1 = __webpack_require__(4479);
5691
+ const source_1 = __webpack_require__(6743);
5675
5692
  const visibility_1 = __webpack_require__(7618);
5676
5693
  const array_1 = __webpack_require__(8112);
5677
5694
  const dom_1 = __webpack_require__(3252);
5678
- 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_))));
5695
+ exports.ulist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(/^-(?=[^\S\n]|\n[^\S\n]*\S)/, exports.ulist_)));
5679
5696
  exports.ulist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^-(?=$|\s)/, (0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(/^-(?:$|\s)/, (0, combinator_1.subsequence)([exports.checkbox, (0, combinator_1.trim)((0, combinator_1.union)([(0, combinator_1.fmap)((0, combinator_1.close)((0, combinator_1.union)([index_1.index]), /^$/), ([el]) => [(0, dom_1.define)(el, {
5680
5697
  class: void el.classList.add('indexer'),
5681
5698
  'data-index': ''
5682
- })]), (0, visibility_1.visualize)((0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline]))))]))]), true)), (0, combinator_1.indent)((0, combinator_1.union)([exports.ulist_, olist_1.olist_, ilist_1.ilist_]))]), olist_1.invalid), ns => [(0, dom_1.html)('li', (0, dom_1.defrag)(fillFirstLine(ns)))]), true)])))), es => [format((0, dom_1.html)('ul', es))])));
5699
+ })]), (0, visibility_1.visualize)((0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline]))))]))]), true)), (0, combinator_1.indent)((0, combinator_1.union)([exports.ulist_, olist_1.olist_, ilist_1.ilist_]))]), exports.invalid), ns => [(0, dom_1.html)('li', (0, dom_1.defrag)(fillFirstLine(ns)))]), true)])))), es => [format((0, dom_1.html)('ul', es))])));
5683
5700
  exports.checkbox = (0, combinator_1.creation)(1, false, (0, combinator_1.focus)(/^\[[xX ]\](?=$|\s)/, ({
5684
5701
  source
5685
5702
  }) => [[(0, dom_1.html)('span', {
5686
5703
  class: 'checkbox'
5687
5704
  }, source[1].trimStart() ? '☑' : '☐')], '']));
5705
+ exports.invalid = (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.contentline, (0, combinator_1.indent)(({
5706
+ source
5707
+ }) => [[source], ''])]), ({
5708
+ source
5709
+ }) => [['', (0, dom_1.html)('span', {
5710
+ class: 'invalid',
5711
+ 'data-invalid-syntax': 'list',
5712
+ 'data-invalid-type': 'syntax',
5713
+ 'data-invalid-message': 'Fix the indent or the head of the list item'
5714
+ }, source.replace('\n', ''))], '']);
5688
5715
  function fillFirstLine(ns) {
5689
5716
  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;
5690
5717
  }
@@ -5756,7 +5783,7 @@ const field = (0, combinator_1.line)(({
5756
5783
  Object.defineProperty(exports, "__esModule", ({
5757
5784
  value: true
5758
5785
  }));
5759
- exports.shortmedia = exports.media = exports.indexer = exports.indexee = exports.inline = void 0;
5786
+ exports.shortmedia = exports.media = exports.medialink = exports.indexer = exports.indexee = exports.inline = void 0;
5760
5787
  const combinator_1 = __webpack_require__(2087);
5761
5788
  const annotation_1 = __webpack_require__(2736);
5762
5789
  const reference_1 = __webpack_require__(3555);
@@ -5774,13 +5801,11 @@ const emstrong_1 = __webpack_require__(6132);
5774
5801
  const emphasis_1 = __webpack_require__(3867);
5775
5802
  const strong_1 = __webpack_require__(6578);
5776
5803
  const code_1 = __webpack_require__(5771);
5777
- const media_1 = __webpack_require__(1303);
5778
5804
  const htmlentity_1 = __webpack_require__(1562);
5779
- const shortmedia_1 = __webpack_require__(4189);
5780
5805
  const autolink_1 = __webpack_require__(6051);
5781
5806
  const bracket_1 = __webpack_require__(5196);
5782
5807
  const source_1 = __webpack_require__(6743);
5783
- exports.inline = (0, combinator_1.lazy)(() => (0, combinator_1.union)([annotation_1.annotation, reference_1.reference, template_1.template, remark_1.remark, math_1.math, extension_1.extension, ruby_1.ruby, link_1.textlink, link_1.linemedialink, media_1.linemedia, html_1.html, insertion_1.insertion, deletion_1.deletion, mark_1.mark, emstrong_1.emstrong, strong_1.strong, emphasis_1.emphasis, code_1.code, htmlentity_1.htmlentity, shortmedia_1.lineshortmedia, autolink_1.autolink, bracket_1.bracket, source_1.text]));
5808
+ exports.inline = (0, combinator_1.lazy)(() => (0, combinator_1.union)([annotation_1.annotation, reference_1.reference, template_1.template, remark_1.remark, math_1.math, extension_1.extension, ruby_1.ruby, link_1.textlink, html_1.html, insertion_1.insertion, deletion_1.deletion, mark_1.mark, emstrong_1.emstrong, strong_1.strong, emphasis_1.emphasis, code_1.code, htmlentity_1.htmlentity, autolink_1.autolink, bracket_1.bracket, source_1.text]));
5784
5809
  var indexee_1 = __webpack_require__(1269);
5785
5810
  Object.defineProperty(exports, "indexee", ({
5786
5811
  enumerable: true,
@@ -5795,18 +5820,25 @@ Object.defineProperty(exports, "indexer", ({
5795
5820
  return indexer_1.indexer;
5796
5821
  }
5797
5822
  }));
5798
- var media_2 = __webpack_require__(1303);
5823
+ var link_2 = __webpack_require__(9628);
5824
+ Object.defineProperty(exports, "medialink", ({
5825
+ enumerable: true,
5826
+ get: function () {
5827
+ return link_2.medialink;
5828
+ }
5829
+ }));
5830
+ var media_1 = __webpack_require__(1303);
5799
5831
  Object.defineProperty(exports, "media", ({
5800
5832
  enumerable: true,
5801
5833
  get: function () {
5802
- return media_2.media;
5834
+ return media_1.media;
5803
5835
  }
5804
5836
  }));
5805
- var shortmedia_2 = __webpack_require__(4189);
5837
+ var shortmedia_1 = __webpack_require__(4189);
5806
5838
  Object.defineProperty(exports, "shortmedia", ({
5807
5839
  enumerable: true,
5808
5840
  get: function () {
5809
- return shortmedia_2.shortmedia;
5841
+ return shortmedia_1.shortmedia;
5810
5842
  }
5811
5843
  }));
5812
5844
 
@@ -5856,7 +5888,7 @@ exports.autolink = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(/^(?:
5856
5888
  // Escape unmatched email-like strings.
5857
5889
  (0, source_1.str)(/^[0-9a-z]+(?:[_.+-][0-9a-z]+)*(?:@(?:[0-9a-z]+(?:[.-][0-9a-z]+)*)?)*/i), channel_1.channel, account_1.account,
5858
5890
  // Escape unmatched account-like strings.
5859
- (0, source_1.str)(/^@+[0-9a-z]*(?:-[0-9a-z]+)*/i),
5891
+ (0, source_1.str)(/^@+[0-9a-z]*(?:[-.][0-9a-z]+)*/i),
5860
5892
  // Escape invalid leading characters.
5861
5893
  (0, source_1.str)(new RegExp(/^(?:[^\p{C}\p{S}\p{P}\s]|emoji|['_])(?=#)/u.source.replace('emoji', hashtag_1.emoji), 'u')), hashtag_1.hashtag, hashnum_1.hashnum,
5862
5894
  // Escape unmatched hashtag-like strings.
@@ -5881,7 +5913,7 @@ const link_1 = __webpack_require__(9628);
5881
5913
  const source_1 = __webpack_require__(6743);
5882
5914
  const dom_1 = __webpack_require__(3252);
5883
5915
  // https://example/@user must be a user page or a redirect page going there.
5884
- 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, {
5916
+ 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]|-(?=[0-9a-z])){0,61}[0-9a-z])?(?:\.[0-9a-z](?:(?:[0-9a-z]|-(?=[0-9a-z])){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, {
5885
5917
  class: 'account'
5886
5918
  })]));
5887
5919
 
@@ -5955,7 +5987,7 @@ const combinator_1 = __webpack_require__(2087);
5955
5987
  const source_1 = __webpack_require__(6743);
5956
5988
  const dom_1 = __webpack_require__(3252);
5957
5989
  // https://html.spec.whatwg.org/multipage/input.html
5958
- exports.email = (0, combinator_1.creation)((0, combinator_1.rewrite)((0, combinator_1.verify)((0, source_1.str)(/^[0-9a-z](?:[_.+-](?=[0-9a-z])|[0-9a-z]){0,255}@[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?(?:\.[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?)*(?![0-9a-z])/i), ([source]) => source.length <= 255), ({
5990
+ exports.email = (0, combinator_1.creation)((0, combinator_1.rewrite)((0, combinator_1.verify)((0, source_1.str)(/^[0-9a-z](?:[_.+-](?=[0-9a-z])|[0-9a-z]){0,255}@[0-9a-z](?:(?:[0-9a-z]|-(?=[0-9a-z])){0,61}[0-9a-z])?(?:\.[0-9a-z](?:(?:[0-9a-z]|-(?=[0-9a-z])){0,61}[0-9a-z])?)*(?![0-9a-z])/i), ([source]) => source.length <= 255), ({
5959
5991
  source
5960
5992
  }) => [[(0, dom_1.html)('a', {
5961
5993
  class: 'email',
@@ -6331,10 +6363,10 @@ exports.indexer = void 0;
6331
6363
  const combinator_1 = __webpack_require__(2087);
6332
6364
  const index_1 = __webpack_require__(4479);
6333
6365
  const dom_1 = __webpack_require__(3252);
6334
- exports.indexer = (0, combinator_1.surround)(/^\s+\[(?=\|\S)/, (0, combinator_1.state)(64 /* State.index */, false, (0, combinator_1.union)([index_1.signature, (0, combinator_1.creation)((0, combinator_1.focus)(/^\|(?=\])/, () => [[(0, dom_1.html)('span', {
6366
+ exports.indexer = (0, combinator_1.surround)(/^\s+\[(?=\|\S)/, (0, combinator_1.union)([index_1.signature, (0, combinator_1.creation)((0, combinator_1.focus)(/^\|(?=\])/, () => [[(0, dom_1.html)('span', {
6335
6367
  class: 'indexer',
6336
6368
  'data-index': ''
6337
- })], '']))])), /^\]\s*$/);
6369
+ })], '']))]), /^\]\s*$/);
6338
6370
 
6339
6371
  /***/ }),
6340
6372
 
@@ -6631,10 +6663,10 @@ function resolve(uri, host, source) {
6631
6663
  exports.resolve = resolve;
6632
6664
  function decode(uri) {
6633
6665
  if (!uri.includes('%')) return uri;
6634
- const origin = uri.match(/^[a-z](?:[-.](?=\w)|[0-9a-z])*:(?:\/{0,2}[^/?#\s]+|\/\/(?=[/]))/i)?.[0] ?? '';
6666
+ const origin = uri.match(/^[a-z](?:[-.](?=[0-9a-z])|[0-9a-z])*:(?:\/{0,2}[^/?#\s]+|\/\/(?=[/]))/i)?.[0] ?? '';
6635
6667
  try {
6636
6668
  let path = decodeURI(uri.slice(origin.length));
6637
- if (!origin && /^[a-z](?:[-.](?=\w)|[0-9a-z])*:\/{0,2}\S/i.test(path)) {
6669
+ if (!origin && /^[a-z](?:[-.](?=[0-9a-z])|[0-9a-z])*:\/{0,2}\S/i.test(path)) {
6638
6670
  path = uri.slice(origin.length);
6639
6671
  }
6640
6672
  uri = origin + path;
@@ -7036,13 +7068,14 @@ function* figure(target, notes, opts = {}) {
7036
7068
  const refs = new queue_1.MultiQueue((0, array_1.push)((0, query_1.querySelectorAll)(target, 'a.label:not(.disabled)[data-label]'), notes && (0, query_1.querySelectorAll)(notes.references, 'a.label:not(.disabled)') || []).map(el => [el.getAttribute('data-label'), el]));
7037
7069
  const labels = new Set();
7038
7070
  const numbers = new Map();
7071
+ const scope = target instanceof Element ? ':scope > ' : '';
7039
7072
  let base = '0';
7040
7073
  let bases = base.split('.');
7041
7074
  let index = bases;
7042
- for (let defs = target.querySelectorAll('figure[data-label], h1, h2'), len = defs.length, i = 0; i < len; ++i) {
7075
+ for (let defs = target.querySelectorAll(`${scope}:is(figure[data-label], h1, h2)`), len = defs.length, i = 0; i < len; ++i) {
7043
7076
  yield;
7044
7077
  const def = defs[i];
7045
- if (def.parentNode !== target) continue;
7078
+ if (!scope && def.parentNode !== target) continue;
7046
7079
  const {
7047
7080
  tagName
7048
7081
  } = def;
@@ -7199,7 +7232,8 @@ function build(syntax, marker, splitter = '') {
7199
7232
  const defIndexes = new Map();
7200
7233
  const refSubindexes = new Map();
7201
7234
  const defSubindexes = new Map();
7202
- const splitters = splitter ? target.querySelectorAll(splitter) : [];
7235
+ const scope = target instanceof Element ? ':scope > ' : '';
7236
+ const splitters = splitter ? target.querySelectorAll(`${scope}:is(${splitter})`) : [];
7203
7237
  let iSplitters = 0;
7204
7238
  let total = 0;
7205
7239
  let format;
@@ -7212,7 +7246,7 @@ function build(syntax, marker, splitter = '') {
7212
7246
  }
7213
7247
  if (splitter) for (let el; el = splitters[iSplitters], el?.compareDocumentPosition(ref) & Node.DOCUMENT_POSITION_FOLLOWING; ++iSplitters) {
7214
7248
  if (~iSplitters << 32 - 8 === 0) yield;
7215
- if (el.parentNode !== target) continue;
7249
+ if (!scope && el.parentNode !== target) continue;
7216
7250
  if (el.tagName === 'OL' && el.nextElementSibling !== splitters[iSplitters + 1]) {
7217
7251
  el.remove();
7218
7252
  continue;
@@ -7284,7 +7318,7 @@ function build(syntax, marker, splitter = '') {
7284
7318
  }
7285
7319
  if (splitter) for (let el; el = splitters[iSplitters]; ++iSplitters) {
7286
7320
  if (~iSplitters << 32 - 8 === 0) yield;
7287
- if (el.parentNode !== target) continue;
7321
+ if (!scope && el.parentNode !== target) continue;
7288
7322
  if (el.tagName === 'OL') {
7289
7323
  el.remove();
7290
7324
  }
@@ -7737,21 +7771,21 @@ var blank;
7737
7771
  blank.start = new RegExp(/^(?:\\?[^\S\n]|&IHN;|<wbr[^\S\n]*>)+/.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`));
7738
7772
  })(blank || (exports.blank = blank = {}));
7739
7773
  function visualize(parser) {
7740
- return (0, combinator_1.union)([(0, combinator_1.convert)(source => source.replace(blank.line, line => line.replace(/[\\&<]/g, '\x1B$&')), (0, combinator_1.verify)(parser, (ns, rest, context) => !rest && hasVisible(ns, context))), (0, combinator_1.some)((0, combinator_1.union)([source_1.linebreak, source_1.unescsource]))]);
7774
+ return (0, combinator_1.union)([(0, combinator_1.convert)(source => source.replace(blank.line, line => line.replace(/[\\&<]/g, '\x1B$&')), (0, combinator_1.verify)(parser, (ns, rest) => !rest && hasVisible(ns))), (0, combinator_1.some)((0, combinator_1.union)([source_1.linebreak, source_1.unescsource]))]);
7741
7775
  }
7742
7776
  exports.visualize = visualize;
7743
- function hasVisible(nodes, {
7744
- state = 0
7745
- } = {}) {
7777
+ function hasVisible(nodes) {
7746
7778
  for (let i = 0; i < nodes.length; ++i) {
7747
7779
  const node = nodes[i];
7748
7780
  if (typeof node === 'string') {
7749
7781
  if (node && node.trimStart()) return true;
7750
7782
  } else {
7751
7783
  if (node.innerText.trimStart()) return true;
7752
- if (state & 8 /* State.media */ ^ 8 /* State.media */ && (node.classList.contains('media') || node.getElementsByClassName('media')[0])) return true;
7784
+ //if (state & State.media ^ State.media &&
7785
+ // (node.classList.contains('media') || node.getElementsByClassName('media')[0])) return true;
7753
7786
  }
7754
7787
  }
7788
+
7755
7789
  return false;
7756
7790
  }
7757
7791
  function blankWith(starting, delimiter) {
@@ -8096,7 +8130,7 @@ function image(source, url, cache) {
8096
8130
  src: source.getAttribute('data-src'),
8097
8131
  loading: 'lazy'
8098
8132
  });
8099
- cache?.set(url.href, (0, dom_1.define)(source.cloneNode(true), Object.fromEntries([...source.attributes].filter(attr => !['class', 'data-type', 'data-src', 'src', 'loading'].includes(attr.name)).map(attr => [attr.name, null]))));
8133
+ cache?.set(url.href, (0, dom_1.define)(source.cloneNode(true), Object.fromEntries([...source.attributes].filter(attr => !['class', 'data-type', 'data-src', 'src', 'loading'].includes(attr.name)).map(attr => [attr.name, attr.name === 'alt' ? '' : null]))));
8100
8134
  return source;
8101
8135
  }
8102
8136
  exports.image = image;
@@ -8155,7 +8189,7 @@ const origins = ['https://twitter.com'];
8155
8189
  function twitter(source, url) {
8156
8190
  if (!origins.includes(url.origin)) return;
8157
8191
  if (url.pathname.split('/').pop().includes('.')) return;
8158
- if (!url.pathname.match(/^\/\w+\/status\/[0-9]{15,}(?!\w)/)) return;
8192
+ if (!url.pathname.match(/^\/\w+\/status\/[0-9]{15,}\/?$/)) return;
8159
8193
  const el = (0, dom_1.html)('div', {
8160
8194
  class: source.className,
8161
8195
  'data-type': 'twitter'
@@ -8526,7 +8560,7 @@ function unlink(h) {
8526
8560
  /***/ 3252:
8527
8561
  /***/ (function(module) {
8528
8562
 
8529
- /*! typed-dom v0.0.335 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
8563
+ /*! typed-dom v0.0.336 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
8530
8564
  (function webpackUniversalModuleDefinition(root, factory) {
8531
8565
  if(true)
8532
8566
  module.exports = factory();
@@ -8862,7 +8896,7 @@ exports.defrag = defrag;
8862
8896
  /***/ 6120:
8863
8897
  /***/ (function(module) {
8864
8898
 
8865
- /*! typed-dom v0.0.335 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
8899
+ /*! typed-dom v0.0.336 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
8866
8900
  (function webpackUniversalModuleDefinition(root, factory) {
8867
8901
  if(true)
8868
8902
  module.exports = factory();
package/markdown.d.ts CHANGED
@@ -71,6 +71,7 @@ export namespace MarkdownParser {
71
71
  BlockParser.ExtensionParser,
72
72
  BlockParser.SidefenceParser,
73
73
  BlockParser.BlockquoteParser,
74
+ BlockParser.MediaBlockParser,
74
75
  BlockParser.ReplyParser,
75
76
  BlockParser.ParagraphParser,
76
77
  ]> {
@@ -270,12 +271,18 @@ export namespace MarkdownParser {
270
271
  export interface HeadParser extends
271
272
  Block<'table/cell/head'>,
272
273
  Parser<HTMLTableCellElement, Context, [
274
+ InlineParser.LinkParser.MediaLinkParser,
275
+ InlineParser.MediaParser,
276
+ InlineParser.ShortMediaParser,
273
277
  InlineParser,
274
278
  ]> {
275
279
  }
276
280
  export interface DataParser extends
277
281
  Block<'table/cell/data'>,
278
282
  Parser<HTMLTableCellElement, Context, [
283
+ InlineParser.LinkParser.MediaLinkParser,
284
+ InlineParser.MediaParser,
285
+ InlineParser.ShortMediaParser,
279
286
  InlineParser,
280
287
  ]> {
281
288
  }
@@ -457,12 +464,18 @@ export namespace MarkdownParser {
457
464
  export interface HeadParser extends
458
465
  Block<'extension/table/cell/head'>,
459
466
  Parser<HTMLTableCellElement, Context, [
467
+ InlineParser.LinkParser.MediaLinkParser,
468
+ InlineParser.MediaParser,
469
+ InlineParser.ShortMediaParser,
460
470
  InlineParser,
461
471
  ]> {
462
472
  }
463
473
  export interface DataParser extends
464
474
  Block<'extension/table/cell/data'>,
465
475
  Parser<HTMLTableCellElement, Context, [
476
+ InlineParser.LinkParser.MediaLinkParser,
477
+ InlineParser.MediaParser,
478
+ InlineParser.ShortMediaParser,
466
479
  InlineParser,
467
480
  ]> {
468
481
  }
@@ -497,6 +510,7 @@ export namespace MarkdownParser {
497
510
  BlockParser.MathBlockParser,
498
511
  BlockParser.SidefenceParser,
499
512
  BlockParser.BlockquoteParser,
513
+ BlockParser.MediaBlockParser,
500
514
  BlockParser.ParagraphParser,
501
515
  ]> {
502
516
  }
@@ -562,6 +576,22 @@ export namespace MarkdownParser {
562
576
  ]> {
563
577
  }
564
578
  }
579
+ export interface MediaBlockParser extends
580
+ // abc
581
+ Block<'mediablock'>,
582
+ Parser<HTMLDivElement, Context, [
583
+ Parser<HTMLElement, Context, [
584
+ InlineParser.LinkParser.MediaLinkParser,
585
+ InlineParser.MediaParser,
586
+ InlineParser.ShortMediaParser,
587
+ ]>,
588
+ Parser<HTMLElement, Context, [
589
+ InlineParser.LinkParser.MediaLinkParser,
590
+ InlineParser.MediaParser,
591
+ InlineParser.ShortMediaParser,
592
+ ]>,
593
+ ]> {
594
+ }
565
595
  export interface ReplyParser extends
566
596
  // >>1
567
597
  // > text
@@ -641,8 +671,6 @@ export namespace MarkdownParser {
641
671
  InlineParser.ExtensionParser,
642
672
  InlineParser.RubyParser,
643
673
  InlineParser.LinkParser.TextLinkParser,
644
- InlineParser.LinkParser.LineMediaLinkParser,
645
- InlineParser.MediaParser.LineMediaParser,
646
674
  InlineParser.HTMLParser,
647
675
  InlineParser.InsertionParser,
648
676
  InlineParser.DeletionParser,
@@ -652,7 +680,6 @@ export namespace MarkdownParser {
652
680
  InlineParser.EmphasisParser,
653
681
  InlineParser.CodeParser,
654
682
  InlineParser.HTMLEntityParser,
655
- InlineParser.ShortMediaParser.LineShortMediaParser,
656
683
  InlineParser.AutolinkParser,
657
684
  InlineParser.BracketParser,
658
685
  SourceParser.TextParser,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securemark",
3
- "version": "0.277.0",
3
+ "version": "0.279.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,14 +34,14 @@
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.59.8",
37
+ "@typescript-eslint/parser": "^5.59.9",
38
38
  "babel-loader": "^9.1.2",
39
39
  "babel-plugin-unassert": "^3.2.0",
40
40
  "concurrently": "^8.1.0",
41
41
  "eslint": "^8.42.0",
42
42
  "eslint-plugin-redos": "^4.4.5",
43
43
  "eslint-webpack-plugin": "^4.0.1",
44
- "glob": "^10.2.6",
44
+ "glob": "^10.2.7",
45
45
  "karma": "^6.4.2",
46
46
  "karma-chrome-launcher": "^3.2.0",
47
47
  "karma-coverage": "^2.2.0",
@@ -51,11 +51,11 @@
51
51
  "mocha": "^10.2.0",
52
52
  "npm-check-updates": "^16.10.12",
53
53
  "semver": "^7.5.1",
54
- "spica": "0.0.731",
54
+ "spica": "0.0.732",
55
55
  "ts-loader": "^9.4.3",
56
- "typed-dom": "0.0.335",
56
+ "typed-dom": "0.0.336",
57
57
  "typescript": "5.1.3",
58
- "webpack": "^5.85.0",
58
+ "webpack": "^5.85.1",
59
59
  "webpack-cli": "^5.1.3",
60
60
  "webpack-merge": "^5.9.0"
61
61
  },
@@ -132,9 +132,9 @@ describe('Unit: parser/api/parse', () => {
132
132
  '<p><a class="url" href="https://source/a" target="_blank">../a</a></p>',
133
133
  '<p><a class="url" href="https://source/a" target="_blank">../../a</a></p>',
134
134
  '<p><a class="url" href="//domain/a" target="_blank">//domain/a</a></p>',
135
- '<p><a href="https://source/x/a" target="_blank"><img class="media" data-src="https://source/x/a" alt=""></a></p>',
136
- '<p><a href="/z/a" target="_blank"><img class="media" data-src="/z/a" alt=""></a></p>',
137
- '<p><a href="https://source/a" target="_blank"><img class="media" data-src="https://source/a" alt=""></a></p>',
135
+ '<div><a href="https://source/x/a" target="_blank"><img class="media" data-src="https://source/x/a" alt=""></a></div>',
136
+ '<div><a href="/z/a" target="_blank"><img class="media" data-src="/z/a" alt=""></a></div>',
137
+ '<div><a href="https://source/a" target="_blank"><img class="media" data-src="https://source/a" alt=""></a></div>',
138
138
  '<ol class="annotations"><li id="annotation::def:a:1" data-marker="*1"><span>a</span><sup><a href="#annotation::ref:a:1">^1</a></sup></li></ol>',
139
139
  ]);
140
140
  assert.deepStrictEqual(
@@ -1,5 +1,5 @@
1
1
  import { ExtensionParser } from '../../block';
2
- import { union, inits, sequence, some, state, block, line, fence, rewrite, close, match, convert, fallback, fmap } from '../../../combinator';
2
+ import { union, inits, sequence, some, 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';
@@ -12,7 +12,6 @@ import { table, segment_ as seg_table } from './table';
12
12
  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
- import { State } from '../../context';
16
15
  import { visualize, trimBlankStart, trimNodeEnd } from '../../visibility';
17
16
  import { memoize } from 'spica/memoize';
18
17
  import { html, defrag } from 'typed-dom/dom';
@@ -64,9 +63,7 @@ export const figure: FigureParser = block(fallback(rewrite(segment, fmap(
64
63
  line(shortmedia),
65
64
  ])),
66
65
  emptyline,
67
- block(
68
- state(State.media,
69
- visualize(trimBlankStart(some(inline))))),
66
+ block(visualize(trimBlankStart(some(inline)))),
70
67
  ]),
71
68
  ])),
72
69
  ([label, param, content, ...caption]: [HTMLAnchorElement, string, ...HTMLElement[]]) => [
@@ -11,6 +11,7 @@ import { codeblock } from '../codeblock';
11
11
  import { mathblock } from '../mathblock';
12
12
  import { sidefence } from '../sidefence';
13
13
  import { blockquote } from '../blockquote';
14
+ import { mediablock } from '../mediablock';
14
15
  import { paragraph } from '../paragraph';
15
16
  import { unshift, push } from 'spica/array';
16
17
  import { html } from 'typed-dom/dom';
@@ -74,5 +75,6 @@ const content: MessageParser.ContentParser = union([
74
75
  mathblock,
75
76
  sidefence,
76
77
  blockquote,
78
+ mediablock,
77
79
  paragraph,
78
80
  ]);
@@ -1,8 +1,8 @@
1
1
  import { max, min, isArray } from 'spica/alias';
2
2
  import { ExtensionParser } from '../../block';
3
3
  import { Tree, eval } from '../../../combinator/data/parser';
4
- import { union, subsequence, inits, some, creation, block, line, validate, fence, rewrite, open, clear, convert, dup, lazy, fmap } from '../../../combinator';
5
- import { inline } from '../../inline';
4
+ import { union, subsequence, inits, some, creation, block, line, validate, fence, rewrite, surround, open, clear, convert, dup, lazy, fmap } from '../../../combinator';
5
+ import { inline, medialink, media, shortmedia } from '../../inline';
6
6
  import { str, anyline, emptyline, contentline } from '../../source';
7
7
  import { visualize, trimBlankStart, trimNodeEnd } from '../../visibility';
8
8
  import { unshift, splice } from 'spica/array';
@@ -84,7 +84,12 @@ const head: CellParser.HeadParser = creation(1, false, block(fmap(open(
84
84
  anyline,
85
85
  some(contentline, delimiter),
86
86
  ]),
87
- open(/^(?:\s*\n|\s)/, visualize(trimBlankStart(some(union([inline])))), true)),
87
+ union([
88
+ block(surround(/^[^\n]/, medialink, /^\s*$/)),
89
+ block(surround(/^[^\n]/, media, /^\s*$/)),
90
+ block(surround(/^[^\n]/, shortmedia, /^\s*$/)),
91
+ open(/^(?:\s*\n|\s)/, visualize(trimBlankStart(some(inline))), true),
92
+ ])),
88
93
  true),
89
94
  ns => [html('th', attributes(ns.shift()! as string), trimNodeEnd(defrag(ns)))]),
90
95
  false));
@@ -96,7 +101,12 @@ const data: CellParser.DataParser = creation(1, false, block(fmap(open(
96
101
  anyline,
97
102
  some(contentline, delimiter),
98
103
  ]),
99
- open(/^(?:\s*\n|\s)/, visualize(some(union([inline]))), true)),
104
+ union([
105
+ block(surround(/^[^\n]/, medialink, /^\s*$/)),
106
+ block(surround(/^[^\n]/, media, /^\s*$/)),
107
+ block(surround(/^[^\n]/, shortmedia, /^\s*$/)),
108
+ open(/^(?:\s*\n|\s)/, visualize(some(inline)), true),
109
+ ])),
100
110
  true),
101
111
  ns => [html('td', attributes(ns.shift()! as string), trimNodeEnd(defrag(ns)))]),
102
112
  false));
@@ -1,15 +1,13 @@
1
1
  import { IListParser } from '../block';
2
- import { union, inits, some, creation, state, block, line, validate, indent, open, fallback, lazy, fmap } from '../../combinator';
3
- import { ulist_, fillFirstLine } from './ulist';
4
- import { olist_, invalid } from './olist';
2
+ import { union, inits, some, creation, block, line, validate, indent, open, fallback, lazy, fmap } from '../../combinator';
3
+ import { ulist_, invalid, fillFirstLine } from './ulist';
4
+ import { olist_ } from './olist';
5
5
  import { inline } from '../inline';
6
- import { State } from '../context';
7
6
  import { html, defrag } from 'typed-dom/dom';
8
7
 
9
8
  export const ilist: IListParser = lazy(() => block(validate(
10
9
  /^[-+*](?=[^\S\n]|\n[^\S\n]*\S)/,
11
- state(State.media,
12
- ilist_))));
10
+ ilist_)));
13
11
 
14
12
  export const ilist_: IListParser = lazy(() => block(fmap(validate(
15
13
  /^[-+*](?:$|\s)/,
@@ -0,0 +1,26 @@
1
+ import { MediaBlockParser } from '../block';
2
+ import { union, inits, some, block, line, validate, fallback, fmap } from '../../combinator';
3
+ import { medialink, media, shortmedia } from '../inline';
4
+ import { html } from 'typed-dom/dom';
5
+
6
+ export const mediablock: MediaBlockParser = block(validate(['[!', '!'], fmap(
7
+ inits([
8
+ line(union([
9
+ medialink,
10
+ media,
11
+ shortmedia,
12
+ ])),
13
+ some(line(fallback(union([
14
+ medialink,
15
+ media,
16
+ shortmedia,
17
+ ]), ({ source }) => [[html('div', [html('span', attrs, source.replace('\n', ''))])], '']))),
18
+ ]),
19
+ ns => [html('div', ns)])));
20
+
21
+ const attrs = {
22
+ class: 'invalid',
23
+ 'data-invalid-syntax': 'mediablock',
24
+ 'data-invalid-type': 'syntax',
25
+ 'data-invalid-message': 'Not media syntax',
26
+ } as const;
@@ -1,12 +1,9 @@
1
1
  import { OListParser } from '../block';
2
- import { Parser } from '../../combinator/data/parser';
3
- import { union, inits, subsequence, some, creation, state, block, line, validate, indent, focus, rewrite, open, close, match, trim, fallback, lazy, fmap } from '../../combinator';
4
- import { checkbox, ulist_, fillFirstLine } from './ulist';
2
+ import { union, inits, subsequence, some, creation, block, line, validate, indent, focus, open, close, match, trim, fallback, lazy, fmap } from '../../combinator';
3
+ import { ulist_, checkbox, invalid, fillFirstLine } from './ulist';
5
4
  import { ilist_ } from './ilist';
6
5
  import { inline, indexee, indexer } from '../inline';
7
6
  import { index } from '../inline/extension/index';
8
- import { contentline } from '../source';
9
- import { State } from '../context';
10
7
  import { visualize, trimBlank } from '../visibility';
11
8
  import { memoize } from 'spica/memoize';
12
9
  import { html, define, defrag } from 'typed-dom/dom';
@@ -21,8 +18,7 @@ export const olist: OListParser = lazy(() => block(validate(
21
18
  /^([0-9]+|[a-z]+|[A-Z]+)(?:-[0-9]+)*\.(?=[^\S\n]|\n[^\S\n]*\S)/.source,
22
19
  /^\(([0-9]+|[a-z]+)\)(?:-[0-9]+)*(?=[^\S\n]|\n[^\S\n]*\S)/.source,
23
20
  ].join('|')),
24
- state(State.media,
25
- olist_))));
21
+ olist_)));
26
22
 
27
23
  export const olist_: OListParser = lazy(() => block(union([
28
24
  match(
@@ -59,18 +55,6 @@ const heads = {
59
55
  ({ source }) => [[source.trimEnd().replace(/^\($/, '(1)').replace(/^\((\w+)$/, '($1)')], '']),
60
56
  } as const;
61
57
 
62
- export const invalid = rewrite(
63
- inits([contentline, indent<Parser<string>>(({ source }) => [[source], ''])]),
64
- ({ source }) => [[
65
- '',
66
- html('span', {
67
- class: 'invalid',
68
- 'data-invalid-syntax': 'list',
69
- 'data-invalid-type': 'syntax',
70
- 'data-invalid-message': 'Fix the indent or the head of the list item',
71
- }, source.replace('\n', ''))
72
- ], '']);
73
-
74
58
  function idx(value: string): number {
75
59
  switch (value) {
76
60
  case 'i':
@@ -35,9 +35,9 @@ describe('Unit: parser/block/paragraph', () => {
35
35
  assert.deepStrictEqual(inspect(parser('==a\n<wbr>==\nb')), [['<p>==a<br><wbr>==<br>b</p>'], '']);
36
36
  assert.deepStrictEqual(inspect(parser('http://host#\\')), [['<p><a class="url" href="http://host#\\" target="_blank">http://host#\\</a></p>'], '']);
37
37
  assert.deepStrictEqual(inspect(parser('a\nhttp://host#\\ \nb')), [['<p>a<br><a class="url" href="http://host#\\" target="_blank">http://host#\\</a><br>b</p>'], '']);
38
- assert.deepStrictEqual(inspect(parser('!http://host#\\')), [['<p><a href="http://host#\\" target="_blank"><img class="media" data-src="http://host#\\" alt=""></a></p>'], '']);
39
- assert.deepStrictEqual(inspect(parser('!http://host#\\ a')), [['<p>!<a class="url" href="http://host#" target="_blank">http://host#</a> a</p>'], '']);
40
- assert.deepStrictEqual(inspect(parser(' !http://host#\\')), [['<p> !<a class="url" href="http://host#" target="_blank">http://host#</a></p>'], '']);
38
+ //assert.deepStrictEqual(inspect(parser('!http://host#\\')), [['<p><a href="http://host#\\" target="_blank"><img class="media" data-src="http://host#\\" alt=""></a></p>'], '']);
39
+ //assert.deepStrictEqual(inspect(parser('!http://host#\\ a')), [['<p>!<a class="url" href="http://host#" target="_blank">http://host#</a> a</p>'], '']);
40
+ //assert.deepStrictEqual(inspect(parser(' !http://host#\\')), [['<p> !<a class="url" href="http://host#" target="_blank">http://host#</a></p>'], '']);
41
41
  assert.deepStrictEqual(inspect(parser('\ta')), [['<p>\ta</p>'], '']);
42
42
  });
43
43
 
@@ -1,6 +1,6 @@
1
1
  import { TableParser } from '../block';
2
- import { union, sequence, some, creation, block, line, validate, focus, rewrite, surround, open, fallback, lazy, fmap } from '../../combinator';
3
- import { inline } from '../inline';
2
+ import { union, sequence, some, creation, block, line, validate, focus, rewrite, surround, open, close, trimStart, fallback, lazy, fmap } from '../../combinator';
3
+ import { inline, media, medialink, shortmedia } from '../inline';
4
4
  import { contentline } from '../source';
5
5
  import { trimBlankStart, trimNodeEnd } from '../visibility';
6
6
  import { duffReduce } from 'spica/duff';
@@ -49,7 +49,12 @@ const align: AlignParser = creation(1, false, fmap(open(
49
49
 
50
50
  const cell: CellParser = surround(
51
51
  /^\|\s*(?=\S)/,
52
- trimBlankStart(some(union([inline]), /^\|/, [[/^[|\\]?\s*$/, 9]])),
52
+ trimStart(union([
53
+ close(medialink, /^\s*(?=\||$)/),
54
+ close(media, /^\s*(?=\||$)/),
55
+ close(shortmedia, /^\s*(?=\||$)/),
56
+ trimBlankStart(some(inline, /^\|/, [[/^[|\\]?\s*$/, 9]])),
57
+ ])),
53
58
  /^[^|]*/, true);
54
59
 
55
60
  const head: CellParser.HeadParser = creation(1, false, fmap(
@@ -1,18 +1,18 @@
1
1
  import { UListParser } from '../block';
2
- import { union, inits, subsequence, some, creation, state, block, line, validate, indent, focus, open, close, trim, fallback, lazy, fmap } from '../../combinator';
3
- import { olist_, invalid } from './olist';
2
+ import { Parser } from '../../combinator/data/parser';
3
+ import { union, inits, subsequence, some, creation, block, line, validate, indent, focus, rewrite, open, close, trim, fallback, lazy, fmap } from '../../combinator';
4
+ import { olist_ } from './olist';
4
5
  import { ilist_ } from './ilist';
5
6
  import { inline, indexer, indexee } from '../inline';
6
7
  import { index } from '../inline/extension/index';
7
- import { State } from '../context';
8
+ import { contentline } from '../source';
8
9
  import { visualize, trimBlank } from '../visibility';
9
10
  import { unshift } from 'spica/array';
10
11
  import { html, define, defrag } from 'typed-dom/dom';
11
12
 
12
13
  export const ulist: UListParser = lazy(() => block(validate(
13
14
  /^-(?=[^\S\n]|\n[^\S\n]*\S)/,
14
- state(State.media,
15
- ulist_))));
15
+ ulist_)));
16
16
 
17
17
  export const ulist_: UListParser = lazy(() => block(fmap(validate(
18
18
  /^-(?=$|\s)/,
@@ -38,6 +38,18 @@ export const checkbox = creation(1, false, focus(
38
38
  html('span', { class: 'checkbox' }, source[1].trimStart() ? '☑' : '☐'),
39
39
  ], '']));
40
40
 
41
+ export const invalid = rewrite(
42
+ inits([contentline, indent<Parser<string>>(({ source }) => [[source], ''])]),
43
+ ({ source }) => [[
44
+ '',
45
+ html('span', {
46
+ class: 'invalid',
47
+ 'data-invalid-syntax': 'list',
48
+ 'data-invalid-type': 'syntax',
49
+ 'data-invalid-message': 'Fix the indent or the head of the list item',
50
+ }, source.replace('\n', ''))
51
+ ], '']);
52
+
41
53
  export function fillFirstLine(ns: (HTMLElement | string)[]): (HTMLElement | string)[] {
42
54
  return ns.length === 1
43
55
  && typeof ns[0] === 'object'
@@ -13,6 +13,7 @@ import { mathblock } from './block/mathblock';
13
13
  import { extension } from './block/extension';
14
14
  import { sidefence } from './block/sidefence';
15
15
  import { blockquote } from './block/blockquote';
16
+ import { mediablock } from './block/mediablock';
16
17
  import { reply } from './block/reply';
17
18
  import { paragraph } from './block/paragraph';
18
19
  import { rnd0Z } from 'spica/random';
@@ -31,6 +32,7 @@ export import MathBlockParser = BlockParser.MathBlockParser;
31
32
  export import ExtensionParser = BlockParser.ExtensionParser;
32
33
  export import SidefenceParser = BlockParser.SidefenceParser;
33
34
  export import BlockquoteParser = BlockParser.BlockquoteParser;
35
+ export import MediaBlockParser = BlockParser.MediaBlockParser;
34
36
  export import ReplyParser = BlockParser.ReplyParser;
35
37
  export import ParagraphParser = BlockParser.ParagraphParser;
36
38
 
@@ -50,6 +52,7 @@ export const block: BlockParser = creation(1, false, error(
50
52
  extension,
51
53
  sidefence,
52
54
  blockquote,
55
+ mediablock,
53
56
  reply,
54
57
  paragraph
55
58
  ]))));
@@ -33,10 +33,12 @@ describe('Unit: parser/inline/autolink/account', () => {
33
33
  assert.deepStrictEqual(inspect(parser('@a-')), [['<a class="account" href="/@a">@a</a>'], '-']);
34
34
  assert.deepStrictEqual(inspect(parser('@a-b')), [['<a class="account" href="/@a-b">@a-b</a>'], '']);
35
35
  assert.deepStrictEqual(inspect(parser('@a--b')), [['<a class="account" href="/@a">@a</a>'], '--b']);
36
+ assert.deepStrictEqual(inspect(parser('@a.')), [['<a class="account" href="/@a">@a</a>'], '.']);
37
+ assert.deepStrictEqual(inspect(parser('@a.domain.com')), [['<a class="account" href="/@a.domain.com">@a.domain.com</a>'], '']);
36
38
  assert.deepStrictEqual(inspect(parser('@http://host')), [['<a class="account" href="/@http">@http</a>'], '://host']);
37
39
  assert.deepStrictEqual(inspect(parser('@ttp://host')), [['<a class="account" href="/@ttp">@ttp</a>'], '://host']);
38
40
  assert.deepStrictEqual(inspect(parser('@domain/a')), [['<a class="account" href="https://domain/@a" target="_blank">@domain/a</a>'], '']);
39
- assert.deepStrictEqual(inspect(parser('@domain.co.jp/a')), [['<a class="account" href="https://domain.co.jp/@a" target="_blank">@domain.co.jp/a</a>'], '']);
41
+ assert.deepStrictEqual(inspect(parser('@domain.com/a')), [['<a class="account" href="https://domain.com/@a" target="_blank">@domain.com/a</a>'], '']);
40
42
  });
41
43
 
42
44
  });
@@ -12,8 +12,8 @@ export const account: AutolinkParser.AccountParser = lazy(() => fmap(rewrite(
12
12
  open(
13
13
  '@',
14
14
  tails([
15
- 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),
16
- str(/^[a-z][0-9a-z]*(?:-[0-9a-z]+)*/i),
15
+ str(/^[0-9a-z](?:(?:[0-9a-z]|-(?=[0-9a-z])){0,61}[0-9a-z])?(?:\.[0-9a-z](?:(?:[0-9a-z]|-(?=[0-9a-z])){0,61}[0-9a-z])?)*\//i),
16
+ str(/^[a-z][0-9a-z]*(?:[-.][0-9a-z]+)*/i),
17
17
  ]))),
18
18
  convert(
19
19
  source =>
@@ -6,6 +6,6 @@ import { html } from 'typed-dom/dom';
6
6
  // https://html.spec.whatwg.org/multipage/input.html
7
7
 
8
8
  export const email: AutolinkParser.EmailParser = creation(rewrite(verify(
9
- str(/^[0-9a-z](?:[_.+-](?=[0-9a-z])|[0-9a-z]){0,255}@[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?(?:\.[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?)*(?![0-9a-z])/i),
9
+ str(/^[0-9a-z](?:[_.+-](?=[0-9a-z])|[0-9a-z]){0,255}@[0-9a-z](?:(?:[0-9a-z]|-(?=[0-9a-z])){0,61}[0-9a-z])?(?:\.[0-9a-z](?:(?:[0-9a-z]|-(?=[0-9a-z])){0,61}[0-9a-z])?)*(?![0-9a-z])/i),
10
10
  ([source]) => source.length <= 255),
11
11
  ({ source }) => [[html('a', { class: 'email', href: `mailto:${source}` }, source)], '']));
@@ -25,7 +25,7 @@ export const autolink: AutolinkParser = lazy(() =>
25
25
  channel,
26
26
  account,
27
27
  // Escape unmatched account-like strings.
28
- str(/^@+[0-9a-z]*(?:-[0-9a-z]+)*/i),
28
+ str(/^@+[0-9a-z]*(?:[-.][0-9a-z]+)*/i),
29
29
  // Escape invalid leading characters.
30
30
  str(new RegExp(/^(?:[^\p{C}\p{S}\p{P}\s]|emoji|['_])(?=#)/u.source.replace('emoji', emoji), 'u')),
31
31
  hashtag,
@@ -34,7 +34,7 @@ assert(identity(undefined, '0'.repeat(41) + '1'.repeat(38) + '2'.repeat(41) + 3,
34
34
  assert(identity(undefined, '0'.repeat(81) + '1'.repeat(38) + '2'.repeat(81) + 3, 'mark')!.slice(6) === '0'.repeat(38) + '...' + '1'.repeat(38) + '...' + '2'.repeat(38 - 1) + 3);
35
35
 
36
36
  export function index(source: Element, optional = false): string {
37
- assert(source instanceof DocumentFragment || !source.matches('.indexer'));
37
+ assert(!source.matches('.indexer'));
38
38
  assert(source.querySelectorAll(':scope > .indexer').length <= 1);
39
39
  if (!source.firstChild) return '';
40
40
  const indexer = source.querySelector(':scope > .indexer');
@@ -1,14 +1,12 @@
1
1
  import { ExtensionParser } from '../../inline';
2
- import { union, creation, state, focus, surround } from '../../../combinator';
2
+ import { union, creation, focus, surround } from '../../../combinator';
3
3
  import { signature } from './index';
4
- import { State } from '../../context';
5
4
  import { html } from 'typed-dom/dom';
6
5
 
7
6
  export const indexer: ExtensionParser.IndexerParser = surround(
8
7
  /^\s+\[(?=\|\S)/,
9
- state(State.index, false,
10
8
  union([
11
9
  signature,
12
10
  creation(focus(/^\|(?=\])/, () => [[html('span', { class: 'indexer', 'data-index': '' })], ''])),
13
- ])),
11
+ ]),
14
12
  /^\]\s*$/);
@@ -203,10 +203,10 @@ export function resolve(uri: string, host: URL | Location, source: URL | Locatio
203
203
 
204
204
  function decode(uri: string): string {
205
205
  if (!uri.includes('%')) return uri;
206
- const origin = uri.match(/^[a-z](?:[-.](?=\w)|[0-9a-z])*:(?:\/{0,2}[^/?#\s]+|\/\/(?=[/]))/i)?.[0] ?? '';
206
+ const origin = uri.match(/^[a-z](?:[-.](?=[0-9a-z])|[0-9a-z])*:(?:\/{0,2}[^/?#\s]+|\/\/(?=[/]))/i)?.[0] ?? '';
207
207
  try {
208
208
  let path = decodeURI(uri.slice(origin.length));
209
- if (!origin && /^[a-z](?:[-.](?=\w)|[0-9a-z])*:\/{0,2}\S/i.test(path)) {
209
+ if (!origin && /^[a-z](?:[-.](?=[0-9a-z])|[0-9a-z])*:\/{0,2}\S/i.test(path)) {
210
210
  path = uri.slice(origin.length);
211
211
  }
212
212
  uri = origin + path;
@@ -134,7 +134,7 @@ describe('Unit: parser/inline', () => {
134
134
  assert.deepStrictEqual(inspect(parser('{a}')), [['<a class="url" href="a">a</a>'], '']);
135
135
  assert.deepStrictEqual(inspect(parser('{{a}}')), [['<span class="template">{{a}}</span>'], '']);
136
136
  assert.deepStrictEqual(inspect(parser('\r!{}')), [['!', '{', '}'], '']);
137
- assert.deepStrictEqual(inspect(parser('\r!{a}')), [['<a href="a" target="_blank"><img class="media" data-src="a" alt=""></a>'], '']);
137
+ assert.deepStrictEqual(inspect(parser('\r!{a}')), [['!', '<a class="url" href="a">a</a>'], '']);
138
138
  assert.deepStrictEqual(inspect(parser('\r!{{a}}')), [['!', '<span class="template">{{a}}</span>'], '']);
139
139
  assert.deepStrictEqual(inspect(parser('\r!{{{a}}}')), [['!', '<span class="template">{{{a}}}</span>'], '']);
140
140
  assert.deepStrictEqual(inspect(parser('\r!!{a}')), [['!', '!', '<a class="url" href="a">a</a>'], '']);
@@ -7,7 +7,7 @@ import { remark } from './inline/remark';
7
7
  import { math } from './inline/math';
8
8
  import { extension } from './inline/extension';
9
9
  import { ruby } from './inline/ruby';
10
- import { textlink, linemedialink } from './inline/link';
10
+ import { textlink } from './inline/link';
11
11
  import { html } from './inline/html';
12
12
  import { insertion } from './inline/insertion';
13
13
  import { deletion } from './inline/deletion';
@@ -16,9 +16,7 @@ import { emstrong } from './inline/emstrong';
16
16
  import { emphasis } from './inline/emphasis';
17
17
  import { strong } from './inline/strong';
18
18
  import { code } from './inline/code';
19
- import { linemedia } from './inline/media';
20
19
  import { htmlentity } from './inline/htmlentity';
21
- import { lineshortmedia } from './inline/shortmedia';
22
20
  import { autolink } from './inline/autolink';
23
21
  import { bracket } from './inline/bracket';
24
22
  import { text } from './source';
@@ -56,8 +54,6 @@ export const inline: InlineParser = lazy(() => union([
56
54
  extension,
57
55
  ruby,
58
56
  textlink,
59
- linemedialink,
60
- linemedia,
61
57
  html,
62
58
  insertion,
63
59
  deletion,
@@ -67,7 +63,6 @@ export const inline: InlineParser = lazy(() => union([
67
63
  emphasis,
68
64
  code,
69
65
  htmlentity,
70
- lineshortmedia,
71
66
  autolink,
72
67
  bracket,
73
68
  text
@@ -75,5 +70,6 @@ export const inline: InlineParser = lazy(() => union([
75
70
 
76
71
  export { indexee } from './inline/extension/indexee';
77
72
  export { indexer } from './inline/extension/indexer';
73
+ export { medialink } from './inline/link';
78
74
  export { media } from './inline/media';
79
75
  export { shortmedia } from './inline/shortmedia';
@@ -16,15 +16,16 @@ export function* figure(
16
16
  .map(el => [el.getAttribute('data-label')!, el]));
17
17
  const labels = new Set<string>();
18
18
  const numbers = new Map<string, string>();
19
+ const scope = target instanceof Element ? ':scope > ' : '';
19
20
  let base = '0';
20
21
  let bases: readonly string[] = base.split('.');
21
22
  let index: readonly string[] = bases;
22
23
  for (
23
- let defs = target.querySelectorAll('figure[data-label], h1, h2'),
24
+ let defs = target.querySelectorAll(`${scope}:is(figure[data-label], h1, h2)`),
24
25
  len = defs.length, i = 0; i < len; ++i) {
25
26
  yield;
26
27
  const def = defs[i];
27
- if (def.parentNode !== target) continue;
28
+ if (!scope && def.parentNode !== target) continue;
28
29
  const { tagName } = def;
29
30
  if (bases.length === 1 && tagName[0] === 'H') continue;
30
31
  assert(base === '0' || bases.length > 1);
@@ -67,7 +67,8 @@ function build(
67
67
  const defIndexes = new Map<HTMLLIElement, number>();
68
68
  const refSubindexes = new Map<string, number>();
69
69
  const defSubindexes = new Map<string, number>();
70
- const splitters = splitter ? target.querySelectorAll(splitter) : [];
70
+ const scope = target instanceof Element ? ':scope > ' : '';
71
+ const splitters = splitter ? target.querySelectorAll(`${scope}:is(${splitter})`) : [];
71
72
  let iSplitters = 0;
72
73
  let total = 0;
73
74
  let format: 'number' | 'abbr';
@@ -84,7 +85,7 @@ function build(
84
85
  el?.compareDocumentPosition(ref) & Node.DOCUMENT_POSITION_FOLLOWING;
85
86
  ++iSplitters) {
86
87
  if (~iSplitters << 32 - 8 === 0) yield;
87
- if (el.parentNode !== target) continue;
88
+ if (!scope && el.parentNode !== target) continue;
88
89
  if (el.tagName === 'OL' && el.nextElementSibling !== splitters[iSplitters + 1]) {
89
90
  assert(el.matches(`.${syntax}s`));
90
91
  el.remove();
@@ -173,7 +174,7 @@ function build(
173
174
  el = splitters[iSplitters];
174
175
  ++iSplitters) {
175
176
  if (~iSplitters << 32 - 8 === 0) yield;
176
- if (el.parentNode !== target) continue;
177
+ if (!scope && el.parentNode !== target) continue;
177
178
  if (el.tagName === 'OL') {
178
179
  assert(el.matches(`.${syntax}s`));
179
180
  el.remove();
@@ -3,7 +3,6 @@ import { Parser, Input, eval } from '../combinator/data/parser';
3
3
  import { union, some, verify, convert, fmap } from '../combinator';
4
4
  import { unsafehtmlentity } from './inline/htmlentity';
5
5
  import { linebreak, unescsource } from './source';
6
- import { State } from './context';
7
6
  import { invisibleHTMLEntityNames } from './api/normalize';
8
7
  import { reduce } from 'spica/memoize';
9
8
  import { push } from 'spica/array';
@@ -23,13 +22,12 @@ export function visualize<T extends HTMLElement | string>(parser: Parser<T>): Pa
23
22
  return union([
24
23
  convert(
25
24
  source => source.replace(blank.line, line => line.replace(/[\\&<]/g, '\x1B$&')),
26
- verify(parser, (ns, rest, context) => !rest && hasVisible(ns, context))),
25
+ verify(parser, (ns, rest) => !rest && hasVisible(ns))),
27
26
  some(union([linebreak, unescsource])),
28
27
  ]);
29
28
  }
30
29
  function hasVisible(
31
30
  nodes: readonly (HTMLElement | string)[],
32
- { state = 0 }: MarkdownParser.Context = {},
33
31
  ): boolean {
34
32
  for (let i = 0; i < nodes.length; ++i) {
35
33
  const node = nodes[i];
@@ -38,8 +36,8 @@ function hasVisible(
38
36
  }
39
37
  else {
40
38
  if (node.innerText.trimStart()) return true;
41
- if (state & State.media ^ State.media &&
42
- (node.classList.contains('media') || node.getElementsByClassName('media')[0])) return true;
39
+ //if (state & State.media ^ State.media &&
40
+ // (node.classList.contains('media') || node.getElementsByClassName('media')[0])) return true;
43
41
  }
44
42
  }
45
43
  return false;
@@ -15,6 +15,6 @@ export function image(source: HTMLImageElement, url: URL, cache?: Dict<string, H
15
15
  source.cloneNode(true),
16
16
  Object.fromEntries([...source.attributes]
17
17
  .filter(attr => !['class', 'data-type', 'data-src', 'src', 'loading'].includes(attr.name))
18
- .map(attr => [attr.name, null]))));
18
+ .map(attr => [attr.name, attr.name === 'alt' ? '' : null]))));
19
19
  return source;
20
20
  }
@@ -19,7 +19,7 @@ const origins = [
19
19
  export function twitter(source: HTMLImageElement, url: URL): HTMLElement | undefined {
20
20
  if (!origins.includes(url.origin)) return;
21
21
  if (url.pathname.split('/').pop()!.includes('.')) return;
22
- if (!url.pathname.match(/^\/\w+\/status\/[0-9]{15,}(?!\w)/)) return;
22
+ if (!url.pathname.match(/^\/\w+\/status\/[0-9]{15,}\/?$/)) return;
23
23
  const el = h('div', { class: source.className, 'data-type': 'twitter' }, [
24
24
  h('em', `Loading ${source.getAttribute('data-src')}...`),
25
25
  ]);
@@ -23,18 +23,18 @@ describe('Unit: renderer/render', () => {
23
23
 
24
24
  it('media', () => {
25
25
  // image
26
- assert(render(parse('!https://pbs.twimg.com/media/C-RAIleV0AAO81x.jpg').querySelector('p')!).querySelector('img')!.matches('p > a > img'));
27
- assert(render(parse('[!{https://pbs.twimg.com/media/C-RAIleV0AAO81x.jpg}]{#}').querySelector('p')!).querySelector('img')!.matches('p > a > img'));
26
+ assert(render(parse('!https://pbs.twimg.com/media/C-RAIleV0AAO81x.jpg').querySelector('div')!).querySelector('img')!.matches('div > a > img'));
27
+ assert(render(parse('[!{https://pbs.twimg.com/media/C-RAIleV0AAO81x.jpg}]{#}').querySelector('div')!).querySelector('img')!.matches('div > a > img'));
28
28
  // other
29
- assert(render(parse('!http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf').querySelector('p')!).querySelector('.media')!.matches('p > .media'));
30
- assert(render(parse('[!{http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf}]{#}').querySelector('p')!).querySelector('.media')!.matches('p > .media'));
29
+ assert(render(parse('!http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf').querySelector('div')!).querySelector('.media')!.matches('div > .media'));
30
+ assert(render(parse('[!{http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf}]{#}').querySelector('div')!).querySelector('.media')!.matches('div > .media'));
31
31
  // all
32
32
  assert(render(parse([
33
33
  '!https://youtu.be/xRF7WIZV4lA',
34
34
  '!http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf',
35
35
  '!https://twitter.com/hourenso_u/status/856828123882676225?hide_thread=true',
36
36
  '!https://pbs.twimg.com/media/C-RAIleV0AAO81x.jpg',
37
- ].join('\n')).querySelector('p')!).querySelectorAll('.media').length === 4);
37
+ ].join('\n')).querySelector('div')!).querySelectorAll('.media').length === 4);
38
38
  });
39
39
 
40
40
  });
@@ -5,10 +5,10 @@ describe('Unit: util/quote', () => {
5
5
  describe('quote', () => {
6
6
  it('basic', () => {
7
7
  const range = document.createRange();
8
- const el = parse('>>1\n>2\n> a\n>>4 `b` ${c}$\n!{d}\n [e](f) ').firstElementChild!;
8
+ const el = parse('>>1\n>2\n> a\n>>4 `b` ${c}$\n [e](f) ').firstElementChild!;
9
9
  range.setStart(el.firstChild!.firstChild!, 0);
10
10
  range.setEnd(el.lastChild!.lastChild!.lastChild!, 1);
11
- assert(quote('3', range) === `>>>1\n> >2\n>> a\n>>3\n> >>4 \`b\` \${c}$\n> !{d}\n> e`);
11
+ assert(quote('3', range) === `>>>1\n> >2\n>> a\n>>3\n> >>4 \`b\` \${c}$\n> e`);
12
12
  });
13
13
 
14
14
  it('adjustment', () => {