securemark 0.287.0 → 0.288.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 (37) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/index.js +56 -62
  3. package/markdown.d.ts +13 -36
  4. package/package.json +1 -1
  5. package/src/combinator/control/manipulation/convert.ts +4 -4
  6. package/src/combinator/control/manipulation/trim.ts +3 -3
  7. package/src/parser/autolink.test.ts +4 -2
  8. package/src/parser/autolink.ts +2 -1
  9. package/src/parser/block/blockquote.test.ts +2 -0
  10. package/src/parser/block/blockquote.ts +4 -4
  11. package/src/parser/block/codeblock.test.ts +2 -0
  12. package/src/parser/block/extension/fig.ts +2 -1
  13. package/src/parser/block/extension/figure.ts +1 -1
  14. package/src/parser/block/extension/table.ts +2 -2
  15. package/src/parser/block/paragraph.test.ts +4 -5
  16. package/src/parser/block/reply/cite.test.ts +8 -10
  17. package/src/parser/block/reply/cite.ts +24 -11
  18. package/src/parser/block/reply/quote.test.ts +18 -17
  19. package/src/parser/block/reply/quote.ts +15 -30
  20. package/src/parser/block/reply.test.ts +14 -1
  21. package/src/parser/block/reply.ts +12 -24
  22. package/src/parser/block/sidefence.test.ts +2 -0
  23. package/src/parser/block/sidefence.ts +2 -2
  24. package/src/parser/header.ts +1 -1
  25. package/src/parser/inline/autolink/account.ts +2 -1
  26. package/src/parser/inline/autolink/anchor.ts +2 -1
  27. package/src/parser/inline/autolink/hashnum.ts +2 -1
  28. package/src/parser/inline/autolink/hashtag.ts +2 -1
  29. package/src/parser/inline/autolink/url.ts +12 -10
  30. package/src/parser/inline/media.ts +6 -6
  31. package/src/parser/inline/shortmedia.ts +4 -2
  32. package/src/parser/inline/template.ts +9 -9
  33. package/src/parser/inline.test.ts +2 -0
  34. package/src/parser/source/str.ts +2 -1
  35. package/src/parser/util.ts +6 -3
  36. package/src/parser/visibility.ts +4 -2
  37. package/src/util/quote.test.ts +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.288.0
4
+
5
+ - Improve reply parser.
6
+
7
+ ## 0.287.1
8
+
9
+ - Refactoring.
10
+
3
11
  ## 0.287.0
4
12
 
5
13
  - Change template syntax to disallow linebreaks.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.287.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.288.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"));
@@ -24,15 +24,15 @@ Object.defineProperty(exports, "__esModule", ({
24
24
  exports.trimEnd = exports.trimStart = exports.trim = void 0;
25
25
  const convert_1 = __webpack_require__(6572);
26
26
  function trim(parser) {
27
- return (0, convert_1.convert)(source => source.trim(), parser);
27
+ return (0, convert_1.convert)(source => source.trim(), parser, false);
28
28
  }
29
29
  exports.trim = trim;
30
30
  function trimStart(parser) {
31
- return (0, convert_1.convert)(source => source.trimStart(), parser);
31
+ return (0, convert_1.convert)(source => source.trimStart(), parser, true);
32
32
  }
33
33
  exports.trimStart = trimStart;
34
34
  function trimEnd(parser) {
35
- return (0, convert_1.convert)(source => source.trimEnd(), parser);
35
+ return (0, convert_1.convert)(source => source.trimEnd(), parser, false);
36
36
  }
37
37
  exports.trimEnd = trimEnd;
38
38
 
@@ -1302,31 +1302,37 @@ class ReadonlyURLSearchParams extends URLSearchParams {
1302
1302
  Object.defineProperty(exports, "__esModule", ({
1303
1303
  value: true
1304
1304
  }));
1305
- exports.cite = void 0;
1305
+ exports.cite = exports.syntax = void 0;
1306
1306
  const combinator_1 = __webpack_require__(3484);
1307
1307
  const anchor_1 = __webpack_require__(8535);
1308
1308
  const source_1 = __webpack_require__(8745);
1309
1309
  const dom_1 = __webpack_require__(394);
1310
- exports.cite = (0, combinator_1.line)((0, combinator_1.fmap)((0, combinator_1.validate)('>>', (0, combinator_1.reverse)((0, combinator_1.tails)([(0, source_1.str)(/^>*(?=>>[^>\s]+\s*$)/), (0, combinator_1.union)([anchor_1.anchor,
1310
+ exports.syntax = /^>*(?=>>[^>\s]\S*[^\S\n]*(?:$|\n))/;
1311
+ exports.cite = (0, combinator_1.line)((0, combinator_1.fmap)((0, combinator_1.validate)('>>', (0, combinator_1.open)((0, source_1.str)(exports.syntax), (0, combinator_1.union)([anchor_1.anchor,
1311
1312
  // Subject page representation.
1312
1313
  // リンクの実装は後で検討
1313
- (0, combinator_1.focus)(/^>>\.(?=\s*$)/, () => [[(0, dom_1.html)('a', {
1314
- class: 'anchor'
1315
- }, '>>.')], ''], false), (0, combinator_1.focus)(/^>>#\S*(?=\s*$)/, ({
1314
+ (0, combinator_1.focus)(/^>>#\S*(?=\s*$)/, ({
1316
1315
  source
1317
1316
  }) => [[(0, dom_1.html)('a', {
1318
1317
  class: 'anchor'
1319
- }, source)], ''], false), (0, combinator_1.focus)(/^>>https?:\/\/(?:[[]|[^\p{C}\p{S}\p{P}\s])\S*(?=\s*$)/u, ({
1318
+ }, source)], ''], false), (0, combinator_1.focus)(/^>>https?:\/\/\S+(?=\s*$)/, ({
1320
1319
  source
1321
1320
  }) => [[(0, dom_1.html)('a', {
1322
1321
  class: 'anchor',
1323
1322
  href: source.slice(2).trimEnd(),
1324
1323
  target: '_blank'
1325
- }, source)], ''], false)])]))), ([el, quotes = '']) => [(0, dom_1.html)('span', {
1324
+ }, source)], ''], false), (0, combinator_1.focus)(/^>>.+(?=\s*$)/, ({
1325
+ source
1326
+ }) => [[source], ''], false)]))), ([quotes, node]) => [(0, dom_1.html)('span', typeof node === 'object' ? {
1326
1327
  class: 'cite'
1327
- }, (0, dom_1.defrag)([`${quotes}>`, (0, dom_1.define)(el, {
1328
+ } : {
1329
+ class: 'cite invalid',
1330
+ 'data-invalid-syntax': 'cite',
1331
+ 'data-invalid-type': 'syntax',
1332
+ 'data-invalid-message': 'Invalid syntax'
1333
+ }, (0, dom_1.defrag)([`${quotes}>`, typeof node === 'object' ? (0, dom_1.define)(node, {
1328
1334
  'data-depth': `${quotes.length + 1}`
1329
- }, el.innerText.slice(1))])), (0, dom_1.html)('br')]));
1335
+ }, node.innerText.slice(1)) : node.slice(1)])), (0, dom_1.html)('br')]));
1330
1336
 
