securemark 0.259.1 → 0.259.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/design.md +2 -1
- package/dist/index.js +427 -154
- package/package.json +1 -1
- package/src/combinator/control/constraint/block.test.ts +5 -5
- package/src/combinator/control/constraint/block.ts +3 -2
- package/src/combinator/control/constraint/contract.ts +7 -5
- package/src/combinator/control/constraint/line.test.ts +6 -6
- package/src/combinator/control/constraint/line.ts +6 -5
- package/src/combinator/control/manipulation/convert.ts +6 -5
- package/src/combinator/control/manipulation/fence.ts +2 -1
- package/src/combinator/control/manipulation/indent.test.ts +14 -14
- package/src/combinator/control/manipulation/indent.ts +5 -5
- package/src/combinator/control/manipulation/lazy.ts +2 -2
- package/src/combinator/control/manipulation/match.ts +3 -2
- package/src/combinator/control/manipulation/recovery.ts +6 -6
- package/src/combinator/control/manipulation/scope.ts +13 -10
- package/src/combinator/control/manipulation/surround.ts +9 -8
- package/src/combinator/control/manipulation/trim.test.ts +9 -9
- package/src/combinator/control/monad/bind.ts +3 -2
- package/src/combinator/data/parser/context/memo.ts +3 -4
- package/src/combinator/data/parser/context.test.ts +9 -9
- package/src/combinator/data/parser/context.ts +23 -18
- package/src/combinator/data/parser/inits.ts +3 -2
- package/src/combinator/data/parser/sequence.test.ts +10 -10
- package/src/combinator/data/parser/sequence.ts +3 -2
- package/src/combinator/data/parser/some.test.ts +13 -13
- package/src/combinator/data/parser/some.ts +3 -2
- package/src/combinator/data/parser/subsequence.test.ts +14 -14
- package/src/combinator/data/parser/union.test.ts +10 -10
- package/src/combinator/data/parser/union.ts +2 -2
- package/src/combinator/data/parser.ts +6 -1
- package/src/parser/api/bind.ts +1 -1
- package/src/parser/api/header.ts +1 -1
- package/src/parser/api/normalize.ts +1 -1
- package/src/parser/api/parse.ts +1 -1
- package/src/parser/autolink.test.ts +1 -1
- package/src/parser/autolink.ts +2 -2
- package/src/parser/block/blockquote.test.ts +1 -1
- package/src/parser/block/blockquote.ts +1 -1
- package/src/parser/block/codeblock.test.ts +1 -1
- package/src/parser/block/codeblock.ts +1 -1
- package/src/parser/block/dlist.test.ts +1 -1
- package/src/parser/block/extension/aside.test.ts +1 -1
- package/src/parser/block/extension/example.test.ts +1 -1
- package/src/parser/block/extension/example.ts +1 -1
- package/src/parser/block/extension/fig.test.ts +1 -1
- package/src/parser/block/extension/figbase.test.ts +1 -1
- package/src/parser/block/extension/figure.test.ts +1 -1
- package/src/parser/block/extension/figure.ts +1 -1
- package/src/parser/block/extension/message.test.ts +1 -1
- package/src/parser/block/extension/message.ts +1 -1
- package/src/parser/block/extension/placeholder.test.ts +1 -1
- package/src/parser/block/extension/table.test.ts +1 -1
- package/src/parser/block/extension/table.ts +1 -1
- package/src/parser/block/extension.test.ts +1 -1
- package/src/parser/block/heading.test.ts +3 -3
- package/src/parser/block/heading.ts +1 -1
- package/src/parser/block/horizontalrule.test.ts +1 -1
- package/src/parser/block/ilist.test.ts +1 -1
- package/src/parser/block/mathblock.test.ts +1 -1
- package/src/parser/block/olist.test.ts +1 -1
- package/src/parser/block/olist.ts +5 -5
- package/src/parser/block/paragraph.test.ts +1 -1
- package/src/parser/block/reply/cite.test.ts +1 -1
- package/src/parser/block/reply/cite.ts +2 -2
- package/src/parser/block/reply/quote.test.ts +1 -1
- package/src/parser/block/reply/quote.ts +2 -2
- package/src/parser/block/reply.test.ts +1 -1
- package/src/parser/block/sidefence.test.ts +1 -1
- package/src/parser/block/table.test.ts +1 -1
- package/src/parser/block/table.ts +1 -1
- package/src/parser/block/ulist.test.ts +1 -1
- package/src/parser/block/ulist.ts +1 -1
- package/src/parser/block.ts +2 -2
- package/src/parser/header.test.ts +1 -1
- package/src/parser/header.ts +3 -3
- package/src/parser/inline/annotation.test.ts +1 -1
- package/src/parser/inline/autolink/account.test.ts +1 -1
- package/src/parser/inline/autolink/anchor.test.ts +1 -1
- package/src/parser/inline/autolink/channel.test.ts +1 -1
- package/src/parser/inline/autolink/email.test.ts +1 -1
- package/src/parser/inline/autolink/email.ts +1 -1
- package/src/parser/inline/autolink/hashnum.test.ts +1 -1
- package/src/parser/inline/autolink/hashtag.test.ts +1 -1
- package/src/parser/inline/autolink/url.test.ts +1 -1
- package/src/parser/inline/bracket.test.ts +1 -1
- package/src/parser/inline/code.test.ts +1 -1
- package/src/parser/inline/code.ts +2 -2
- package/src/parser/inline/comment.test.ts +1 -1
- package/src/parser/inline/deletion.test.ts +1 -1
- package/src/parser/inline/emphasis.test.ts +1 -1
- package/src/parser/inline/emstrong.ts +2 -2
- package/src/parser/inline/escape.ts +3 -3
- package/src/parser/inline/extension/index.test.ts +1 -1
- package/src/parser/inline/extension/indexer.test.ts +1 -1
- package/src/parser/inline/extension/label.test.ts +1 -1
- package/src/parser/inline/extension/placeholder.test.ts +1 -1
- package/src/parser/inline/html.test.ts +1 -1
- package/src/parser/inline/htmlentity.test.ts +1 -1
- package/src/parser/inline/htmlentity.ts +1 -1
- package/src/parser/inline/insertion.test.ts +1 -1
- package/src/parser/inline/link.test.ts +1 -1
- package/src/parser/inline/link.ts +1 -1
- package/src/parser/inline/mark.test.ts +1 -1
- package/src/parser/inline/math.test.ts +1 -1
- package/src/parser/inline/math.ts +1 -1
- package/src/parser/inline/media.test.ts +1 -1
- package/src/parser/inline/media.ts +2 -2
- package/src/parser/inline/reference.test.ts +1 -1
- package/src/parser/inline/ruby.test.ts +1 -1
- package/src/parser/inline/ruby.ts +3 -3
- package/src/parser/inline/shortmedia.test.ts +1 -1
- package/src/parser/inline/strong.test.ts +1 -1
- package/src/parser/inline/template.test.ts +1 -1
- package/src/parser/inline.test.ts +1 -1
- package/src/parser/locale.test.ts +1 -1
- package/src/parser/segment.ts +1 -1
- package/src/parser/source/escapable.test.ts +1 -1
- package/src/parser/source/escapable.ts +1 -1
- package/src/parser/source/line.test.ts +1 -1
- package/src/parser/source/line.ts +2 -2
- package/src/parser/source/str.ts +4 -4
- package/src/parser/source/text.test.ts +1 -1
- package/src/parser/source/text.ts +3 -3
- package/src/parser/source/unescapable.test.ts +1 -1
- package/src/parser/source/unescapable.ts +1 -1
- package/src/parser/visibility.ts +13 -13
- package/src/util/quote.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.259.
|
|
1
|
+
/*! securemark v0.259.2 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
|
|
2
2
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
3
3
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
4
4
|
module.exports = factory(require("DOMPurify"), require("Prism"));
|
|
@@ -2129,10 +2129,14 @@ const memo_1 = __webpack_require__(1090);
|
|
|
2129
2129
|
const line_1 = __webpack_require__(9315);
|
|
2130
2130
|
|
|
2131
2131
|
function block(parser, separation = true) {
|
|
2132
|
-
return
|
|
2132
|
+
return input => {
|
|
2133
|
+
const {
|
|
2134
|
+
source,
|
|
2135
|
+
context
|
|
2136
|
+
} = input;
|
|
2133
2137
|
if (source === '') return;
|
|
2134
2138
|
context.memo ??= new memo_1.Memo();
|
|
2135
|
-
const result = parser(
|
|
2139
|
+
const result = parser(input);
|
|
2136
2140
|
if (!result) return;
|
|
2137
2141
|
const rest = (0, parser_1.exec)(result);
|
|
2138
2142
|
if (separation && !(0, line_1.isEmpty)((0, line_1.firstline)(rest))) return;
|
|
@@ -2165,10 +2169,13 @@ function validate(patterns, has, parser) {
|
|
|
2165
2169
|
if (typeof has === 'function') return validate(patterns, '', has);
|
|
2166
2170
|
if (!(0, alias_1.isArray)(patterns)) return validate([patterns], has, parser);
|
|
2167
2171
|
const match = (0, global_1.Function)(['"use strict";', 'return source =>', '0', ...patterns.map(pattern => typeof pattern === 'string' ? `|| source.slice(0, ${pattern.length}) === '${pattern}'` : `|| /${pattern.source}/${pattern.flags}.test(source)`)].join(''))();
|
|
2168
|
-
return
|
|
2172
|
+
return input => {
|
|
2173
|
+
const {
|
|
2174
|
+
source
|
|
2175
|
+
} = input;
|
|
2169
2176
|
if (source === '') return;
|
|
2170
2177
|
if (!match(source)) return;
|
|
2171
|
-
const result = parser(
|
|
2178
|
+
const result = parser(input);
|
|
2172
2179
|
if (!result) return;
|
|
2173
2180
|
return (0, parser_1.exec)(result).length < source.length ? result : global_1.undefined;
|
|
2174
2181
|
};
|
|
@@ -2177,11 +2184,14 @@ function validate(patterns, has, parser) {
|
|
|
2177
2184
|
exports.validate = validate;
|
|
2178
2185
|
|
|
2179
2186
|
function verify(parser, cond) {
|
|
2180
|
-
return
|
|
2187
|
+
return input => {
|
|
2188
|
+
const {
|
|
2189
|
+
source
|
|
2190
|
+
} = input;
|
|
2181
2191
|
if (source === '') return;
|
|
2182
|
-
const result = parser(
|
|
2192
|
+
const result = parser(input);
|
|
2183
2193
|
if (!result) return;
|
|
2184
|
-
if (!cond((0, parser_1.eval)(result), (0, parser_1.exec)(result), context)) return;
|
|
2194
|
+
if (!cond((0, parser_1.eval)(result), (0, parser_1.exec)(result), input.context)) return;
|
|
2185
2195
|
return (0, parser_1.exec)(result).length < source.length ? result : global_1.undefined;
|
|
2186
2196
|
};
|
|
2187
2197
|
}
|
|
@@ -2208,14 +2218,21 @@ const parser_1 = __webpack_require__(6728);
|
|
|
2208
2218
|
const memo_1 = __webpack_require__(1090);
|
|
2209
2219
|
|
|
2210
2220
|
function line(parser) {
|
|
2211
|
-
return
|
|
2221
|
+
return input => {
|
|
2222
|
+
const {
|
|
2223
|
+
source,
|
|
2224
|
+
context
|
|
2225
|
+
} = input;
|
|
2212
2226
|
if (source === '') return;
|
|
2213
2227
|
context.memo ??= new memo_1.Memo();
|
|
2214
2228
|
const line = firstline(source);
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
const result = parser(
|
|
2218
|
-
|
|
2229
|
+
context.offset ??= 0;
|
|
2230
|
+
context.offset += source.length - line.length;
|
|
2231
|
+
const result = parser({
|
|
2232
|
+
source: line,
|
|
2233
|
+
context
|
|
2234
|
+
});
|
|
2235
|
+
context.offset -= source.length - line.length;
|
|
2219
2236
|
if (!result) return;
|
|
2220
2237
|
return isEmpty((0, parser_1.exec)(result)) ? [(0, parser_1.eval)(result), source.slice(line.length)] : global_1.undefined;
|
|
2221
2238
|
};
|
|
@@ -2262,14 +2279,21 @@ exports.convert = void 0;
|
|
|
2262
2279
|
const parser_1 = __webpack_require__(6728);
|
|
2263
2280
|
|
|
2264
2281
|
function convert(conv, parser) {
|
|
2265
|
-
return
|
|
2282
|
+
return input => {
|
|
2283
|
+
const {
|
|
2284
|
+
source,
|
|
2285
|
+
context
|
|
2286
|
+
} = input;
|
|
2266
2287
|
if (source === '') return;
|
|
2267
2288
|
const src = conv(source);
|
|
2268
2289
|
if (src === '') return [[], ''];
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
const result = parser(
|
|
2272
|
-
|
|
2290
|
+
context.offset ??= 0;
|
|
2291
|
+
context.offset += source.length - src.length;
|
|
2292
|
+
const result = parser({
|
|
2293
|
+
source: src,
|
|
2294
|
+
context
|
|
2295
|
+
});
|
|
2296
|
+
context.offset -= source.length - src.length;
|
|
2273
2297
|
return result;
|
|
2274
2298
|
};
|
|
2275
2299
|
}
|
|
@@ -2336,7 +2360,10 @@ const line_1 = __webpack_require__(9315);
|
|
|
2336
2360
|
const array_1 = __webpack_require__(8112);
|
|
2337
2361
|
|
|
2338
2362
|
function fence(opener, limit, separation = true) {
|
|
2339
|
-
return
|
|
2363
|
+
return input => {
|
|
2364
|
+
const {
|
|
2365
|
+
source
|
|
2366
|
+
} = input;
|
|
2340
2367
|
if (source === '') return;
|
|
2341
2368
|
const matches = source.match(opener);
|
|
2342
2369
|
if (!matches) return;
|
|
@@ -2420,11 +2447,16 @@ const memoize_1 = __webpack_require__(1808);
|
|
|
2420
2447
|
|
|
2421
2448
|
function indent(opener, parser, separation = false) {
|
|
2422
2449
|
if (typeof opener === 'function') return indent(/^([ \t])\1*/, opener, parser);
|
|
2423
|
-
return (0, bind_1.bind)((0, block_1.block)((0, match_1.match)(opener, (0, memoize_1.memoize)(([indent]) => (0, some_1.some)((0, line_1.line)((0, surround_1.open)(indent,
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2450
|
+
return (0, bind_1.bind)((0, block_1.block)((0, match_1.match)(opener, (0, memoize_1.memoize)(([indent]) => (0, some_1.some)((0, line_1.line)((0, surround_1.open)(indent, ({
|
|
2451
|
+
source
|
|
2452
|
+
}) => [[source], '']))), ([indent]) => indent.length * 2 + +(indent[0] === ' '), [])), separation), (lines, rest, context) => {
|
|
2453
|
+
context.offset ??= 0;
|
|
2454
|
+
context.offset += rest.length;
|
|
2455
|
+
const result = parser({
|
|
2456
|
+
source: trimBlockEnd(lines.join('')),
|
|
2457
|
+
context
|
|
2458
|
+
});
|
|
2459
|
+
context.offset -= rest.length;
|
|
2428
2460
|
return result && (0, parser_1.exec)(result) === '' ? [(0, parser_1.eval)(result), rest] : global_1.undefined;
|
|
2429
2461
|
});
|
|
2430
2462
|
}
|
|
@@ -2450,7 +2482,7 @@ exports.lazy = void 0;
|
|
|
2450
2482
|
|
|
2451
2483
|
function lazy(builder) {
|
|
2452
2484
|
let parser;
|
|
2453
|
-
return
|
|
2485
|
+
return input => (parser ??= builder())(input);
|
|
2454
2486
|
}
|
|
2455
2487
|
|
|
2456
2488
|
exports.lazy = lazy;
|
|
@@ -2473,11 +2505,14 @@ const global_1 = __webpack_require__(4128);
|
|
|
2473
2505
|
const parser_1 = __webpack_require__(6728);
|
|
2474
2506
|
|
|
2475
2507
|
function match(pattern, f) {
|
|
2476
|
-
return
|
|
2508
|
+
return input => {
|
|
2509
|
+
const {
|
|
2510
|
+
source
|
|
2511
|
+
} = input;
|
|
2477
2512
|
if (source === '') return;
|
|
2478
2513
|
const param = source.match(pattern);
|
|
2479
2514
|
if (!param) return;
|
|
2480
|
-
const result = f(param)(
|
|
2515
|
+
const result = f(param)(input);
|
|
2481
2516
|
if (!result) return;
|
|
2482
2517
|
return (0, parser_1.exec)(result).length < source.length && (0, parser_1.exec)(result).length <= source.length ? result : global_1.undefined;
|
|
2483
2518
|
};
|
|
@@ -2499,11 +2534,11 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
2499
2534
|
exports.recover = void 0;
|
|
2500
2535
|
|
|
2501
2536
|
function recover(parser, fallback) {
|
|
2502
|
-
return
|
|
2537
|
+
return input => {
|
|
2503
2538
|
try {
|
|
2504
|
-
return parser(
|
|
2539
|
+
return parser(input);
|
|
2505
2540
|
} catch (reason) {
|
|
2506
|
-
return fallback(
|
|
2541
|
+
return fallback(input, reason);
|
|
2507
2542
|
}
|
|
2508
2543
|
};
|
|
2509
2544
|
}
|
|
@@ -2550,14 +2585,21 @@ const parser_1 = __webpack_require__(6728);
|
|
|
2550
2585
|
|
|
2551
2586
|
function focus(scope, parser) {
|
|
2552
2587
|
const match = typeof scope === 'string' ? source => source.slice(0, scope.length) === scope ? scope : '' : source => source.match(scope)?.[0] ?? '';
|
|
2553
|
-
return
|
|
2588
|
+
return input => {
|
|
2589
|
+
const {
|
|
2590
|
+
source,
|
|
2591
|
+
context
|
|
2592
|
+
} = input;
|
|
2554
2593
|
if (source === '') return;
|
|
2555
2594
|
const src = match(source);
|
|
2556
2595
|
if (src === '') return;
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
const result = parser(
|
|
2560
|
-
|
|
2596
|
+
context.offset ??= 0;
|
|
2597
|
+
context.offset += source.length - src.length;
|
|
2598
|
+
const result = parser({
|
|
2599
|
+
source: src,
|
|
2600
|
+
context
|
|
2601
|
+
});
|
|
2602
|
+
context.offset -= source.length - src.length;
|
|
2561
2603
|
if (!result) return;
|
|
2562
2604
|
return (0, parser_1.exec)(result).length < src.length ? [(0, parser_1.eval)(result), (0, parser_1.exec)(result) + source.slice(src.length)] : global_1.undefined;
|
|
2563
2605
|
};
|
|
@@ -2566,17 +2608,25 @@ function focus(scope, parser) {
|
|
|
2566
2608
|
exports.focus = focus;
|
|
2567
2609
|
|
|
2568
2610
|
function rewrite(scope, parser) {
|
|
2569
|
-
return
|
|
2611
|
+
return input => {
|
|
2612
|
+
const {
|
|
2613
|
+
source,
|
|
2614
|
+
context
|
|
2615
|
+
} = input;
|
|
2570
2616
|
if (source === '') return;
|
|
2571
2617
|
const memo = context.memo;
|
|
2572
2618
|
context.memo = global_1.undefined;
|
|
2573
|
-
const res1 = scope(
|
|
2619
|
+
const res1 = scope(input);
|
|
2574
2620
|
context.memo = memo;
|
|
2575
2621
|
if (!res1 || (0, parser_1.exec)(res1).length >= source.length) return;
|
|
2576
2622
|
const src = source.slice(0, source.length - (0, parser_1.exec)(res1).length);
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2623
|
+
context.offset ??= 0;
|
|
2624
|
+
context.offset += source.length - src.length;
|
|
2625
|
+
const res2 = parser({
|
|
2626
|
+
source: src,
|
|
2627
|
+
context
|
|
2628
|
+
});
|
|
2629
|
+
context.offset -= source.length - src.length;
|
|
2580
2630
|
if (!res2) return;
|
|
2581
2631
|
return (0, parser_1.exec)(res2).length < src.length ? [(0, parser_1.eval)(res2), (0, parser_1.exec)(res2) + (0, parser_1.exec)(res1)] : global_1.undefined;
|
|
2582
2632
|
};
|
|
@@ -2618,17 +2668,30 @@ function surround(opener, parser, closer, optional = false, f, g) {
|
|
|
2618
2668
|
return surround(opener, parser, match(closer), optional, f, g);
|
|
2619
2669
|
}
|
|
2620
2670
|
|
|
2621
|
-
return
|
|
2671
|
+
return input => {
|
|
2672
|
+
const {
|
|
2673
|
+
source: lmr_,
|
|
2674
|
+
context
|
|
2675
|
+
} = input;
|
|
2622
2676
|
if (lmr_ === '') return;
|
|
2623
|
-
const res1 = opener(
|
|
2677
|
+
const res1 = opener({
|
|
2678
|
+
source: lmr_,
|
|
2679
|
+
context
|
|
2680
|
+
});
|
|
2624
2681
|
if (!res1) return;
|
|
2625
2682
|
const rl = (0, parser_1.eval)(res1);
|
|
2626
2683
|
const mr_ = (0, parser_1.exec)(res1);
|
|
2627
|
-
const res2 = mr_ !== '' ? parser(
|
|
2684
|
+
const res2 = mr_ !== '' ? parser({
|
|
2685
|
+
source: mr_,
|
|
2686
|
+
context
|
|
2687
|
+
}) : global_1.undefined;
|
|
2628
2688
|
const rm = (0, parser_1.eval)(res2);
|
|
2629
2689
|
const r_ = (0, parser_1.exec)(res2, mr_);
|
|
2630
2690
|
if (!rm && !optional) return;
|
|
2631
|
-
const res3 = closer(
|
|
2691
|
+
const res3 = closer({
|
|
2692
|
+
source: r_,
|
|
2693
|
+
context
|
|
2694
|
+
});
|
|
2632
2695
|
const rr = (0, parser_1.eval)(res3);
|
|
2633
2696
|
const rest = (0, parser_1.exec)(res3, r_);
|
|
2634
2697
|
if (rest.length === lmr_.length) return;
|
|
@@ -2641,10 +2704,14 @@ exports.surround = surround;
|
|
|
2641
2704
|
function match(pattern) {
|
|
2642
2705
|
switch (typeof pattern) {
|
|
2643
2706
|
case 'string':
|
|
2644
|
-
return
|
|
2707
|
+
return ({
|
|
2708
|
+
source
|
|
2709
|
+
}) => source.slice(0, pattern.length) === pattern ? [[], source.slice(pattern.length)] : global_1.undefined;
|
|
2645
2710
|
|
|
2646
2711
|
case 'object':
|
|
2647
|
-
return
|
|
2712
|
+
return ({
|
|
2713
|
+
source
|
|
2714
|
+
}) => {
|
|
2648
2715
|
const m = source.match(pattern);
|
|
2649
2716
|
return m ? [[], source.slice(m[0].length)] : global_1.undefined;
|
|
2650
2717
|
};
|
|
@@ -2720,9 +2787,13 @@ const global_1 = __webpack_require__(4128);
|
|
|
2720
2787
|
const parser_1 = __webpack_require__(6728);
|
|
2721
2788
|
|
|
2722
2789
|
function bind(parser, f) {
|
|
2723
|
-
return
|
|
2790
|
+
return input => {
|
|
2791
|
+
const {
|
|
2792
|
+
source,
|
|
2793
|
+
context
|
|
2794
|
+
} = input;
|
|
2724
2795
|
if (source === '') return;
|
|
2725
|
-
const res1 = parser(
|
|
2796
|
+
const res1 = parser(input);
|
|
2726
2797
|
if (!res1) return;
|
|
2727
2798
|
const res2 = f((0, parser_1.eval)(res1), (0, parser_1.exec)(res1), context);
|
|
2728
2799
|
if (!res2) return;
|
|
@@ -2808,7 +2879,10 @@ const memo_1 = __webpack_require__(1090);
|
|
|
2808
2879
|
function reset(base, parser) {
|
|
2809
2880
|
const changes = global_1.Object.entries(base);
|
|
2810
2881
|
const values = (0, global_1.Array)(changes.length);
|
|
2811
|
-
return (
|
|
2882
|
+
return ({
|
|
2883
|
+
source,
|
|
2884
|
+
context
|
|
2885
|
+
}) => apply(parser, source, (0, alias_1.ObjectCreate)(context), changes, values);
|
|
2812
2886
|
}
|
|
2813
2887
|
|
|
2814
2888
|
exports.reset = reset;
|
|
@@ -2816,7 +2890,10 @@ exports.reset = reset;
|
|
|
2816
2890
|
function context(base, parser) {
|
|
2817
2891
|
const changes = global_1.Object.entries(base);
|
|
2818
2892
|
const values = (0, global_1.Array)(changes.length);
|
|
2819
|
-
return (
|
|
2893
|
+
return ({
|
|
2894
|
+
source,
|
|
2895
|
+
context
|
|
2896
|
+
}) => apply(parser, source, context, changes, values);
|
|
2820
2897
|
}
|
|
2821
2898
|
|
|
2822
2899
|
exports.context = context;
|
|
@@ -2838,7 +2915,10 @@ function apply(parser, source, context, changes, values) {
|
|
|
2838
2915
|
context[prop] = change[1];
|
|
2839
2916
|
}
|
|
2840
2917
|
}
|
|
2841
|
-
const result = parser(
|
|
2918
|
+
const result = parser({
|
|
2919
|
+
source,
|
|
2920
|
+
context
|
|
2921
|
+
});
|
|
2842
2922
|
if (context) for (let i = 0; i < changes.length; ++i) {
|
|
2843
2923
|
const change = changes[i];
|
|
2844
2924
|
const prop = change[0];
|
|
@@ -2856,15 +2936,20 @@ function apply(parser, source, context, changes, values) {
|
|
|
2856
2936
|
}
|
|
2857
2937
|
|
|
2858
2938
|
function syntax(syntax, prec, cost, state, parser) {
|
|
2859
|
-
return creation(cost, precedence(prec,
|
|
2939
|
+
return creation(cost, precedence(prec, input => {
|
|
2940
|
+
const {
|
|
2941
|
+
source,
|
|
2942
|
+
context
|
|
2943
|
+
} = input;
|
|
2860
2944
|
if (source === '') return;
|
|
2861
2945
|
const memo = context.memo ??= new memo_1.Memo();
|
|
2862
2946
|
context.memorable ??= ~0;
|
|
2863
|
-
|
|
2947
|
+
context.offset ??= 0;
|
|
2948
|
+
const position = source.length + context.offset;
|
|
2864
2949
|
const st0 = context.state ?? 0;
|
|
2865
2950
|
const st1 = context.state = st0 | state;
|
|
2866
2951
|
const cache = syntax && memo.get(position, syntax, st1);
|
|
2867
|
-
const result = cache ? cache.length === 0 ? global_1.undefined : [cache[0], source.slice(cache[1])] : parser(
|
|
2952
|
+
const result = cache ? cache.length === 0 ? global_1.undefined : [cache[0], source.slice(cache[1])] : parser(input);
|
|
2868
2953
|
|
|
2869
2954
|
if (syntax && st0 & context.memorable) {
|
|
2870
2955
|
cache ?? memo.set(position, syntax, st1, (0, parser_1.eval)(result), source.length - (0, parser_1.exec)(result, '').length);
|
|
@@ -2883,17 +2968,15 @@ exports.syntax = syntax;
|
|
|
2883
2968
|
|
|
2884
2969
|
function creation(cost, parser) {
|
|
2885
2970
|
if (typeof cost === 'function') return creation(1, cost);
|
|
2886
|
-
return
|
|
2887
|
-
const {
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
}
|
|
2892
|
-
} = context;
|
|
2971
|
+
return input => {
|
|
2972
|
+
const resources = input.context.resources ?? {
|
|
2973
|
+
clock: 1,
|
|
2974
|
+
recursion: 1
|
|
2975
|
+
};
|
|
2893
2976
|
if (resources.clock <= 0) throw new Error('Too many creations');
|
|
2894
2977
|
if (resources.recursion <= 0) throw new Error('Too much recursion');
|
|
2895
2978
|
--resources.recursion;
|
|
2896
|
-
const result = parser(
|
|
2979
|
+
const result = parser(input);
|
|
2897
2980
|
++resources.recursion;
|
|
2898
2981
|
|
|
2899
2982
|
if (result) {
|
|
@@ -2907,10 +2990,13 @@ function creation(cost, parser) {
|
|
|
2907
2990
|
exports.creation = creation;
|
|
2908
2991
|
|
|
2909
2992
|
function precedence(precedence, parser) {
|
|
2910
|
-
return
|
|
2993
|
+
return input => {
|
|
2994
|
+
const {
|
|
2995
|
+
context
|
|
2996
|
+
} = input;
|
|
2911
2997
|
const p = context.precedence;
|
|
2912
2998
|
context.precedence = precedence;
|
|
2913
|
-
const result = parser(
|
|
2999
|
+
const result = parser(input);
|
|
2914
3000
|
context.precedence = p;
|
|
2915
3001
|
return result;
|
|
2916
3002
|
};
|
|
@@ -2919,7 +3005,7 @@ function precedence(precedence, parser) {
|
|
|
2919
3005
|
exports.precedence = precedence;
|
|
2920
3006
|
|
|
2921
3007
|
function guard(f, parser) {
|
|
2922
|
-
return
|
|
3008
|
+
return input => f(input.context) ? parser(input) : global_1.undefined;
|
|
2923
3009
|
}
|
|
2924
3010
|
|
|
2925
3011
|
exports.guard = guard;
|
|
@@ -2930,9 +3016,12 @@ function constraint(state, positive, parser) {
|
|
|
2930
3016
|
positive = true;
|
|
2931
3017
|
}
|
|
2932
3018
|
|
|
2933
|
-
return
|
|
3019
|
+
return input => {
|
|
3020
|
+
const {
|
|
3021
|
+
context
|
|
3022
|
+
} = input;
|
|
2934
3023
|
const s = positive ? state & context.state : state & ~context.state;
|
|
2935
|
-
return s === state ? parser(
|
|
3024
|
+
return s === state ? parser(input) : global_1.undefined;
|
|
2936
3025
|
};
|
|
2937
3026
|
}
|
|
2938
3027
|
|
|
@@ -2944,10 +3033,13 @@ function state(state, positive, parser) {
|
|
|
2944
3033
|
positive = true;
|
|
2945
3034
|
}
|
|
2946
3035
|
|
|
2947
|
-
return
|
|
3036
|
+
return input => {
|
|
3037
|
+
const {
|
|
3038
|
+
context
|
|
3039
|
+
} = input;
|
|
2948
3040
|
const s = context.state ?? 0;
|
|
2949
3041
|
context.state = positive ? s | state : s & ~state;
|
|
2950
|
-
const result = parser(
|
|
3042
|
+
const result = parser(input);
|
|
2951
3043
|
context.state = s;
|
|
2952
3044
|
return result;
|
|
2953
3045
|
};
|
|
@@ -3075,7 +3167,6 @@ exports.Memo = void 0;
|
|
|
3075
3167
|
class Memo {
|
|
3076
3168
|
constructor() {
|
|
3077
3169
|
this.memory = [];
|
|
3078
|
-
this.offset = 0;
|
|
3079
3170
|
}
|
|
3080
3171
|
|
|
3081
3172
|
get length() {
|
|
@@ -3084,19 +3175,19 @@ class Memo {
|
|
|
3084
3175
|
|
|
3085
3176
|
get(position, syntax, state) {
|
|
3086
3177
|
//console.log('get', position + this.offset, syntax, state, this.memory[position + this.offset - 1]?.[`${syntax}:${state}`]);;
|
|
3087
|
-
const cache = this.memory[position
|
|
3178
|
+
const cache = this.memory[position - 1]?.[`${syntax}:${state}`];
|
|
3088
3179
|
return cache?.length === 2 ? [cache[0].slice(), cache[1]] : cache;
|
|
3089
3180
|
}
|
|
3090
3181
|
|
|
3091
3182
|
set(position, syntax, state, nodes, offset) {
|
|
3092
|
-
const record = this.memory[position
|
|
3183
|
+
const record = this.memory[position - 1] ??= {};
|
|
3093
3184
|
record[`${syntax}:${state}`] = nodes ? [nodes.slice(), offset] : []; //console.log('set', position + this.offset, syntax, state, record[`${syntax}:${state}`]);
|
|
3094
3185
|
}
|
|
3095
3186
|
|
|
3096
3187
|
clear(position) {
|
|
3097
3188
|
const memory = this.memory;
|
|
3098
3189
|
|
|
3099
|
-
for (let i = position
|
|
3190
|
+
for (let i = position, len = memory.length; i < len; ++i) {
|
|
3100
3191
|
memory.pop();
|
|
3101
3192
|
} //console.log('clear', position + this.offset + 1);
|
|
3102
3193
|
|
|
@@ -3127,14 +3218,21 @@ const array_1 = __webpack_require__(8112);
|
|
|
3127
3218
|
|
|
3128
3219
|
function inits(parsers, resume) {
|
|
3129
3220
|
if (parsers.length === 1) return parsers[0];
|
|
3130
|
-
return
|
|
3221
|
+
return input => {
|
|
3222
|
+
const {
|
|
3223
|
+
source,
|
|
3224
|
+
context
|
|
3225
|
+
} = input;
|
|
3131
3226
|
let rest = source;
|
|
3132
3227
|
let nodes;
|
|
3133
3228
|
|
|
3134
3229
|
for (let i = 0, len = parsers.length; i < len; ++i) {
|
|
3135
3230
|
if (rest === '') break;
|
|
3136
3231
|
if (context.delimiters?.match(rest, context.precedence)) break;
|
|
3137
|
-
const result = parsers[i](
|
|
3232
|
+
const result = parsers[i]({
|
|
3233
|
+
source: rest,
|
|
3234
|
+
context
|
|
3235
|
+
});
|
|
3138
3236
|
if (!result) break;
|
|
3139
3237
|
nodes = nodes ? (0, array_1.push)(nodes, (0, parser_1.eval)(result)) : (0, parser_1.eval)(result);
|
|
3140
3238
|
rest = (0, parser_1.exec)(result);
|
|
@@ -3168,14 +3266,21 @@ const array_1 = __webpack_require__(8112);
|
|
|
3168
3266
|
|
|
3169
3267
|
function sequence(parsers, resume) {
|
|
3170
3268
|
if (parsers.length === 1) return parsers[0];
|
|
3171
|
-
return
|
|
3269
|
+
return input => {
|
|
3270
|
+
const {
|
|
3271
|
+
source,
|
|
3272
|
+
context
|
|
3273
|
+
} = input;
|
|
3172
3274
|
let rest = source;
|
|
3173
3275
|
let nodes;
|
|
3174
3276
|
|
|
3175
3277
|
for (let i = 0, len = parsers.length; i < len; ++i) {
|
|
3176
3278
|
if (rest === '') return;
|
|
3177
3279
|
if (context.delimiters?.match(rest, context.precedence)) return;
|
|
3178
|
-
const result = parsers[i](
|
|
3280
|
+
const result = parsers[i]({
|
|
3281
|
+
source: rest,
|
|
3282
|
+
context
|
|
3283
|
+
});
|
|
3179
3284
|
if (!result) return;
|
|
3180
3285
|
nodes = nodes ? (0, array_1.push)(nodes, (0, parser_1.eval)(result)) : (0, parser_1.eval)(result);
|
|
3181
3286
|
rest = (0, parser_1.exec)(result);
|
|
@@ -3217,7 +3322,11 @@ function some(parser, end, delimiters = [], limit = -1) {
|
|
|
3217
3322
|
matcher: delimiter_1.Delimiters.matcher(delimiter),
|
|
3218
3323
|
precedence
|
|
3219
3324
|
}));
|
|
3220
|
-
return
|
|
3325
|
+
return input => {
|
|
3326
|
+
const {
|
|
3327
|
+
source,
|
|
3328
|
+
context
|
|
3329
|
+
} = input;
|
|
3221
3330
|
if (source === '') return;
|
|
3222
3331
|
let rest = source;
|
|
3223
3332
|
let nodes;
|
|
@@ -3231,7 +3340,10 @@ function some(parser, end, delimiters = [], limit = -1) {
|
|
|
3231
3340
|
if (rest === '') break;
|
|
3232
3341
|
if (match(rest)) break;
|
|
3233
3342
|
if (context.delimiters?.match(rest, context.precedence)) break;
|
|
3234
|
-
const result = parser(
|
|
3343
|
+
const result = parser({
|
|
3344
|
+
source: rest,
|
|
3345
|
+
context
|
|
3346
|
+
});
|
|
3235
3347
|
if (!result) break;
|
|
3236
3348
|
nodes = nodes ? nodes.length < (0, parser_1.eval)(result).length ? (0, array_1.unshift)(nodes, (0, parser_1.eval)(result)) : (0, array_1.push)(nodes, (0, parser_1.eval)(result)) : (0, parser_1.eval)(result);
|
|
3237
3349
|
rest = (0, parser_1.exec)(result);
|
|
@@ -3318,7 +3430,7 @@ function union(parsers) {
|
|
|
3318
3430
|
return parsers[0];
|
|
3319
3431
|
|
|
3320
3432
|
default:
|
|
3321
|
-
return (0, global_1.Function)('parsers', ['"use strict";', 'return (
|
|
3433
|
+
return (0, global_1.Function)('parsers', ['"use strict";', 'return (input, context) =>', '0', ...parsers.map((_, i) => `|| parsers[${i}](input, context)`)].join('\n'))(parsers);
|
|
3322
3434
|
}
|
|
3323
3435
|
}
|
|
3324
3436
|
|
|
@@ -3528,9 +3640,15 @@ function bind(target, settings) {
|
|
|
3528
3640
|
|
|
3529
3641
|
for (; index < sourceSegments.length - last; ++index) {
|
|
3530
3642
|
const seg = sourceSegments[index];
|
|
3531
|
-
const es = (0, parser_1.eval)((0, header_1.header)(
|
|
3532
|
-
|
|
3533
|
-
|
|
3643
|
+
const es = (0, parser_1.eval)((0, header_1.header)({
|
|
3644
|
+
source: seg,
|
|
3645
|
+
context: {
|
|
3646
|
+
header: index === 0
|
|
3647
|
+
}
|
|
3648
|
+
}) || (0, block_1.block)({
|
|
3649
|
+
source: seg,
|
|
3650
|
+
context
|
|
3651
|
+
}), []);
|
|
3534
3652
|
blocks.splice(index, 0, [seg, es, url]);
|
|
3535
3653
|
if (es.length === 0) continue; // All deletion processes always run after all addition processes have done.
|
|
3536
3654
|
// Therefore any `base` node will never be unavailable by deletions until all the dependent `el` nodes are added.
|
|
@@ -3715,7 +3833,10 @@ function headers(source) {
|
|
|
3715
3833
|
exports.headers = headers;
|
|
3716
3834
|
|
|
3717
3835
|
function parse(source) {
|
|
3718
|
-
const result = (0, header_1.header)(
|
|
3836
|
+
const result = (0, header_1.header)({
|
|
3837
|
+
source,
|
|
3838
|
+
context: {}
|
|
3839
|
+
});
|
|
3719
3840
|
const [el] = (0, parser_1.eval)(result, []);
|
|
3720
3841
|
return el?.tagName === 'ASIDE' ? [el, (0, parser_1.exec)(result)] : [];
|
|
3721
3842
|
}
|
|
@@ -3757,7 +3878,10 @@ function sanitize(source) {
|
|
|
3757
3878
|
|
|
3758
3879
|
exports.invisibleHTMLEntityNames = ['Tab', 'NewLine', 'NonBreakingSpace', 'nbsp', 'shy', 'ensp', 'emsp', 'emsp13', 'emsp14', 'numsp', 'puncsp', 'ThinSpace', 'thinsp', 'VeryThinSpace', 'hairsp', 'ZeroWidthSpace', 'NegativeVeryThinSpace', 'NegativeThinSpace', 'NegativeMediumSpace', 'NegativeThickSpace', 'zwj', 'zwnj', 'lrm', 'rlm', 'MediumSpace', 'NoBreak', 'ApplyFunction', 'af', 'InvisibleTimes', 'it', 'InvisibleComma', 'ic'];
|
|
3759
3880
|
const unreadableHTMLEntityNames = exports.invisibleHTMLEntityNames.slice(2);
|
|
3760
|
-
const unreadableEscapableCharacters = unreadableHTMLEntityNames.map(name => (0, parser_1.eval)((0, htmlentity_1.unsafehtmlentity)(
|
|
3881
|
+
const unreadableEscapableCharacters = unreadableHTMLEntityNames.map(name => (0, parser_1.eval)((0, htmlentity_1.unsafehtmlentity)({
|
|
3882
|
+
source: `&${name};`,
|
|
3883
|
+
context: {}
|
|
3884
|
+
}))[0]);
|
|
3761
3885
|
const unreadableEscapableCharacter = new RegExp(`[${[...new Set(unreadableEscapableCharacters)].join('')}]`, 'g');
|
|
3762
3886
|
// https://www.pandanoir.info/entry/2018/03/11/193000
|
|
3763
3887
|
// http://anti.rosx.net/etc/memo/002_space.html
|
|
@@ -3841,9 +3965,15 @@ function parse(source, opts = {}, context) {
|
|
|
3841
3965
|
let index = 0;
|
|
3842
3966
|
|
|
3843
3967
|
for (const seg of (0, segment_1.segment)(source)) {
|
|
3844
|
-
node.append(...(0, parser_1.eval)((0, header_1.header)(
|
|
3845
|
-
|
|
3846
|
-
|
|
3968
|
+
node.append(...(0, parser_1.eval)((0, header_1.header)({
|
|
3969
|
+
source: seg,
|
|
3970
|
+
context: {
|
|
3971
|
+
header: index++ === 0
|
|
3972
|
+
}
|
|
3973
|
+
}) || (0, block_1.block)({
|
|
3974
|
+
source: seg,
|
|
3975
|
+
context
|
|
3976
|
+
}), []));
|
|
3847
3977
|
}
|
|
3848
3978
|
|
|
3849
3979
|
if (opts.test) return node;
|
|
@@ -3878,7 +4008,10 @@ const source_1 = __webpack_require__(6743);
|
|
|
3878
4008
|
|
|
3879
4009
|
const delimiter = /[@#>0-9A-Za-z\n]|\S[#>]/;
|
|
3880
4010
|
|
|
3881
|
-
const autolink = (
|
|
4011
|
+
const autolink = ({
|
|
4012
|
+
source,
|
|
4013
|
+
context
|
|
4014
|
+
}) => {
|
|
3882
4015
|
if (source === '') return;
|
|
3883
4016
|
const i = source.search(delimiter);
|
|
3884
4017
|
|
|
@@ -3887,7 +4020,10 @@ const autolink = (source, context) => {
|
|
|
3887
4020
|
return [[source], ''];
|
|
3888
4021
|
|
|
3889
4022
|
case 0:
|
|
3890
|
-
return parser(
|
|
4023
|
+
return parser({
|
|
4024
|
+
source,
|
|
4025
|
+
context
|
|
4026
|
+
});
|
|
3891
4027
|
|
|
3892
4028
|
default:
|
|
3893
4029
|
return [[source.slice(0, i)], source.slice(i)];
|
|
@@ -3956,10 +4092,15 @@ exports.block = (0, combinator_1.creation)(error((0, combinator_1.reset)({
|
|
|
3956
4092
|
}, (0, combinator_1.union)([source_1.emptyline, horizontalrule_1.horizontalrule, heading_1.heading, ulist_1.ulist, olist_1.olist, ilist_1.ilist, dlist_1.dlist, table_1.table, codeblock_1.codeblock, mathblock_1.mathblock, extension_1.extension, sidefence_1.sidefence, blockquote_1.blockquote, reply_1.reply, paragraph_1.paragraph]))));
|
|
3957
4093
|
|
|
3958
4094
|
function error(parser) {
|
|
3959
|
-
return (0, combinator_1.recover)((0, combinator_1.fallback)((0, combinator_1.open)('\x07',
|
|
4095
|
+
return (0, combinator_1.recover)((0, combinator_1.fallback)((0, combinator_1.open)('\x07', ({
|
|
4096
|
+
source
|
|
4097
|
+
}) => {
|
|
3960
4098
|
throw new Error(source.split('\n', 1)[0]);
|
|
3961
|
-
}), parser), (
|
|
3962
|
-
|
|
4099
|
+
}), parser), ({
|
|
4100
|
+
source,
|
|
4101
|
+
context: {
|
|
4102
|
+
id
|
|
4103
|
+
}
|
|
3963
4104
|
}, reason) => [[(0, dom_1.html)('h1', {
|
|
3964
4105
|
id: id !== '' ? `error:${(0, random_1.rnd0Z)(8)}` : global_1.undefined,
|
|
3965
4106
|
class: 'error'
|
|
@@ -4000,7 +4141,10 @@ const indent = (0, combinator_1.block)((0, combinator_1.open)(opener, (0, combin
|
|
|
4000
4141
|
const unindent = source => source.replace(/(^|\n)>(?:[^\S\n]|(?=>*(?:$|\s)))|\n$/g, '$1');
|
|
4001
4142
|
|
|
4002
4143
|
const source = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)((0, combinator_1.union)([(0, combinator_1.rewrite)(indent, (0, combinator_1.convert)(unindent, source)), (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, (0, combinator_1.fmap)((0, combinator_1.some)(autolink_1.autolink), ns => [(0, dom_1.html)('pre', (0, dom_1.defrag)(ns))])))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
|
|
4003
|
-
const markdown = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)((0, combinator_1.union)([(0, combinator_1.rewrite)(indent, (0, combinator_1.convert)(unindent, markdown)), (0, combinator_1.creation)(99, (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, (
|
|
4144
|
+
const markdown = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)((0, combinator_1.union)([(0, combinator_1.rewrite)(indent, (0, combinator_1.convert)(unindent, markdown)), (0, combinator_1.creation)(99, (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, ({
|
|
4145
|
+
source,
|
|
4146
|
+
context
|
|
4147
|
+
}) => {
|
|
4004
4148
|
const references = (0, dom_1.html)('ol', {
|
|
4005
4149
|
class: 'references'
|
|
4006
4150
|
});
|
|
@@ -4081,7 +4225,10 @@ exports.codeblock = (0, combinator_1.block)((0, combinator_1.validate)('```', (0
|
|
|
4081
4225
|
'data-lang': params.lang || global_1.undefined,
|
|
4082
4226
|
'data-line': params.line || global_1.undefined,
|
|
4083
4227
|
'data-path': params.path || global_1.undefined
|
|
4084
|
-
}, params.lang ? context.caches?.code?.get(`${params.lang ?? ''}\n${body.slice(0, -1)}`)?.cloneNode(true).childNodes || body.slice(0, -1) || global_1.undefined : (0, dom_1.defrag)((0, parser_1.eval)((0, combinator_1.some)(autolink_1.autolink)(
|
|
4228
|
+
}, params.lang ? context.caches?.code?.get(`${params.lang ?? ''}\n${body.slice(0, -1)}`)?.cloneNode(true).childNodes || body.slice(0, -1) || global_1.undefined : (0, dom_1.defrag)((0, parser_1.eval)((0, combinator_1.some)(autolink_1.autolink)({
|
|
4229
|
+
source: body.slice(0, -1),
|
|
4230
|
+
context
|
|
4231
|
+
}), [])));
|
|
4085
4232
|
return [el];
|
|
4086
4233
|
})));
|
|
4087
4234
|
|
|
@@ -4281,7 +4428,10 @@ exports.example = (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0,
|
|
|
4281
4428
|
'data-type': 'math'
|
|
4282
4429
|
}, [(0, dom_1.html)('pre', {
|
|
4283
4430
|
translate: 'no'
|
|
4284
|
-
}, body.slice(0, -1)), (0, dom_1.html)('hr'), (0, parser_1.eval)((0, mathblock_1.mathblock)(
|
|
4431
|
+
}, body.slice(0, -1)), (0, dom_1.html)('hr'), (0, parser_1.eval)((0, mathblock_1.mathblock)({
|
|
4432
|
+
source: `$$\n${body}$$`,
|
|
4433
|
+
context
|
|
4434
|
+
}), [])[0]])];
|
|
4285
4435
|
|
|
4286
4436
|
default:
|
|
4287
4437
|
return [(0, dom_1.html)('pre', {
|
|
@@ -4427,7 +4577,10 @@ exports.figure = (0, combinator_1.block)((0, combinator_1.fallback)((0, combinat
|
|
|
4427
4577
|
} || overflow && {
|
|
4428
4578
|
'data-invalid-type': 'fence',
|
|
4429
4579
|
'data-invalid-message': `Invalid trailing line after the closing delimiter "${delim}"`
|
|
4430
|
-
} || !(0, label_1.segment)(
|
|
4580
|
+
} || !(0, label_1.segment)({
|
|
4581
|
+
source: opener.match(/^~+(?:figure[^\S\n]+)?(\[?\$\S+)/)?.[1] ?? '',
|
|
4582
|
+
context
|
|
4583
|
+
}) && {
|
|
4431
4584
|
'data-invalid-type': 'label',
|
|
4432
4585
|
'data-invalid-message': 'Invalid label'
|
|
4433
4586
|
} || /^~+(?:figure[^\S\n]+)?(\[?\$\S+)[^\S\n]+\S/.test(opener) && {
|
|
@@ -4587,7 +4740,10 @@ exports.message = (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0,
|
|
|
4587
4740
|
return [(0, dom_1.html)('section', {
|
|
4588
4741
|
class: `message`,
|
|
4589
4742
|
'data-type': type
|
|
4590
|
-
}, (0, array_1.unshift)([(0, dom_1.html)('h1', title(type))], [...(0, segment_1.segment)(body)].reduce((acc, seg) => (0, array_1.push)(acc, (0, parser_1.eval)(content(
|
|
4743
|
+
}, (0, array_1.unshift)([(0, dom_1.html)('h1', title(type))], [...(0, segment_1.segment)(body)].reduce((acc, seg) => (0, array_1.push)(acc, (0, parser_1.eval)(content({
|
|
4744
|
+
source: seg,
|
|
4745
|
+
context
|
|
4746
|
+
}), [])), [])))];
|
|
4591
4747
|
})));
|
|
4592
4748
|
|
|
4593
4749
|
function title(type) {
|
|
@@ -4681,7 +4837,10 @@ exports.table = (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0, co
|
|
|
4681
4837
|
switch (type) {
|
|
4682
4838
|
case 'grid':
|
|
4683
4839
|
case global_1.undefined:
|
|
4684
|
-
return ((0, parser_1.eval)(parser(
|
|
4840
|
+
return ((0, parser_1.eval)(parser({
|
|
4841
|
+
source: body,
|
|
4842
|
+
context
|
|
4843
|
+
})) ?? [(0, dom_1.html)('table')]).map(el => (0, dom_1.define)(el, {
|
|
4685
4844
|
'data-type': type
|
|
4686
4845
|
}));
|
|
4687
4846
|
|
|
@@ -4936,7 +5095,9 @@ const visibility_1 = __webpack_require__(7618);
|
|
|
4936
5095
|
|
|
4937
5096
|
const dom_1 = __webpack_require__(3252);
|
|
4938
5097
|
|
|
4939
|
-
exports.segment = (0, combinator_1.block)((0, combinator_1.validate)('#', (0, combinator_1.focus)(/^#+[^\S\n]+\S[^\n]*(?:\n#+(?!\S)[^\n]*)*(?:$|\n)/, (0, combinator_1.some)((0, combinator_1.line)(
|
|
5098
|
+
exports.segment = (0, combinator_1.block)((0, combinator_1.validate)('#', (0, combinator_1.focus)(/^#+[^\S\n]+\S[^\n]*(?:\n#+(?!\S)[^\n]*)*(?:$|\n)/, (0, combinator_1.some)((0, combinator_1.line)(({
|
|
5099
|
+
source
|
|
5100
|
+
}) => [[source], ''])))));
|
|
4940
5101
|
exports.heading = (0, combinator_1.block)((0, combinator_1.rewrite)(exports.segment, (0, combinator_1.state)(64
|
|
4941
5102
|
/* State.annotation */
|
|
4942
5103
|
| 32
|
|
@@ -5083,8 +5244,6 @@ const duff_1 = __webpack_require__(8099);
|
|
|
5083
5244
|
|
|
5084
5245
|
const array_1 = __webpack_require__(8112);
|
|
5085
5246
|
|
|
5086
|
-
const tuple_1 = __webpack_require__(5341);
|
|
5087
|
-
|
|
5088
5247
|
const openers = {
|
|
5089
5248
|
'.': /^([0-9]+|[a-z]+|[A-Z]+)(?:-(?!-)[0-9]*)*(?![^\S\n])\.?(?:$|\s)/,
|
|
5090
5249
|
'(': /^\(([0-9]*|[a-z]*)(?![^)\n])\)?(?:-(?!-)[0-9]*)*(?:$|\s)/
|
|
@@ -5099,10 +5258,18 @@ const list = (type, form) => (0, combinator_1.fmap)((0, combinator_1.some)((0, c
|
|
|
5099
5258
|
}, (0, dom_1.defrag)((0, ulist_1.fillFirstLine)((0, array_1.shift)(ns)[1])))]), true)]))), es => [format((0, dom_1.html)('ol', es), type, form)]);
|
|
5100
5259
|
|
|
5101
5260
|
const heads = {
|
|
5102
|
-
'.': (0, combinator_1.focus)(openers['.'],
|
|
5103
|
-
|
|
5261
|
+
'.': (0, combinator_1.focus)(openers['.'], ({
|
|
5262
|
+
source
|
|
5263
|
+
}) => [[source.trimEnd().split('.', 1)[0] + '.'], '']),
|
|
5264
|
+
'(': (0, combinator_1.focus)(openers['('], ({
|
|
5265
|
+
source
|
|
5266
|
+
}) => [[source.trimEnd().replace(/^\($/, '(1)').replace(/^\((\w+)$/, '($1)')], ''])
|
|
5104
5267
|
};
|
|
5105
|
-
exports.invalid = (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.contentline, (0, combinator_1.indent)(
|
|
5268
|
+
exports.invalid = (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.contentline, (0, combinator_1.indent)(({
|
|
5269
|
+
source
|
|
5270
|
+
}) => [[source], ''])]), ({
|
|
5271
|
+
source
|
|
5272
|
+
}) => [['', (0, dom_1.html)('span', {
|
|
5106
5273
|
class: 'invalid',
|
|
5107
5274
|
'data-invalid-syntax': 'listitem',
|
|
5108
5275
|
'data-invalid-type': 'syntax',
|
|
@@ -5283,9 +5450,13 @@ exports.cite = (0, combinator_1.creation)((0, combinator_1.line)((0, combinator_
|
|
|
5283
5450
|
// リンクの実装は後で検討
|
|
5284
5451
|
(0, combinator_1.focus)(/^>>\.[^\S\n]*(?:$|\n)/, () => [[(0, dom_1.html)('a', {
|
|
5285
5452
|
class: 'anchor'
|
|
5286
|
-
}, '>>.')], '']), (0, combinator_1.focus)(/^>>#\S*[^\S\n]*(?:$|\n)/,
|
|
5453
|
+
}, '>>.')], '']), (0, combinator_1.focus)(/^>>#\S*[^\S\n]*(?:$|\n)/, ({
|
|
5454
|
+
source
|
|
5455
|
+
}) => [[(0, dom_1.html)('a', {
|
|
5287
5456
|
class: 'anchor'
|
|
5288
|
-
}, source)], '']), (0, combinator_1.focus)(/^>>https?:\/\/\w\S*[^\S\n]*(?:$|\n)/,
|
|
5457
|
+
}, source)], '']), (0, combinator_1.focus)(/^>>https?:\/\/\w\S*[^\S\n]*(?:$|\n)/, ({
|
|
5458
|
+
source
|
|
5459
|
+
}) => [[(0, dom_1.html)('a', {
|
|
5289
5460
|
class: 'anchor',
|
|
5290
5461
|
href: source.slice(2).trimEnd(),
|
|
5291
5462
|
target: '_blank'
|
|
@@ -5330,12 +5501,18 @@ exports.quote = (0, combinator_1.lazy)(() => (0, combinator_1.creation)((0, comb
|
|
|
5330
5501
|
'data-invalid-message': `Missing the whitespace after "${ns[0].split(/[^>]/, 1)[0]}"`
|
|
5331
5502
|
}, (0, dom_1.defrag)(ns)), (0, dom_1.html)('br')]), false)));
|
|
5332
5503
|
|
|
5333
|
-
const qblock = (
|
|
5504
|
+
const qblock = ({
|
|
5505
|
+
source,
|
|
5506
|
+
context
|
|
5507
|
+
}) => {
|
|
5334
5508
|
source = source.replace(/\n$/, '');
|
|
5335
5509
|
const lines = source.match(/^.*\n?/mg);
|
|
5336
5510
|
const quotes = source.match(/^>+[^\S\n]/mg);
|
|
5337
5511
|
const content = lines.reduce((acc, line, row) => acc + line.slice(quotes[row].length), '');
|
|
5338
|
-
const nodes = (0, parser_1.eval)((0, combinator_1.some)(text)(
|
|
5512
|
+
const nodes = (0, parser_1.eval)((0, combinator_1.some)(text)({
|
|
5513
|
+
source: content,
|
|
5514
|
+
context
|
|
5515
|
+
}), []);
|
|
5339
5516
|
nodes.unshift(quotes.shift());
|
|
5340
5517
|
|
|
5341
5518
|
for (let i = 0; i < nodes.length; ++i) {
|
|
@@ -5429,7 +5606,9 @@ const array_1 = __webpack_require__(8112);
|
|
|
5429
5606
|
|
|
5430
5607
|
exports.table = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^\|[^\n]*(?:\n\|[^\n]*){2}/, (0, combinator_1.sequence)([row((0, combinator_1.some)(head), true), row((0, combinator_1.some)(align), false), (0, combinator_1.some)(row((0, combinator_1.some)(data), true))])), rows => [(0, dom_1.html)('table', [(0, dom_1.html)('thead', [rows.shift()]), (0, dom_1.html)('tbody', format(rows))])])));
|
|
5431
5608
|
|
|
5432
|
-
const row = (parser, optional) => (0, combinator_1.creation)((0, combinator_1.fallback)((0, combinator_1.fmap)((0, combinator_1.line)((0, combinator_1.surround)(/^(?=\|)/, (0, combinator_1.some)((0, combinator_1.union)([parser])), /^[|\\]?\s*$/, optional)), es => [(0, dom_1.html)('tr', es)]), (0, combinator_1.rewrite)(source_1.contentline,
|
|
5609
|
+
const row = (parser, optional) => (0, combinator_1.creation)((0, combinator_1.fallback)((0, combinator_1.fmap)((0, combinator_1.line)((0, combinator_1.surround)(/^(?=\|)/, (0, combinator_1.some)((0, combinator_1.union)([parser])), /^[|\\]?\s*$/, optional)), es => [(0, dom_1.html)('tr', es)]), (0, combinator_1.rewrite)(source_1.contentline, ({
|
|
5610
|
+
source
|
|
5611
|
+
}) => [[(0, dom_1.html)('tr', {
|
|
5433
5612
|
class: 'invalid',
|
|
5434
5613
|
'data-invalid-syntax': 'table-row',
|
|
5435
5614
|
'data-invalid-type': 'syntax',
|
|
@@ -5489,7 +5668,9 @@ exports.ulist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combina
|
|
|
5489
5668
|
/* State.media */
|
|
5490
5669
|
, exports.ulist_))));
|
|
5491
5670
|
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)((0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(/^-(?:$|\s)/, (0, combinator_1.subsequence)([exports.checkbox, (0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))]), true)), (0, combinator_1.indent)((0, combinator_1.union)([exports.ulist_, olist_1.olist_, ilist_1.ilist_]))]), olist_1.invalid), ns => [(0, dom_1.html)('li', (0, dom_1.defrag)(fillFirstLine(ns)))]), true)])))), es => [format((0, dom_1.html)('ul', es))])));
|
|
5492
|
-
exports.checkbox = (0, combinator_1.creation)((0, combinator_1.focus)(/^\[[xX ]\](?=$|\s)/,
|
|
5671
|
+
exports.checkbox = (0, combinator_1.creation)((0, combinator_1.focus)(/^\[[xX ]\](?=$|\s)/, ({
|
|
5672
|
+
source
|
|
5673
|
+
}) => [[(0, dom_1.html)('span', {
|
|
5493
5674
|
class: 'checkbox'
|
|
5494
5675
|
}, source[1].trimStart() ? '☑' : '☐')], '']));
|
|
5495
5676
|
|
|
@@ -5530,18 +5711,25 @@ const normalize_1 = __webpack_require__(185);
|
|
|
5530
5711
|
|
|
5531
5712
|
const dom_1 = __webpack_require__(3252);
|
|
5532
5713
|
|
|
5533
|
-
exports.header = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(/^---+[^\S\v\f\r\n]*\r?\n[^\S\n]*(?=\S)/, (0, combinator_1.inits)([(0, combinator_1.rewrite)((
|
|
5714
|
+
exports.header = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(/^---+[^\S\v\f\r\n]*\r?\n[^\S\n]*(?=\S)/, (0, combinator_1.inits)([(0, combinator_1.rewrite)(({
|
|
5715
|
+
source,
|
|
5716
|
+
context
|
|
5717
|
+
}) => [[], context.header ?? true ? source.slice((0, segment_1.segment)(source).next().value.length) : ''], (0, combinator_1.block)((0, combinator_1.union)([(0, combinator_1.guard)(context => context.header ?? true, (0, combinator_1.focus)(/^---[^\S\v\f\r\n]*\r?\n(?:[A-Za-z][0-9A-Za-z]*(?:-[A-Za-z][0-9A-Za-z]*)*:[ \t]+\S[^\v\f\r\n]*\r?\n){1,100}---[^\S\v\f\r\n]*(?:$|\r?\n)/, (0, combinator_1.convert)(source => (0, normalize_1.normalize)(source.slice(source.indexOf('\n') + 1, source.trimEnd().lastIndexOf('\n'))).replace(/(\S)\s+$/mg, '$1'), (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.union)([field])), es => [(0, dom_1.html)('aside', {
|
|
5534
5718
|
class: 'header'
|
|
5535
5719
|
}, [(0, dom_1.html)('details', {
|
|
5536
5720
|
open: ''
|
|
5537
|
-
}, (0, dom_1.defrag)([(0, dom_1.html)('summary', 'Header'), ...es]))])])))),
|
|
5721
|
+
}, (0, dom_1.defrag)([(0, dom_1.html)('summary', 'Header'), ...es]))])])))), ({
|
|
5722
|
+
source
|
|
5723
|
+
}) => [[(0, dom_1.html)('pre', {
|
|
5538
5724
|
class: 'invalid',
|
|
5539
5725
|
translate: 'no',
|
|
5540
5726
|
'data-invalid-syntax': 'header',
|
|
5541
5727
|
'data-invalid-type': 'syntax',
|
|
5542
5728
|
'data-invalid-message': 'Invalid syntax'
|
|
5543
5729
|
}, (0, normalize_1.normalize)(source))], '']]))), (0, combinator_1.clear)((0, source_1.str)(/^[^\S\v\f\r\n]*\r?\n/))])));
|
|
5544
|
-
const field = (0, combinator_1.line)(
|
|
5730
|
+
const field = (0, combinator_1.line)(({
|
|
5731
|
+
source
|
|
5732
|
+
}) => {
|
|
5545
5733
|
const name = source.slice(0, source.indexOf(':'));
|
|
5546
5734
|
const value = source.slice(name.length + 1).trim();
|
|
5547
5735
|
return [[(0, dom_1.html)('span', {
|
|
@@ -5846,7 +6034,9 @@ const source_1 = __webpack_require__(6743);
|
|
|
5846
6034
|
const dom_1 = __webpack_require__(3252); // https://html.spec.whatwg.org/multipage/input.html
|
|
5847
6035
|
|
|
5848
6036
|
|
|
5849
|
-
exports.email = (0, combinator_1.creation)((0, combinator_1.rewrite)((0, combinator_1.verify)((0, source_1.str)(/^[0-9A-Za-z]+(?:[.+_-][0-9A-Za-z]+)*@[0-9A-Za-z](?:(?:[0-9A-Za-z]|-(?=\w)){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-(?=\w)){0,61}[0-9A-Za-z])?)*(?![0-9A-Za-z])/), ([source]) => source.indexOf('@') <= 64 && source.length <= 255),
|
|
6037
|
+
exports.email = (0, combinator_1.creation)((0, combinator_1.rewrite)((0, combinator_1.verify)((0, source_1.str)(/^[0-9A-Za-z]+(?:[.+_-][0-9A-Za-z]+)*@[0-9A-Za-z](?:(?:[0-9A-Za-z]|-(?=\w)){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-(?=\w)){0,61}[0-9A-Za-z])?)*(?![0-9A-Za-z])/), ([source]) => source.indexOf('@') <= 64 && source.length <= 255), ({
|
|
6038
|
+
source
|
|
6039
|
+
}) => [[(0, dom_1.html)('a', {
|
|
5850
6040
|
class: 'email',
|
|
5851
6041
|
href: `mailto:${source}`
|
|
5852
6042
|
}, source)], '']));
|
|
@@ -6008,9 +6198,11 @@ const combinator_1 = __webpack_require__(2087);
|
|
|
6008
6198
|
|
|
6009
6199
|
const dom_1 = __webpack_require__(3252);
|
|
6010
6200
|
|
|
6011
|
-
exports.code = (0, combinator_1.creation)((0, combinator_1.validate)('`', (0, combinator_1.match)(/^(`+)(?!`)([^\n]*?[^`\n])\1(?!`)/, ([whole,, body]) =>
|
|
6201
|
+
exports.code = (0, combinator_1.creation)((0, combinator_1.validate)('`', (0, combinator_1.match)(/^(`+)(?!`)([^\n]*?[^`\n])\1(?!`)/, ([whole,, body]) => ({
|
|
6202
|
+
source
|
|
6203
|
+
}) => [[(0, dom_1.html)('code', {
|
|
6012
6204
|
'data-src': whole
|
|
6013
|
-
}, format(body))],
|
|
6205
|
+
}, format(body))], source.slice(whole.length)])));
|
|
6014
6206
|
|
|
6015
6207
|
function format(text) {
|
|
6016
6208
|
return `${text[0]}${text[text.length - 1]}` === ' ' && text.trimStart() ? text.slice(1, -1) : text;
|
|
@@ -6158,10 +6350,16 @@ exports.emstrong = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, s
|
|
|
6158
6350
|
return [[(0, dom_1.html)('em', [(0, dom_1.html)('strong', (0, dom_1.defrag)(bs))])], rest];
|
|
6159
6351
|
|
|
6160
6352
|
case '**':
|
|
6161
|
-
return (0, combinator_1.bind)(subemphasis, (ds, rest) => rest.slice(0, 1) === '*' ? [[(0, dom_1.html)('em', (0, array_1.unshift)([(0, dom_1.html)('strong', (0, dom_1.defrag)(bs))], (0, dom_1.defrag)(ds)))], rest.slice(1)] : [(0, array_1.unshift)(['*', (0, dom_1.html)('strong', (0, dom_1.defrag)(bs))], ds), rest])(
|
|
6353
|
+
return (0, combinator_1.bind)(subemphasis, (ds, rest) => rest.slice(0, 1) === '*' ? [[(0, dom_1.html)('em', (0, array_1.unshift)([(0, dom_1.html)('strong', (0, dom_1.defrag)(bs))], (0, dom_1.defrag)(ds)))], rest.slice(1)] : [(0, array_1.unshift)(['*', (0, dom_1.html)('strong', (0, dom_1.defrag)(bs))], ds), rest])({
|
|
6354
|
+
source: rest,
|
|
6355
|
+
context
|
|
6356
|
+
}) ?? [['*', (0, dom_1.html)('strong', (0, dom_1.defrag)(bs))], rest];
|
|
6162
6357
|
|
|
6163
6358
|
case '*':
|
|
6164
|
-
return (0, combinator_1.bind)(substrong, (ds, rest) => rest.slice(0, 2) === '**' ? [[(0, dom_1.html)('strong', (0, array_1.unshift)([(0, dom_1.html)('em', (0, dom_1.defrag)(bs))], (0, dom_1.defrag)(ds)))], rest.slice(2)] : [(0, array_1.unshift)(['**', (0, dom_1.html)('em', (0, dom_1.defrag)(bs))], ds), rest])(
|
|
6359
|
+
return (0, combinator_1.bind)(substrong, (ds, rest) => rest.slice(0, 2) === '**' ? [[(0, dom_1.html)('strong', (0, array_1.unshift)([(0, dom_1.html)('em', (0, dom_1.defrag)(bs))], (0, dom_1.defrag)(ds)))], rest.slice(2)] : [(0, array_1.unshift)(['**', (0, dom_1.html)('em', (0, dom_1.defrag)(bs))], ds), rest])({
|
|
6360
|
+
source: rest,
|
|
6361
|
+
context
|
|
6362
|
+
}) ?? [['**', (0, dom_1.html)('em', (0, dom_1.defrag)(bs))], rest];
|
|
6165
6363
|
}
|
|
6166
6364
|
}, ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest]));
|
|
6167
6365
|
|
|
@@ -6185,18 +6383,27 @@ const combinator_1 = __webpack_require__(2087);
|
|
|
6185
6383
|
const source_1 = __webpack_require__(6743);
|
|
6186
6384
|
|
|
6187
6385
|
const repeat = (0, source_1.str)(/^(.)\1*/);
|
|
6188
|
-
exports.escape = (0, combinator_1.union)([(
|
|
6386
|
+
exports.escape = (0, combinator_1.union)([({
|
|
6387
|
+
source,
|
|
6388
|
+
context
|
|
6389
|
+
}) => {
|
|
6189
6390
|
if (source.length < 3) return;
|
|
6190
6391
|
|
|
6191
6392
|
switch (source[0]) {
|
|
6192
6393
|
case '*':
|
|
6193
6394
|
if (source.length < 4) return;
|
|
6194
|
-
return source[3] === source[0] && source[2] === source[0] && source[1] === source[0] ? repeat(
|
|
6395
|
+
return source[3] === source[0] && source[2] === source[0] && source[1] === source[0] ? repeat({
|
|
6396
|
+
source,
|
|
6397
|
+
context
|
|
6398
|
+
}) : global_1.undefined;
|
|
6195
6399
|
|
|
6196
6400
|
case '+':
|
|
6197
6401
|
case '~':
|
|
6198
6402
|
case '=':
|
|
6199
|
-
return source[2] === source[0] && source[1] === source[0] ? repeat(
|
|
6403
|
+
return source[2] === source[0] && source[1] === source[0] ? repeat({
|
|
6404
|
+
source,
|
|
6405
|
+
context
|
|
6406
|
+
}) : global_1.undefined;
|
|
6200
6407
|
|
|
6201
6408
|
default:
|
|
6202
6409
|
return;
|
|
@@ -6590,7 +6797,9 @@ const dom_1 = __webpack_require__(3252);
|
|
|
6590
6797
|
|
|
6591
6798
|
const memoize_1 = __webpack_require__(1808);
|
|
6592
6799
|
|
|
6593
|
-
exports.unsafehtmlentity = (0, combinator_1.creation)((0, combinator_1.validate)('&', (0, combinator_1.focus)(/^&[0-9A-Za-z]+;/,
|
|
6800
|
+
exports.unsafehtmlentity = (0, combinator_1.creation)((0, combinator_1.validate)('&', (0, combinator_1.focus)(/^&[0-9A-Za-z]+;/, ({
|
|
6801
|
+
source
|
|
6802
|
+
}) => [[parse(source) ?? `\x1B${source}`], ''])));
|
|
6594
6803
|
exports.htmlentity = (0, combinator_1.fmap)((0, combinator_1.union)([exports.unsafehtmlentity]), ([test]) => [test[0] === '\x1B' ? (0, dom_1.html)('span', {
|
|
6595
6804
|
class: 'invalid',
|
|
6596
6805
|
'data-invalid-syntax': 'htmlentity',
|
|
@@ -6687,7 +6896,10 @@ const textlink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(4
|
|
|
6687
6896
|
for (let source = (0, util_1.stringify)(content); source;) {
|
|
6688
6897
|
const result = (0, combinator_1.state)(1
|
|
6689
6898
|
/* State.autolink */
|
|
6690
|
-
, false, autolink_1.autolink)(
|
|
6899
|
+
, false, autolink_1.autolink)({
|
|
6900
|
+
source,
|
|
6901
|
+
context
|
|
6902
|
+
});
|
|
6691
6903
|
if (typeof (0, parser_1.eval)(result)[0] === 'object') return;
|
|
6692
6904
|
source = (0, parser_1.exec)(result);
|
|
6693
6905
|
}
|
|
@@ -6841,10 +7053,13 @@ const source_1 = __webpack_require__(6743);
|
|
|
6841
7053
|
const dom_1 = __webpack_require__(3252);
|
|
6842
7054
|
|
|
6843
7055
|
const forbiddenCommand = /\\(?:begin|tiny|huge|large)(?![a-z])/i;
|
|
6844
|
-
exports.math = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('$', (0, combinator_1.creation)((0, combinator_1.rewrite)((0, combinator_1.union)([(0, combinator_1.surround)('$', (0, combinator_1.precedence)(6, bracket), '$'), (0, combinator_1.surround)(/^\$(?![\s{}])/, (0, combinator_1.precedence)(3, (0, combinator_1.some)((0, combinator_1.union)([bracket, (0, combinator_1.focus)(/^(?:[ ([](?!\$)|\\[\\{}$]?|[!#%&')\x2A-\x5A\]^_\x61-\x7A|~])+/, (0, combinator_1.some)(source_1.unescsource))]))), /^\$(?![0-9A-Za-z])/)]), (
|
|
6845
|
-
|
|
6846
|
-
|
|
6847
|
-
|
|
7056
|
+
exports.math = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('$', (0, combinator_1.creation)((0, combinator_1.rewrite)((0, combinator_1.union)([(0, combinator_1.surround)('$', (0, combinator_1.precedence)(6, bracket), '$'), (0, combinator_1.surround)(/^\$(?![\s{}])/, (0, combinator_1.precedence)(3, (0, combinator_1.some)((0, combinator_1.union)([bracket, (0, combinator_1.focus)(/^(?:[ ([](?!\$)|\\[\\{}$]?|[!#%&')\x2A-\x5A\]^_\x61-\x7A|~])+/, (0, combinator_1.some)(source_1.unescsource))]))), /^\$(?![0-9A-Za-z])/)]), ({
|
|
7057
|
+
source,
|
|
7058
|
+
context: {
|
|
7059
|
+
caches: {
|
|
7060
|
+
math: cache
|
|
7061
|
+
} = {}
|
|
7062
|
+
}
|
|
6848
7063
|
}) => [[cache?.get(source)?.cloneNode(true) || (0, dom_1.html)('span', !forbiddenCommand.test(source) ? {
|
|
6849
7064
|
class: 'math',
|
|
6850
7065
|
translate: 'no',
|
|
@@ -6923,10 +7138,16 @@ exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['![', '
|
|
|
6923
7138
|
if (context.state & 4
|
|
6924
7139
|
/* State.link */
|
|
6925
7140
|
) return [[el], rest];
|
|
6926
|
-
if (cache && cache.tagName !== 'IMG') return (0, combinator_1.creation)(10, (..._) => [[el], rest])(
|
|
7141
|
+
if (cache && cache.tagName !== 'IMG') return (0, combinator_1.creation)(10, (..._) => [[el], rest])({
|
|
7142
|
+
source: '!',
|
|
7143
|
+
context
|
|
7144
|
+
});
|
|
6927
7145
|
return (0, combinator_1.fmap)(link_1.unsafelink, ([link]) => [(0, dom_1.define)(link, {
|
|
6928
7146
|
target: '_blank'
|
|
6929
|
-
}, [el])])(
|
|
7147
|
+
}, [el])])({
|
|
7148
|
+
source: `{ ${INSECURE_URI}${params.join('')} }${rest}`,
|
|
7149
|
+
context
|
|
7150
|
+
});
|
|
6930
7151
|
}))))));
|
|
6931
7152
|
const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.creation)((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, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (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, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (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, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(8, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, source_1.txt]), '"')), (0, source_1.str)('"'), true)])));
|
|
6932
7153
|
const option = (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]);
|
|
@@ -7074,7 +7295,10 @@ exports.ruby = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[', (0,
|
|
|
7074
7295
|
return [(0, dom_1.html)('ruby', attributes(texts, rubies), (0, dom_1.defrag)((0, array_1.unshift)([texts.join(' ')], [(0, dom_1.html)('rp', '('), (0, dom_1.html)('rt', rubies.join(' ').trim()), (0, dom_1.html)('rp', ')')])))];
|
|
7075
7296
|
}
|
|
7076
7297
|
}))));
|
|
7077
|
-
const text = (0, combinator_1.creation)((
|
|
7298
|
+
const text = (0, combinator_1.creation)(({
|
|
7299
|
+
source,
|
|
7300
|
+
context
|
|
7301
|
+
}) => {
|
|
7078
7302
|
const acc = [''];
|
|
7079
7303
|
|
|
7080
7304
|
while (source !== '') {
|
|
@@ -7082,7 +7306,10 @@ const text = (0, combinator_1.creation)((source, context) => {
|
|
|
7082
7306
|
// @ts-expect-error
|
|
7083
7307
|
case '&':
|
|
7084
7308
|
{
|
|
7085
|
-
const result = (0, htmlentity_1.unsafehtmlentity)(
|
|
7309
|
+
const result = (0, htmlentity_1.unsafehtmlentity)({
|
|
7310
|
+
source,
|
|
7311
|
+
context
|
|
7312
|
+
});
|
|
7086
7313
|
|
|
7087
7314
|
if (result) {
|
|
7088
7315
|
acc[acc.length - 1] += (0, parser_1.eval)(result)[0];
|
|
@@ -7100,7 +7327,10 @@ const text = (0, combinator_1.creation)((source, context) => {
|
|
|
7100
7327
|
continue;
|
|
7101
7328
|
}
|
|
7102
7329
|
|
|
7103
|
-
const result = (0, source_1.text)(
|
|
7330
|
+
const result = (0, source_1.text)({
|
|
7331
|
+
source,
|
|
7332
|
+
context
|
|
7333
|
+
});
|
|
7104
7334
|
acc[acc.length - 1] += (0, parser_1.eval)(result)[0] ?? source.slice(0, source.length - (0, parser_1.exec)(result).length);
|
|
7105
7335
|
source = (0, parser_1.exec)(result);
|
|
7106
7336
|
continue;
|
|
@@ -7746,7 +7976,10 @@ function* segment(source) {
|
|
|
7746
7976
|
if (!validate(source, exports.MAX_INPUT_SIZE)) return yield `\x07Too large input over ${exports.MAX_INPUT_SIZE.toLocaleString('en')} bytes.\n${source.slice(0, 1001)}`;
|
|
7747
7977
|
|
|
7748
7978
|
while (source !== '') {
|
|
7749
|
-
const result = parser(
|
|
7979
|
+
const result = parser({
|
|
7980
|
+
source,
|
|
7981
|
+
context: {}
|
|
7982
|
+
});
|
|
7750
7983
|
const rest = (0, parser_1.exec)(result);
|
|
7751
7984
|
const segs = (0, parser_1.eval)(result).length ? (0, parser_1.eval)(result) : [source.slice(0, source.length - rest.length)];
|
|
7752
7985
|
|
|
@@ -7873,7 +8106,9 @@ const combinator_1 = __webpack_require__(2087);
|
|
|
7873
8106
|
const text_1 = __webpack_require__(7763);
|
|
7874
8107
|
|
|
7875
8108
|
const delimiter = /[\s\x00-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]/;
|
|
7876
|
-
exports.escsource = (0, combinator_1.creation)(
|
|
8109
|
+
exports.escsource = (0, combinator_1.creation)(({
|
|
8110
|
+
source
|
|
8111
|
+
}) => {
|
|
7877
8112
|
if (source === '') return;
|
|
7878
8113
|
const i = source.search(delimiter);
|
|
7879
8114
|
|
|
@@ -7918,8 +8153,8 @@ const global_1 = __webpack_require__(4128);
|
|
|
7918
8153
|
const combinator_1 = __webpack_require__(2087);
|
|
7919
8154
|
|
|
7920
8155
|
exports.anyline = (0, combinator_1.line)(() => [[], '']);
|
|
7921
|
-
exports.emptyline = (0, combinator_1.line)(
|
|
7922
|
-
exports.contentline = (0, combinator_1.line)(
|
|
8156
|
+
exports.emptyline = (0, combinator_1.line)(i => (0, combinator_1.isEmpty)(i.source) ? [[], ''] : global_1.undefined);
|
|
8157
|
+
exports.contentline = (0, combinator_1.line)(i => !(0, combinator_1.isEmpty)(i.source) ? [[], ''] : global_1.undefined);
|
|
7923
8158
|
|
|
7924
8159
|
/***/ }),
|
|
7925
8160
|
|
|
@@ -7939,10 +8174,14 @@ const global_1 = __webpack_require__(4128);
|
|
|
7939
8174
|
const combinator_1 = __webpack_require__(2087);
|
|
7940
8175
|
|
|
7941
8176
|
function str(pattern) {
|
|
7942
|
-
return typeof pattern === 'string' ? (0, combinator_1.creation)(
|
|
8177
|
+
return typeof pattern === 'string' ? (0, combinator_1.creation)(({
|
|
8178
|
+
source
|
|
8179
|
+
}) => {
|
|
7943
8180
|
if (source === '') return;
|
|
7944
8181
|
return source.slice(0, pattern.length) === pattern ? [[pattern], source.slice(pattern.length)] : global_1.undefined;
|
|
7945
|
-
}) : (0, combinator_1.creation)(
|
|
8182
|
+
}) : (0, combinator_1.creation)(({
|
|
8183
|
+
source
|
|
8184
|
+
}) => {
|
|
7946
8185
|
if (source === '') return;
|
|
7947
8186
|
const m = source.match(pattern);
|
|
7948
8187
|
return m && m[0].length > 0 ? [[m[0]], source.slice(m[0].length)] : global_1.undefined;
|
|
@@ -7952,10 +8191,14 @@ function str(pattern) {
|
|
|
7952
8191
|
exports.str = str;
|
|
7953
8192
|
|
|
7954
8193
|
function stropt(pattern) {
|
|
7955
|
-
return typeof pattern === 'string' ? (0, combinator_1.creation)(
|
|
8194
|
+
return typeof pattern === 'string' ? (0, combinator_1.creation)(({
|
|
8195
|
+
source
|
|
8196
|
+
}) => {
|
|
7956
8197
|
if (source === '') return;
|
|
7957
8198
|
return source.slice(0, pattern.length) === pattern ? [[pattern], source.slice(pattern.length)] : global_1.undefined;
|
|
7958
|
-
}) : (0, combinator_1.creation)(
|
|
8199
|
+
}) : (0, combinator_1.creation)(({
|
|
8200
|
+
source
|
|
8201
|
+
}) => {
|
|
7959
8202
|
if (source === '') return;
|
|
7960
8203
|
const m = source.match(pattern);
|
|
7961
8204
|
return m ? [[m[0]], source.slice(m[0].length)] : global_1.undefined;
|
|
@@ -7993,7 +8236,10 @@ exports.text = (0, combinator_1.syntax)(0
|
|
|
7993
8236
|
/* Syntax.none */
|
|
7994
8237
|
, 1, 1, 0
|
|
7995
8238
|
/* State.none */
|
|
7996
|
-
, (
|
|
8239
|
+
, ({
|
|
8240
|
+
source,
|
|
8241
|
+
context
|
|
8242
|
+
}) => {
|
|
7997
8243
|
if (source === '') return;
|
|
7998
8244
|
const i = source.search(exports.delimiter);
|
|
7999
8245
|
|
|
@@ -8010,7 +8256,10 @@ exports.text = (0, combinator_1.syntax)(0
|
|
|
8010
8256
|
case '。':
|
|
8011
8257
|
case '!':
|
|
8012
8258
|
case '?':
|
|
8013
|
-
return (0, exports.text)(
|
|
8259
|
+
return (0, exports.text)({
|
|
8260
|
+
source: source.slice(1),
|
|
8261
|
+
context
|
|
8262
|
+
});
|
|
8014
8263
|
}
|
|
8015
8264
|
|
|
8016
8265
|
break;
|
|
@@ -8049,7 +8298,10 @@ exports.text = (0, combinator_1.syntax)(0
|
|
|
8049
8298
|
case '~':
|
|
8050
8299
|
case '=':
|
|
8051
8300
|
case '`':
|
|
8052
|
-
return source[1] === source[0] ? repeat(
|
|
8301
|
+
return source[1] === source[0] ? repeat({
|
|
8302
|
+
source,
|
|
8303
|
+
context
|
|
8304
|
+
}) : [[source[0]], source.slice(1)];
|
|
8053
8305
|
|
|
8054
8306
|
default:
|
|
8055
8307
|
const b = source[0].trimStart() === '';
|
|
@@ -8088,7 +8340,9 @@ const combinator_1 = __webpack_require__(2087);
|
|
|
8088
8340
|
|
|
8089
8341
|
const text_1 = __webpack_require__(7763);
|
|
8090
8342
|
|
|
8091
|
-
exports.unescsource = (0, combinator_1.creation)(
|
|
8343
|
+
exports.unescsource = (0, combinator_1.creation)(({
|
|
8344
|
+
source
|
|
8345
|
+
}) => {
|
|
8092
8346
|
if (source === '') return;
|
|
8093
8347
|
const i = source.search(text_1.delimiter);
|
|
8094
8348
|
|
|
@@ -8207,20 +8461,31 @@ function blankWith(starting, delimiter) {
|
|
|
8207
8461
|
exports.blankWith = blankWith;
|
|
8208
8462
|
|
|
8209
8463
|
function startLoose(parser, except) {
|
|
8210
|
-
return
|
|
8464
|
+
return input => isStartLoose(input, except) ? parser(input) : global_1.undefined;
|
|
8211
8465
|
}
|
|
8212
8466
|
|
|
8213
8467
|
exports.startLoose = startLoose;
|
|
8214
|
-
const isStartLoose = (0, memoize_1.reduce)((
|
|
8215
|
-
|
|
8216
|
-
|
|
8468
|
+
const isStartLoose = (0, memoize_1.reduce)(({
|
|
8469
|
+
source,
|
|
8470
|
+
context
|
|
8471
|
+
}, except) => {
|
|
8472
|
+
return isStartTight({
|
|
8473
|
+
source: source.replace(exports.regBlankStart, ''),
|
|
8474
|
+
context
|
|
8475
|
+
}, except);
|
|
8476
|
+
}, ({
|
|
8477
|
+
source
|
|
8478
|
+
}, except = '') => `${source}\x1E${except}`);
|
|
8217
8479
|
|
|
8218
8480
|
function startTight(parser, except) {
|
|
8219
|
-
return
|
|
8481
|
+
return input => isStartTight(input, except) ? parser(input) : global_1.undefined;
|
|
8220
8482
|
}
|
|
8221
8483
|
|
|
8222
8484
|
exports.startTight = startTight;
|
|
8223
|
-
const isStartTight = (0, memoize_1.reduce)((
|
|
8485
|
+
const isStartTight = (0, memoize_1.reduce)(({
|
|
8486
|
+
source,
|
|
8487
|
+
context
|
|
8488
|
+
}, except) => {
|
|
8224
8489
|
if (source === '') return true;
|
|
8225
8490
|
if (except && source.slice(0, except.length) === except) return false;
|
|
8226
8491
|
|
|
@@ -8236,7 +8501,10 @@ const isStartTight = (0, memoize_1.reduce)((source, context, except) => {
|
|
|
8236
8501
|
|
|
8237
8502
|
case '&':
|
|
8238
8503
|
switch (true) {
|
|
8239
|
-
case source.length > 2 && source[1] !== ' ' && (0, parser_1.eval)((0, htmlentity_1.unsafehtmlentity)(
|
|
8504
|
+
case source.length > 2 && source[1] !== ' ' && (0, parser_1.eval)((0, htmlentity_1.unsafehtmlentity)({
|
|
8505
|
+
source,
|
|
8506
|
+
context
|
|
8507
|
+
}))?.[0]?.trimStart() === '':
|
|
8240
8508
|
return false;
|
|
8241
8509
|
}
|
|
8242
8510
|
|
|
@@ -8253,7 +8521,9 @@ const isStartTight = (0, memoize_1.reduce)((source, context, except) => {
|
|
|
8253
8521
|
default:
|
|
8254
8522
|
return source[0].trimStart() !== '';
|
|
8255
8523
|
}
|
|
8256
|
-
}, (
|
|
8524
|
+
}, ({
|
|
8525
|
+
source
|
|
8526
|
+
}, except = '') => `${source}\x1E${except}`);
|
|
8257
8527
|
|
|
8258
8528
|
function isStartLooseNodes(nodes) {
|
|
8259
8529
|
if (nodes.length === 0) return true;
|
|
@@ -8937,7 +9207,10 @@ const dom_1 = __webpack_require__(3252);
|
|
|
8937
9207
|
const duff_1 = __webpack_require__(8099);
|
|
8938
9208
|
|
|
8939
9209
|
function quote(anchor, range) {
|
|
8940
|
-
if ((0, parser_1.exec)((0, cite_1.cite)(
|
|
9210
|
+
if ((0, parser_1.exec)((0, cite_1.cite)({
|
|
9211
|
+
source: `>>${anchor}`,
|
|
9212
|
+
context: {}
|
|
9213
|
+
})) !== '') throw new Error(`Invalid anchor: ${anchor}`);
|
|
8941
9214
|
fit(range);
|
|
8942
9215
|
const node = trim(range.cloneContents());
|
|
8943
9216
|
if (!node.firstChild) return '';
|