1331
1337
  /***/ },
1332
1338
 
@@ -1727,7 +1733,7 @@ exports.autolink = void 0;
1727
1733
  const combinator_1 = __webpack_require__(3484);
1728
1734
  const autolink_1 = __webpack_require__(8072);
1729
1735
  const source_1 = __webpack_require__(8745);
1730
- exports.autolink = (0, combinator_1.lazy)(() => (0, combinator_1.convert)(source => `\r${source}`, (0, combinator_1.some)((0, combinator_1.union)([autolink_1.autolink, source_1.linebreak, source_1.unescsource]))));
1736
+ exports.autolink = (0, combinator_1.lazy)(() => (0, combinator_1.convert)(source => `\r${source}`, (0, combinator_1.some)((0, combinator_1.union)([autolink_1.autolink, source_1.linebreak, source_1.unescsource])), false));
1731
1737
 
1732
1738
  /***/ },
1733
1739
 
@@ -1996,13 +2002,13 @@ const combinator_1 = __webpack_require__(3484);
1996
2002
  const link_1 = __webpack_require__(3628);
1997
2003
  const source_1 = __webpack_require__(8745);
1998
2004
  const closer = /^[-+*=~^_,.;:!?]*(?=[\\"`|\[\](){}<>]|$)/;
1999
- exports.url = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['http://', 'https://'], (0, combinator_1.rewrite)((0, combinator_1.open)(/^https?:\/\/(?=[\x21-\x7E])/, (0, combinator_1.focus)(/^[\x21-\x7E]+/, (0, combinator_1.precedence)(1, (0, combinator_1.some)((0, combinator_1.verify)((0, combinator_1.union)([bracket, (0, combinator_1.some)(source_1.unescsource, closer)]), ns => ns[0] !== "\u001B" /* Command.Escape */))))), (0, combinator_1.union)([(0, combinator_1.constraint)(1 /* State.autolink */, false, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.convert)(url => `{ ${url} }`, link_1.unsafelink))), ({
2005
+ exports.url = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['http://', 'https://'], (0, combinator_1.rewrite)((0, combinator_1.open)(/^https?:\/\/(?=[\x21-\x7E])/, (0, combinator_1.focus)(/^[\x21-\x7E]+/, (0, combinator_1.precedence)(1, (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.verify)(bracket, ns => ns.length > 0), (0, combinator_1.some)(source_1.unescsource, closer)]))))), (0, combinator_1.union)([(0, combinator_1.constraint)(1 /* State.autolink */, false, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.convert)(url => `{ ${url} }`, link_1.unsafelink, false))), ({
2000
2006
  source
2001
2007
  }) => [[source], '']]))));
2002
- exports.lineurl = (0, combinator_1.lazy)(() => (0, combinator_1.open)(source_1.linebreak, (0, combinator_1.focus)(/^!?https?:\/\/\S+(?=[^\S\n]*(?:$|\n))/, (0, combinator_1.tails)([(0, source_1.str)('!'), (0, combinator_1.union)([(0, combinator_1.constraint)(1 /* State.autolink */, false, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.convert)(url => `{ ${url} }`, link_1.unsafelink))), ({
2008
+ exports.lineurl = (0, combinator_1.lazy)(() => (0, combinator_1.open)(source_1.linebreak, (0, combinator_1.focus)(/^!?https?:\/\/\S+(?=[^\S\n]*(?:$|\n))/, (0, combinator_1.tails)([(0, source_1.str)('!'), (0, combinator_1.union)([(0, combinator_1.constraint)(1 /* State.autolink */, false, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.convert)(url => `{ ${url} }`, link_1.unsafelink, false))), ({
2003
2009
  source
2004
2010
  }) => [[source], '']])]))));
2005
- const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), ')')), (0, source_1.str)(')'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], [3 | 0 /* Backtrack.lineunescbracket */]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), ']')), (0, source_1.str)(']'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], [3 | 0 /* Backtrack.lineunescbracket */]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), '}')), (0, source_1.str)('}'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], [3 | 0 /* Backtrack.lineunescbracket */]), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)(source_1.unescsource, '"'))), (0, source_1.str)('"'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], [3 | 0 /* Backtrack.lineunescbracket */])]));
2011
+ const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), ')')), (0, source_1.str)(')'), true, undefined, () => [[], ''], [3 | 0 /* Backtrack.lineunescbracket */]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), ']')), (0, source_1.str)(']'), true, undefined, () => [[], ''], [3 | 0 /* Backtrack.lineunescbracket */]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), '}')), (0, source_1.str)('}'), true, undefined, () => [[], ''], [3 | 0 /* Backtrack.lineunescbracket */]), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)(source_1.unescsource, '"'))), (0, source_1.str)('"'), true, undefined, () => [[], ''], [3 | 0 /* Backtrack.lineunescbracket */])]));
2006
2012
 
2007
2013
  /***/ },
2008
2014
 
@@ -2494,7 +2500,7 @@ exports.header = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(/^---+[
2494
2500
  class: 'header'
2495
2501
  }, [(0, dom_1.html)('details', {
2496
2502
  open: ''
2497
- }, (0, dom_1.defrag)([(0, dom_1.html)('summary', 'Header'), ...es]))])])), false)), ({
2503
+ }, (0, dom_1.defrag)([(0, dom_1.html)('summary', 'Header'), ...es]))])]), false), false)), ({
2498
2504
  source
2499
2505
  }) => [[(0, dom_1.html)('pre', {
2500
2506
  class: 'invalid',
@@ -3424,7 +3430,7 @@ const align = (0, combinator_1.line)((0, combinator_1.fmap)((0, combinator_1.uni
3424
3430
  const delimiter = /^[-=<>]+(?:\/[-=^v]*)?(?=[^\S\n]*\n)|^[#:](?:(?!:\D|0)\d*:(?!0)\d*)?(?:!+[+]?)?(?=\s)/;
3425
3431
  const head = (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.trimBlank)((0, combinator_1.some)(inline_1.inline))), true)])), true), ns => [(0, dom_1.html)('th', attributes(ns.shift()), (0, dom_1.defrag)(ns))]), false);
3426
3432
  const data = (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.trimBlankEnd)((0, util_1.lineable)((0, combinator_1.some)(inline_1.inline)))), true)])), true), ns => [(0, dom_1.html)('td', attributes(ns.shift()), (0, dom_1.defrag)(ns))]), false);
3427
- const dataline = (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)])));
3433
+ const dataline = (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, true)), (0, combinator_1.convert)(source => `: ${source}`, data, true)])));
3428
3434
  function attributes(source) {
3429
3435
  let [, rowspan = undefined, colspan = undefined, highlight = undefined, extension = undefined] = source.match(/^[#:](?:(\d+)?:(\d+)?)?(?:(!+)([+]?))?$/) ?? [];
3430
3436
  rowspan === '1' ? rowspan = undefined : undefined;
@@ -4053,15 +4059,9 @@ const inline_1 = __webpack_require__(7973);
4053
4059
  const source_1 = __webpack_require__(8745);
4054
4060
  const util_1 = __webpack_require__(4992);
4055
4061
  const visibility_1 = __webpack_require__(6364);
4056
- const array_1 = __webpack_require__(6876);
4057
4062
  const dom_1 = __webpack_require__(394);
4058
- /*
4059
- 必ず対象指定から始まる
4060
- 対象がページである場合>>.を表現方法とする
4061
- 対象をURLで指定すべき(引用ツリーにルートを追加する)場合はない
4062
- 対象と引用は1:N(分割)、N:1(統合)のみ可能、N:N(混合)は不可能
4063
- */
4064
- exports.reply = (0, combinator_1.block)((0, combinator_1.validate)('>', (0, combinator_1.fmap)((0, combinator_1.inits)([(0, combinator_1.some)((0, combinator_1.inits)([cite_1.cite, quote_1.quote])), (0, combinator_1.some)((0, combinator_1.subsequence)([(0, combinator_1.some)(quote_1.quote), (0, combinator_1.fmap)((0, combinator_1.rewrite)((0, combinator_1.some)(source_1.anyline, quote_1.syntax), (0, visibility_1.visualize)((0, util_1.lineable)((0, combinator_1.some)(inline_1.inline)))), ns => (0, array_1.push)(ns, [(0, dom_1.html)('br')]))]))]), ns => [(0, dom_1.html)('p', (0, visibility_1.trimBlankNodeEnd)((0, dom_1.defrag)(ns)))])));
4063
+ const delimiter = new RegExp(String.raw`${cite_1.syntax.source}|${quote_1.syntax.source}`);
4064
+ exports.reply = (0, combinator_1.block)((0, combinator_1.validate)(cite_1.syntax, (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.union)([cite_1.cite, quote_1.quote, (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.anyline, delimiter), (0, visibility_1.visualize)((0, util_1.lineable)((0, combinator_1.some)(inline_1.inline), true)))])), ns => [(0, dom_1.html)('p', (0, visibility_1.trimBlankNodeEnd)((0, dom_1.defrag)(ns)))])));
4065
4065
 
4066
4066
  /***/ },
4067
4067
 
@@ -4338,7 +4338,8 @@ function str(pattern, not) {
4338
4338
  const m = source.match(pattern);
4339
4339
  count && m && (0, combinator_1.consume)(m[0].length, context);
4340
4340
  if (m && not && source.slice(m[0].length, m[0].length + not.length) === not) return;
4341
- return m && m[0].length > 0 ? [[m[0]], source.slice(m[0].length)] : undefined;
4341
+ //assert(!m || m[0]);
4342
+ return m ? [[m[0]], source.slice(m[0].length)] : undefined;
4342
4343
  };
4343
4344
  }
4344
4345
  exports.str = str;
@@ -4403,7 +4404,7 @@ const link_1 = __webpack_require__(3628);
4403
4404
  const source_1 = __webpack_require__(8745);
4404
4405
  const dom_1 = __webpack_require__(394);
4405
4406
  // https://example/@user must be a user page or a redirect page going there.
4406
- exports.account = (0, combinator_1.lazy)(() => (0, combinator_1.rewrite)((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.union)([(0, combinator_1.constraint)(1 /* State.autolink */, false, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.fmap)((0, combinator_1.convert)(source => `[${source}]{ ${source.includes('/') ? `https://${source.slice(1).replace('/', '/@')}` : `/${source}`} }`, link_1.unsafelink), ([el]) => [(0, dom_1.define)(el, {
4407
+ exports.account = (0, combinator_1.lazy)(() => (0, combinator_1.rewrite)((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.union)([(0, combinator_1.constraint)(1 /* State.autolink */, false, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.fmap)((0, combinator_1.convert)(source => `[${source}]{ ${source.includes('/') ? `https://${source.slice(1).replace('/', '/@')}` : `/${source}`} }`, link_1.unsafelink, false), ([el]) => [(0, dom_1.define)(el, {
4407
4408
  class: 'account'
4408
4409
  })]))), ({
4409
4410
  source
@@ -4709,7 +4710,7 @@ const dom_1 = __webpack_require__(394);
4709
4710
  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)([
4710
4711
  // All parsers which can include closing terms.
4711
4712
  (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, {}), false));
4712
- 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.trimBlank)((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', {
4713
+ 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.trimBlank)((0, combinator_1.some)(inline_1.inline))))])]), false), ([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', {
4713
4714
  class: 'figindex'
4714
4715
  }), (0, dom_1.html)('span', {
4715
4716
  class: 'figtext'
@@ -5028,10 +5029,10 @@ exports.template = void 0;
5028
5029
  const combinator_1 = __webpack_require__(3484);
5029
5030
  const source_1 = __webpack_require__(8745);
5030
5031
  const dom_1 = __webpack_require__(394);
5031
- exports.template = (0, combinator_1.lazy)(() => (0, combinator_1.surround)('{{', (0, combinator_1.precedence)(1, (0, combinator_1.some)((0, combinator_1.verify)((0, combinator_1.union)([bracket, source_1.escsource]), ns => ns[0] !== "\u001B" /* Command.Escape */), '}', [['\n', 9]])), '}}', true, ([, ns = []], rest) => [[(0, dom_1.html)('span', {
5032
+ exports.template = (0, combinator_1.lazy)(() => (0, combinator_1.surround)('{{', (0, combinator_1.precedence)(1, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), '}', [['\n', 9]])), '}}', true, ([, ns = []], rest) => [[(0, dom_1.html)('span', {
5032
5033
  class: 'template'
5033
- }, `{{${ns.join('')}}}`)], rest], undefined, [3 | 16 /* Backtrack.linedoublebracket */, 1 | 4 /* Backtrack.lineescbracket */], 8 /* Backtrack.bracket */));
5034
- const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ')')), (0, source_1.str)(')'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], [3 | 4 /* Backtrack.lineescbracket */]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ']')), (0, source_1.str)(']'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], [3 | 4 /* Backtrack.lineescbracket */]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), '}')), (0, source_1.str)('}'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], [3 | 4 /* Backtrack.lineescbracket */]), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)(source_1.escsource, /^["\n]/))), (0, source_1.str)('"'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], [3 | 4 /* Backtrack.lineescbracket */])]));
5034
+ }, `{{${ns.join('')}}}`)], rest], undefined, [3 | 16 /* Backtrack.linedoublebracket */, 1 | 4 /* Backtrack.lineescbracket */]));
5035
+ const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ')')), (0, source_1.str)(')'), true, undefined, () => [[], ''], [3 | 4 /* Backtrack.lineescbracket */]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ']')), (0, source_1.str)(']'), true, undefined, () => [[], ''], [3 | 4 /* Backtrack.lineescbracket */]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), '}')), (0, source_1.str)('}'), true, undefined, () => [[], ''], [3 | 4 /* Backtrack.lineescbracket */]), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)(source_1.escsource, '"'))), (0, source_1.str)('"'), true, undefined, () => [[], ''], [3 | 4 /* Backtrack.lineescbracket */])]));
5035
5036
 
5036
5037
  /***/ },
5037
5038
 
@@ -5220,18 +5221,12 @@ const math_1 = __webpack_require__(2962);
5220
5221
  const autolink_1 = __webpack_require__(8072);
5221
5222
  const source_1 = __webpack_require__(8745);
5222
5223
  const dom_1 = __webpack_require__(394);
5223
- exports.syntax = /^>+(?=[^\S\n])|^>(?=[^\s>])|^>+(?=[^\s>])(?![0-9a-z]+(?:-[0-9a-z]+)*(?![0-9A-Za-z@#:]))/;
5224
- exports.quote = (0, combinator_1.lazy)(() => (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 ? {
5224
+ exports.syntax = /^>+[^\S\n]/;
5225
+ exports.quote = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)('>', (0, combinator_1.rewrite)((0, combinator_1.some)((0, combinator_1.validate)(exports.syntax, source_1.anyline)), (0, combinator_1.convert)(source => source.replace(/\n$/, '').replace(/(?<=^>+[^\S\n])/mg, '\r'), (0, combinator_1.some)((0, combinator_1.union)([math_1.math,
5226
+ // quote補助関数が残した数式をパースする。他の構文で数式を残す場合はソーステキストを直接使用する。
5227
+ autolink_1.autolink, source_1.linebreak, source_1.unescsource])), false))), ns => [(0, dom_1.html)('span', {
5225
5228
  class: 'quote'
5226
- } : {
5227
- class: 'quote invalid',
5228
- 'data-invalid-syntax': 'quote',
5229
- 'data-invalid-type': 'syntax',
5230
- 'data-invalid-message': `Missing the whitespace after "${ns[0].split(/[^>]/, 1)[0]}"`
5231
5229
  }, (0, dom_1.defrag)(ns)), (0, dom_1.html)('br')]), false));
5232
- const qblock = (0, combinator_1.convert)(source => source.replace(/\n$/, '').replace(/(?<=^>+[^\S\n])/mg, '\r'), (0, combinator_1.some)((0, combinator_1.union)([math_1.math,
5233
- // quote補助関数が残した数式をパースする。他の構文で数式を残す場合はソーステキストを直接使用する。
5234
- autolink_1.autolink, source_1.linebreak, source_1.unescsource])));
5235
5230
 
5236
5231
  /***/ },
5237
5232
 
@@ -5283,8 +5278,8 @@ const alias_1 = __webpack_require__(5413);
5283
5278
  const parser_1 = __webpack_require__(605);
5284
5279
  const combinator_1 = __webpack_require__(3484);
5285
5280
  const dom_1 = __webpack_require__(394);
5286
- function lineable(parser) {
5287
- return (0, combinator_1.convert)(source => `\r${source}`, parser);
5281
+ function lineable(parser, fillTrailingLinebreak = false) {
5282
+ return (0, combinator_1.convert)(source => `\r${source}${fillTrailingLinebreak && source.at(-1) !== '\n' ? '\n' : ''}`, parser, !fillTrailingLinebreak);
5288
5283
  }
5289
5284
  exports.lineable = lineable;
5290
5285
  function repeat(symbol, parser, cons, termination = (acc, rest, prefix, postfix) => {
@@ -5926,7 +5921,7 @@ const dom_1 = __webpack_require__(394);
5926
5921
  // https://example/hashtags/a must be a hashtag page or a redirect page going there.
5927
5922
  // https://github.com/tc39/proposal-regexp-unicode-property-escapes#matching-emoji
5928
5923
  exports.emoji = String.raw`\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F`;
5929
- exports.hashtag = (0, combinator_1.lazy)(() => (0, combinator_1.rewrite)((0, combinator_1.open)('#', (0, source_1.str)(new RegExp([/^(?!['_])(?=(?:[0-9]{1,9})?(?:[^\d\p{C}\p{S}\p{P}\s]|emoji|'(?=[0-9A-Za-z])|_(?=[^'\p{C}\p{S}\p{P}\s]|emoji)))/u.source, /(?:[^\p{C}\p{S}\p{P}\s]|emoji|'(?=[0-9A-Za-z])|_(?=[^'\p{C}\p{S}\p{P}\s]|emoji))+/u.source].join('').replace(/emoji/g, exports.emoji), 'u'))), (0, combinator_1.union)([(0, combinator_1.constraint)(1 /* State.autolink */, false, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.fmap)((0, combinator_1.convert)(source => `[${source}]{ ${`/hashtags/${source.slice(1)}`} }`, link_1.unsafelink), ([el]) => [(0, dom_1.define)(el, {
5924
+ exports.hashtag = (0, combinator_1.lazy)(() => (0, combinator_1.rewrite)((0, combinator_1.open)('#', (0, source_1.str)(new RegExp([/^(?!['_])(?=(?:[0-9]{1,9})?(?:[^\d\p{C}\p{S}\p{P}\s]|emoji|'(?=[0-9A-Za-z])|_(?=[^'\p{C}\p{S}\p{P}\s]|emoji)))/u.source, /(?:[^\p{C}\p{S}\p{P}\s]|emoji|'(?=[0-9A-Za-z])|_(?=[^'\p{C}\p{S}\p{P}\s]|emoji))+/u.source].join('').replace(/emoji/g, exports.emoji), 'u'))), (0, combinator_1.union)([(0, combinator_1.constraint)(1 /* State.autolink */, false, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.fmap)((0, combinator_1.convert)(source => `[${source}]{ ${`/hashtags/${source.slice(1)}`} }`, link_1.unsafelink, false), ([el]) => [(0, dom_1.define)(el, {
5930
5925
  class: 'hashtag'
5931
5926
  })]))), ({
5932
5927
  source
@@ -6098,8 +6093,8 @@ exports.blockquote = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, co
6098
6093
  const opener = /^(?=>>+(?:$|\s))/;
6099
6094
  const indent = (0, combinator_1.block)((0, combinator_1.open)(opener, (0, combinator_1.some)(source_1.contentline, /^>(?:$|\s)/)), false);
6100
6095
  const unindent = source => source.replace(/(?<=^|\n)>(?:[^\S\n]|(?=>*(?:$|\s)))|\n$/g, '');
6101
- const source = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.recursion)(2 /* Recursion.blockquote */, (0, combinator_1.union)([(0, combinator_1.rewrite)(indent, (0, combinator_1.convert)(unindent, source, true)), (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, (0, combinator_1.fmap)(autolink_1.autolink, ns => [(0, dom_1.html)('pre', (0, dom_1.defrag)(ns))]), true))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
6102
- const markdown = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.recursion)(2 /* Recursion.blockquote */, (0, combinator_1.union)([(0, combinator_1.rewrite)(indent, (0, combinator_1.convert)(unindent, markdown, true)), (0, combinator_1.creation)(10, (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, ({
6096
+ const source = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.recursion)(2 /* Recursion.blockquote */, (0, combinator_1.union)([(0, combinator_1.rewrite)(indent, (0, combinator_1.convert)(unindent, source, false, true)), (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, (0, combinator_1.fmap)(autolink_1.autolink, ns => [(0, dom_1.html)('pre', (0, dom_1.defrag)(ns))]), false, true))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
6097
+ const markdown = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.recursion)(2 /* Recursion.blockquote */, (0, combinator_1.union)([(0, combinator_1.rewrite)(indent, (0, combinator_1.convert)(unindent, markdown, false, true)), (0, combinator_1.creation)(10, (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, ({
6103
6098
  source,
6104
6099
  context
6105
6100
  }) => {
@@ -6113,7 +6108,7 @@ const markdown = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combina
6113
6108
  }
6114
6109
  }, context);
6115
6110
  return [[(0, dom_1.html)('section', [document, (0, dom_1.html)('h2', 'References'), references])], ''];
6116
- }, true)))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
6111
+ }, false, true)))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
6117
6112
 
6118
6113
  /***/ },
6119
6114
 
@@ -6192,8 +6187,8 @@ const combinator_1 = __webpack_require__(3484);
6192
6187
  const url_1 = __webpack_require__(2129);
6193
6188
  const media_1 = __webpack_require__(7478);
6194
6189
  const source_1 = __webpack_require__(8745);
6195
- exports.shortmedia = (0, combinator_1.constraint)(4 /* State.media */, false, (0, combinator_1.rewrite)((0, combinator_1.open)('!', url_1.url), (0, combinator_1.convert)(source => `!{ ${source.slice(1)} }`, (0, combinator_1.union)([media_1.media]))));
6196
- exports.lineshortmedia = (0, combinator_1.open)(source_1.linebreak, (0, combinator_1.focus)(/^!https?:\/\/\S+(?=[^\S\n]*(?:$|\n))/, (0, combinator_1.convert)(source => `!{ ${source.slice(1)} }`, (0, combinator_1.union)([media_1.media]))));
6190
+ exports.shortmedia = (0, combinator_1.constraint)(4 /* State.media */, false, (0, combinator_1.rewrite)((0, combinator_1.open)('!', url_1.url), (0, combinator_1.convert)(source => `!{ ${source.slice(1)} }`, (0, combinator_1.union)([media_1.media]), false)));
6191
+ exports.lineshortmedia = (0, combinator_1.open)(source_1.linebreak, (0, combinator_1.focus)(/^!https?:\/\/\S+(?=[^\S\n]*(?:$|\n))/, (0, combinator_1.convert)(source => `!{ ${source.slice(1)} }`, (0, combinator_1.union)([media_1.media]), false)));
6197
6192
 
6198
6193
  /***/ },
6199
6194
 
@@ -6352,7 +6347,7 @@ var blank;
6352
6347
  blank.start = new RegExp(/^(?:\\?[^\S\r\n]|&IHN;|<wbr[^\S\n]*>)+/.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`));
6353
6348
  })(blank || (exports.blank = blank = {}));
6354
6349
  function visualize(parser) {
6355
- return (0, combinator_1.union)([(0, combinator_1.convert)(source => source.replace(blank.line, line => line.replace(/[\\&<]/g, `${"\u001B" /* Command.Escape */}$&`)), (0, combinator_1.verify)(parser, (ns, rest) => !rest && hasVisible(ns))), (0, combinator_1.some)((0, combinator_1.union)([source_1.linebreak, source_1.unescsource]))]);
6350
+ return (0, combinator_1.union)([(0, combinator_1.convert)(source => source.replace(blank.line, line => line.replace(/[\\&<]/g, `${"\u001B" /* Command.Escape */}$&`)), (0, combinator_1.verify)(parser, (ns, rest) => !rest && hasVisible(ns)), false), (0, combinator_1.some)((0, combinator_1.union)([source_1.linebreak, source_1.unescsource]))]);
6356
6351
  }
6357
6352
  exports.visualize = visualize;
6358
6353
  function hasVisible(nodes) {
@@ -6458,7 +6453,7 @@ function trimBlank(parser) {
6458
6453
  }
6459
6454
  exports.trimBlank = trimBlank;
6460
6455
  function trimBlankStart(parser) {
6461
- return (0, combinator_1.convert)(source => source.replace(blank.start, ''), parser);
6456
+ return (0, combinator_1.convert)(source => source.replace(blank.start, ''), parser, true);
6462
6457
  }
6463
6458
  exports.trimBlankStart = trimBlankStart;
6464
6459
  function trimBlankEnd(parser) {
@@ -6524,7 +6519,7 @@ exports.sidefence = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, com
6524
6519
  })])));
6525
6520
  const opener = /^(?=\|\|+(?:$|\s))/;
6526
6521
  const unindent = source => source.replace(/(?<=^|\n)\|(?:[^\S\n]|(?=\|*(?:$|\s)))|\n$/g, '');
6527
- const source = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.recursion)(1 /* Recursion.block */, (0, combinator_1.union)([(0, combinator_1.focus)(/^(?:\|\|+(?:[^\S\n][^\n]*)?(?:$|\n))+/, (0, combinator_1.convert)(unindent, source, true), false), (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, (0, combinator_1.fmap)(autolink_1.autolink, ns => [(0, dom_1.html)('pre', (0, dom_1.defrag)(ns))]), true))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
6522
+ const source = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.recursion)(1 /* Recursion.block */, (0, combinator_1.union)([(0, combinator_1.focus)(/^(?:\|\|+(?:[^\S\n][^\n]*)?(?:$|\n))+/, (0, combinator_1.convert)(unindent, source, false, true), false), (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))]), false, true))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
6528
6523
 
6529
6524
  /***/ },
6530
6525
 
@@ -6539,7 +6534,7 @@ Object.defineProperty(exports, "__esModule", ({
6539
6534
  }));
6540
6535
  exports.convert = void 0;
6541
6536
  const parser_1 = __webpack_require__(605);
6542
- function convert(conv, parser, empty = false) {
6537
+ function convert(conv, parser, continuous, empty = false) {
6543
6538
  return ({
6544
6539
  source,
6545
6540
  context
@@ -6547,11 +6542,10 @@ function convert(conv, parser, empty = false) {
6547
6542
  if (source === '') return;
6548
6543
  const src = conv(source, context);
6549
6544
  if (src === '') return empty ? [[], ''] : undefined;
6550
- const sub = source.endsWith(src);
6551
6545
  const {
6552
6546
  backtracks
6553
6547
  } = context;
6554
- context.backtracks = sub ? backtracks : {};
6548
+ context.backtracks = continuous ? backtracks : {};
6555
6549
  const result = parser({
6556
6550
  source: src,
6557
6551
  context
@@ -7267,7 +7261,7 @@ exports.fig = (0, combinator_1.block)((0, combinator_1.rewrite)(exports.segment,
7267
7261
  source,
7268
7262
  context
7269
7263
  }) ? `${fence}figure ${source.replace(/^(.+\n.+\n)([\S\s]+?)\n?$/, '$1\n$2')}\n${fence}` : `${fence}figure ${source}\n\n${fence}`;
7270
- }, (0, combinator_1.union)([figure_1.figure])), ([el]) => el.tagName === 'FIGURE')));
7264
+ }, (0, combinator_1.union)([figure_1.figure]), false), ([el]) => el.tagName === 'FIGURE')));
7271
7265
  const parser = (0, combinator_1.sequence)([(0, combinator_1.line)((0, combinator_1.close)(label_1.segment, /^(?=\s).*\n/)), (0, combinator_1.line)((0, combinator_1.union)([inline_1.media, inline_1.shortmedia])), (0, combinator_1.some)(source_1.contentline)]);
7272
7266
 
7273
7267
  /***/ },
@@ -7318,7 +7312,7 @@ const optspec = {
7318
7312
  rel: undefined
7319
7313
  };
7320
7314
  Object.setPrototypeOf(optspec, null);
7321
- exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(4 /* State.media */, false, (0, combinator_1.validate)(['![', '!{'], (0, combinator_1.creation)(10, (0, combinator_1.open)('!', (0, combinator_1.bind)((0, combinator_1.verify)((0, combinator_1.fmap)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.precedence)(1, (0, combinator_1.some)((0, combinator_1.verify)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ns => ns[0] !== "\u001B" /* Command.Escape */), ']', [['\n', 9]])), ']', true, undefined, undefined, [3 | 4 /* Backtrack.lineescbracket */])), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([link_1.uri, (0, combinator_1.some)(option)]), /^[^\S\n]*}/, false, undefined, undefined, [3 | 24 /* Backtrack.link */]))]), ([as, bs]) => bs ? [[as.join('').trim() || as.join('')], bs] : [[''], as]), ([[text]]) => text === '' || text.trim() !== ''), ([[text], params], rest, context) => {
7315
+ exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(4 /* State.media */, false, (0, combinator_1.validate)(['![', '!{'], (0, combinator_1.creation)(10, (0, combinator_1.open)('!', (0, combinator_1.bind)((0, combinator_1.verify)((0, combinator_1.fmap)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.precedence)(1, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ']', [['\n', 9]])), ']', true, undefined, undefined, [3 | 4 /* Backtrack.lineescbracket */])), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([link_1.uri, (0, combinator_1.some)(option)]), /^[^\S\n]*}/, false, undefined, undefined, [3 | 24 /* Backtrack.link */]))]), ([as, bs]) => bs ? [[as.join('').trim() || as.join('')], bs] : [[''], as]), ([[text]]) => text === '' || text.trim() !== ''), ([[text], params], rest, context) => {
7322
7316
  const INSECURE_URI = params.shift();
7323
7317
  const url = new url_1.ReadonlyURL((0, link_1.resolve)(INSECURE_URI, context.host ?? location, context.url ?? context.host ?? location), context.host?.href || location.href);
7324
7318
  let cache;
@@ -7345,7 +7339,7 @@ exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(4 /* S
7345
7339
  });
7346
7340
  }))))));
7347
7341
  exports.linemedia = (0, combinator_1.surround)(source_1.linebreak, (0, combinator_1.union)([exports.media]), /^(?=[^\S\n]*(?:$|\n))/);
7348
- const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ')'), (0, source_1.str)(')'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], [3 | 4 /* Backtrack.lineescbracket */]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ']'), (0, source_1.str)(']'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], [3 | 4 /* Backtrack.lineescbracket */]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), '}'), (0, source_1.str)('}'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], [3 | 4 /* Backtrack.lineescbracket */]), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, source_1.txt]), '"')), (0, source_1.str)('"'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], [3 | 4 /* Backtrack.lineescbracket */])])));
7342
+ const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ')'), (0, source_1.str)(')'), true, undefined, () => [[], ''], [3 | 4 /* Backtrack.lineescbracket */]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ']'), (0, source_1.str)(']'), true, undefined, () => [[], ''], [3 | 4 /* Backtrack.lineescbracket */]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), '}'), (0, source_1.str)('}'), true, undefined, () => [[], ''], [3 | 4 /* Backtrack.lineescbracket */]), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, source_1.txt]), '"')), (0, source_1.str)('"'), true, undefined, () => [[], ''], [3 | 4 /* Backtrack.lineescbracket */])])));
7349
7343
  const option = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+[1-9][0-9]*x[1-9][0-9]*(?=[^\S\n]|})/), ([opt]) => [` width="${opt.slice(1).split('x')[0]}"`, ` height="${opt.slice(1).split('x')[1]}"`]), (0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+[1-9][0-9]*:[1-9][0-9]*(?=[^\S\n]|})/), ([opt]) => [` aspect-ratio="${opt.slice(1).split(':').join('/')}"`]), link_1.option]));
7350
7344
  function sanitize(target, uri, alt) {
7351
7345
  switch (uri.protocol) {
@@ -8379,7 +8373,7 @@ const dom_1 = __webpack_require__(394);
8379
8373
  // cid: YYYY-MMDD-HHMM-SSmmm
8380
8374
  // 内部表現はUnixTimeに統一する(時系列順)
8381
8375
  // 外部表現は投稿ごとに投稿者の投稿時のタイムゾーンに統一する(非時系列順)
8382
- exports.anchor = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('>>', (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.union)([(0, combinator_1.constraint)(1 /* State.autolink */, false, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.fmap)((0, combinator_1.convert)(source => `[${source}]{ ${source.includes('/') ? `/@${source.slice(2).replace('/', '/timeline?at=')}` : `?at=${source.slice(2)}`} }`, link_1.unsafelink), ([el]) => [(0, dom_1.define)(el, {
8376
+ exports.anchor = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('>>', (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.union)([(0, combinator_1.constraint)(1 /* State.autolink */, false, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.fmap)((0, combinator_1.convert)(source => `[${source}]{ ${source.includes('/') ? `/@${source.slice(2).replace('/', '/timeline?at=')}` : `?at=${source.slice(2)}`} }`, link_1.unsafelink, false), ([el]) => [(0, dom_1.define)(el, {
8383
8377
  class: 'anchor'
8384
8378
  })]))), ({
8385
8379
  source
@@ -8687,7 +8681,7 @@ const link_1 = __webpack_require__(3628);
8687
8681
  const hashtag_1 = __webpack_require__(5764);
8688
8682
  const source_1 = __webpack_require__(8745);
8689
8683
  const dom_1 = __webpack_require__(394);
8690
- exports.hashnum = (0, combinator_1.lazy)(() => (0, combinator_1.rewrite)((0, combinator_1.open)('#', (0, source_1.str)(new RegExp(/^[0-9]{1,9}(?![^\p{C}\p{S}\p{P}\s]|emoji)/u.source.replace(/emoji/, hashtag_1.emoji), 'u'))), (0, combinator_1.union)([(0, combinator_1.constraint)(1 /* State.autolink */, false, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.fmap)((0, combinator_1.convert)(source => `[${source}]{ ${source.slice(1)} }`, link_1.unsafelink), ([el]) => [(0, dom_1.define)(el, {
8684
+ exports.hashnum = (0, combinator_1.lazy)(() => (0, combinator_1.rewrite)((0, combinator_1.open)('#', (0, source_1.str)(new RegExp(/^[0-9]{1,9}(?![^\p{C}\p{S}\p{P}\s]|emoji)/u.source.replace(/emoji/, hashtag_1.emoji), 'u'))), (0, combinator_1.union)([(0, combinator_1.constraint)(1 /* State.autolink */, false, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.fmap)((0, combinator_1.convert)(source => `[${source}]{ ${source.slice(1)} }`, link_1.unsafelink, false), ([el]) => [(0, dom_1.define)(el, {
8691
8685
  class: 'hashnum',
8692
8686
  href: null
8693
8687
  })]))), ({
package/markdown.d.ts CHANGED
@@ -587,53 +587,30 @@ export namespace MarkdownParser {
587
587
  // abc
588
588
  Block<'reply'>,
589
589
  Parser<HTMLParagraphElement, Context, [
590
- Parser<HTMLElement, Context, [
591
- ReplyParser.CiteParser,
592
- ReplyParser.QuoteParser,
593
- ]>,
594
- Parser<HTMLElement | string, Context, [
595
- ReplyParser.QuoteParser,
596
- InlineParser,
597
- ]>,
590
+ ReplyParser.CiteParser,
591
+ ReplyParser.QuoteParser,
592
+ InlineParser,
598
593
  ]> {
599
594
  }
600
595
  export namespace ReplyParser {
601
596
  export interface CiteParser extends
602
597
  Block<'reply/cite'>,
603
598
  Parser<HTMLSpanElement | HTMLBRElement, Context, [
604
- SourceParser.StrParser,
605
- Parser<string | HTMLAnchorElement, Context, [
606
- InlineParser.AutolinkParser.AnchorParser,
607
- Parser<HTMLAnchorElement, Context, []>,
608
- Parser<HTMLAnchorElement, Context, []>,
609
- Parser<HTMLAnchorElement, Context, []>,
610
- ]>,
599
+ InlineParser.AutolinkParser.AnchorParser,
600
+ Parser<HTMLAnchorElement, Context, []>,
601
+ Parser<HTMLAnchorElement, Context, []>,
602
+ Parser<string, Context, []>,
611
603
  ]> {
612
604
  }
613
605
  export interface QuoteParser extends
614
606
  Block<'reply/quote'>,
615
607
  Parser<HTMLSpanElement | HTMLBRElement, Context, [
616
- QuoteParser.BlockParser,
617
- QuoteParser.PlaceholderParser,
608
+ InlineParser.MathParser,
609
+ InlineParser.AutolinkParser,
610
+ SourceParser.LinebreakParser,
611
+ SourceParser.UnescapableSourceParser,
618
612
  ]> {
619
613
  }
620
- export namespace QuoteParser {
621
- export interface BlockParser extends
622
- Block<'reply/quote/block'>,
623
- Parser<string | HTMLElement, Context, [
624
- InlineParser.MathParser,
625
- InlineParser.AutolinkParser,
626
- SourceParser.LinebreakParser,
627
- SourceParser.UnescapableSourceParser,
628
- ]> {
629
- }
630
- export interface PlaceholderParser extends
631
- Block<'reply/quote/placeholder'>,
632
- Parser<string | HTMLElement, Context, [
633
- SourceParser.StrParser,
634
- ]> {
635
- }
636
- }
637
614
  }
638
615
  export interface ParagraphParser extends
639
616
  // abc
@@ -1194,8 +1171,8 @@ export namespace MarkdownParser {
1194
1171
  }
1195
1172
  export interface BracketParser extends
1196
1173
  Inline<'url/bracket'>,
1197
- Parser<string | Command.Escape, Context, [
1198
- Parser<string | Command.Escape, Context, [
1174
+ Parser<string, Context, [
1175
+ Parser<string, Context, [
1199
1176
  BracketParser,
1200
1177
  SourceParser.UnescapableSourceParser,
1201
1178
  ]>,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securemark",
3
- "version": "0.287.0",
3
+ "version": "0.288.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",
@@ -1,15 +1,15 @@
1
1
  import { Parser, Ctx, Context, check } from '../../data/parser';
2
2
 
3
- export function convert<P extends Parser<unknown>>(conv: (source: string, context: Context<P>) => string, parser: P, empty?: boolean): P;
4
- export function convert<T>(conv: (source: string, context: Ctx) => string, parser: Parser<T>, empty = false): Parser<T> {
3
+ export function convert<P extends Parser<unknown>>(conv: (source: string, context: Context<P>) => string, parser: P, continuous: boolean, empty?: boolean): P;
4
+ export function convert<T>(conv: (source: string, context: Ctx) => string, parser: Parser<T>, continuous: boolean, empty = false): Parser<T> {
5
5
  assert(parser);
6
6
  return ({ source, context }) => {
7
7
  if (source === '') return;
8
8
  const src = conv(source, context);
9
9
  if (src === '') return empty ? [[], ''] : undefined;
10
- const sub = source.endsWith(src);
11
10
  const { backtracks } = context;
12
- context.backtracks = sub ? backtracks : {};
11
+ assert(source.endsWith(src) || src.endsWith(source) || !continuous);
12
+ context.backtracks = continuous ? backtracks : {};
13
13
  const result = parser({ source: src, context });
14
14
  assert(check(src, result));
15
15
  context.backtracks = backtracks;
@@ -3,15 +3,15 @@ import { convert } from './convert';
3
3
 
4
4
  export function trim<P extends Parser<unknown>>(parser: P): P;
5
5
  export function trim<T>(parser: Parser<T>): Parser<T> {
6
- return convert(source => source.trim(), parser);
6
+ return convert(source => source.trim(), parser, false);
7
7
  }
8
8
 
9
9
  export function trimStart<P extends Parser<unknown>>(parser: P): P;
10
10
  export function trimStart<T>(parser: Parser<T>): Parser<T> {
11
- return convert(source => source.trimStart(), parser);
11
+ return convert(source => source.trimStart(), parser, true);
12
12
  }
13
13
 
14
14
  export function trimEnd<P extends Parser<unknown>>(parser: P): P;
15
15
  export function trimEnd<T>(parser: Parser<T>): Parser<T> {
16
- return convert(source => source.trimEnd(), parser);
16
+ return convert(source => source.trimEnd(), parser, false);
17
17
  }
@@ -6,8 +6,10 @@ describe('Unit: parser/autolink', () => {
6
6
  const parser = (source: string) => autolink({ source, context: {} });
7
7
 
8
8
  it('basic', () => {
9
- assert.deepStrictEqual(inspect(parser('http://host#\\')), [['<a class="url" href="http://host#\\" target="_blank">http://host#\\</a>'], '']);
10
- assert.deepStrictEqual(inspect(parser('!http://host#\\')), [['!', '<a class="url" href="http://host#\\" target="_blank">http://host#\\</a>'], '']);
9
+ assert.deepStrictEqual(inspect(parser('http://host)')), [['<a class="url" href="http://host)" target="_blank">http://host)</a>'], '']);
10
+ assert.deepStrictEqual(inspect(parser('http://host\\')), [['<a class="url" href="http://host\\" target="_blank">http://host\\</a>'], '']);
11
+ assert.deepStrictEqual(inspect(parser('!http://host)')), [['!', '<a class="url" href="http://host)" target="_blank">http://host)</a>'], '']);
12
+ assert.deepStrictEqual(inspect(parser('!http://host\\')), [['!', '<a class="url" href="http://host\\" target="_blank">http://host\\</a>'], '']);
11
13
  assert.deepStrictEqual(inspect(parser('#a')), [['<a class="hashtag" href="/hashtags/a">#a</a>'], '']);
12
14
  assert.deepStrictEqual(inspect(parser('@a#b')), [['<a class="channel" href="/@a?ch=b">@a#b</a>'], '']);
13
15
  assert.deepStrictEqual(inspect(parser('\\\n')), [['\\', '<br>'], '']);
@@ -11,4 +11,5 @@ export const autolink: AutolinkParser = lazy(() =>
11
11
  autolink_,
12
12
  linebreak,
13
13
  unescsource,
14
- ]))));
14
+ ])),
15
+ false));
@@ -41,7 +41,9 @@ describe('Unit: parser/block/blockquote', () => {
41
41
  assert.deepStrictEqual(inspect(parser('>\n>')), [['<blockquote><pre><br></pre></blockquote>'], '']);
42
42
  assert.deepStrictEqual(inspect(parser('>\n> a')), [['<blockquote><pre><br>a</pre></blockquote>'], '']);
43
43
  assert.deepStrictEqual(inspect(parser('> http://host')), [['<blockquote><pre><a class="url" href="http://host" target="_blank">http://host</a></pre></blockquote>'], '']);
44
+ assert.deepStrictEqual(inspect(parser('> http://host)')), [['<blockquote><pre><a class="url" href="http://host)" target="_blank">http://host)</a></pre></blockquote>'], '']);
44
45
  assert.deepStrictEqual(inspect(parser('> !http://host')), [['<blockquote><pre>!<a class="url" href="http://host" target="_blank">http://host</a></pre></blockquote>'], '']);
46
+ assert.deepStrictEqual(inspect(parser('> !http://host)')), [['<blockquote><pre>!<a class="url" href="http://host)" target="_blank">http://host)</a></pre></blockquote>'], '']);
45
47
  assert.deepStrictEqual(inspect(parser('> #a')), [['<blockquote><pre><a class="hashtag" href="/hashtags/a">#a</a></pre></blockquote>'], '']);
46
48
  assert.deepStrictEqual(inspect(parser('> @a#b')), [['<blockquote><pre><a class="channel" href="/@a?ch=b">@a#b</a></pre></blockquote>'], '']);
47
49
  assert.deepStrictEqual(inspect(parser('> >>1\n> > b')), [['<blockquote><pre><a class="anchor" href="?at=1">&gt;&gt;1</a><br>&gt; b</pre></blockquote>'], '']);
@@ -23,10 +23,10 @@ const source: BlockquoteParser.SourceParser = lazy(() => fmap(
23
23
  some(recursion(Recursion.blockquote, union([
24
24
  rewrite(
25
25
  indent,
26
- convert(unindent, source, true)),
26
+ convert(unindent, source, false, true)),
27
27
  rewrite(
28
28
  some(contentline, opener),
29
- convert(unindent, fmap(autolink, ns => [html('pre', defrag(ns))]), true)),
29
+ convert(unindent, fmap(autolink, ns => [html('pre', defrag(ns))]), false, true)),
30
30
  ]))),
31
31
  ns => [html('blockquote', ns)]));
32
32
 
@@ -34,7 +34,7 @@ const markdown: BlockquoteParser.MarkdownParser = lazy(() => fmap(
34
34
  some(recursion(Recursion.blockquote, union([
35
35
  rewrite(
36
36
  indent,
37
- convert(unindent, markdown, true)),
37
+ convert(unindent, markdown, false, true)),
38
38
  creation(10,
39
39
  rewrite(
40
40
  some(contentline, opener),
@@ -47,6 +47,6 @@ const markdown: BlockquoteParser.MarkdownParser = lazy(() => fmap(
47
47
  },
48
48
  }, context);
49
49
  return [[html('section', [document, html('h2', 'References'), references])], ''];
50
- }, true))),
50
+ }, false, true))),
51
51
  ]))),
52
52
  ns => [html('blockquote', ns)]));
@@ -38,7 +38,9 @@ describe('Unit: parser/block/codeblock', () => {
38
38
  assert.deepStrictEqual(inspect(parser('````\n```\n\n````')), [['<pre class="text">```<br></pre>'], '']);
39
39
  assert.deepStrictEqual(inspect(parser('```\n\n```\n')), [['<pre class="text"></pre>'], '']);
40
40
  assert.deepStrictEqual(inspect(parser('```\nhttp://host\n```')), [['<pre class="text"><a class="url" href="http://host" target="_blank">http://host</a></pre>'], '']);
41
+ assert.deepStrictEqual(inspect(parser('```\nhttp://host)\n```')), [['<pre class="text"><a class="url" href="http://host)" target="_blank">http://host)</a></pre>'], '']);
41
42
  assert.deepStrictEqual(inspect(parser('```\n!http://host\n```')), [['<pre class="text">!<a class="url" href="http://host" target="_blank">http://host</a></pre>'], '']);
43
+ assert.deepStrictEqual(inspect(parser('```\n!http://host)\n```')), [['<pre class="text">!<a class="url" href="http://host)" target="_blank">http://host)</a></pre>'], '']);
42
44
  assert.deepStrictEqual(inspect(parser('```\n#a\n```')), [['<pre class="text"><a class="hashtag" href="/hashtags/a">#a</a></pre>'], '']);
43
45
  assert.deepStrictEqual(inspect(parser('```\n@a#b\n```')), [['<pre class="text"><a class="channel" href="/@a?ch=b">@a#b</a></pre>'], '']);
44
46
  assert.deepStrictEqual(inspect(parser(`\`\`\`\n0${'\n'.repeat(300)}\`\`\``), '>'), [['<pre class="text">'], '']);
@@ -34,7 +34,8 @@ export const fig: FigParser = block(rewrite(segment, verify(convert(
34
34
  ? `${fence}figure ${source.replace(/^(.+\n.+\n)([\S\s]+?)\n?$/, '$1\n$2')}\n${fence}`
35
35
  : `${fence}figure ${source}\n\n${fence}`;
36
36
  },
37
- union([figure])),
37
+ union([figure]),
38
+ false),
38
39
  ([el]) => el.tagName === 'FIGURE')));
39
40
 
40
41
  const parser = sequence([