securemark 0.289.1 → 0.289.3
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 +8 -0
- package/design.md +2 -1
- package/dist/index.js +114 -90
- package/package.json +1 -1
- package/src/combinator/control/constraint/block.ts +1 -1
- package/src/combinator/control/constraint/contract.ts +7 -7
- package/src/combinator/control/constraint/line.ts +1 -1
- package/src/combinator/control/manipulation/clear.ts +7 -0
- package/src/combinator/control/manipulation/convert.ts +1 -1
- package/src/combinator/control/manipulation/duplicate.ts +4 -4
- package/src/combinator/control/manipulation/fallback.ts +3 -3
- package/src/combinator/control/manipulation/indent.ts +3 -3
- package/src/combinator/control/manipulation/lazy.ts +2 -2
- package/src/combinator/control/manipulation/match.ts +1 -1
- package/src/combinator/control/manipulation/recovery.ts +3 -3
- package/src/combinator/control/manipulation/reverse.ts +1 -1
- package/src/combinator/control/manipulation/scope.ts +3 -3
- package/src/combinator/control/manipulation/surround.ts +79 -69
- package/src/combinator/control/manipulation/trim.ts +3 -3
- package/src/combinator/control/monad/bind.ts +6 -6
- package/src/combinator/control/monad/fmap.ts +6 -6
- package/src/combinator/data/parser/context/delimiter.ts +21 -19
- package/src/combinator/data/parser/context.ts +8 -8
- package/src/combinator/data/parser/inits.ts +4 -4
- package/src/combinator/data/parser/sequence.ts +4 -4
- package/src/combinator/data/parser/some.ts +3 -3
- package/src/combinator/data/parser/subsequence.ts +3 -3
- package/src/combinator/data/parser/tails.ts +3 -3
- package/src/combinator/data/parser/union.ts +3 -3
- package/src/combinator/data/parser.ts +13 -13
- package/src/combinator.ts +1 -0
- package/src/parser/block/extension/figure.ts +1 -1
- package/src/parser/block/extension/table.ts +3 -3
- package/src/parser/block/olist.ts +4 -4
- package/src/parser/block/reply/cite.ts +3 -3
- package/src/parser/block/ulist.ts +1 -1
- package/src/parser/context.ts +5 -6
- package/src/parser/inline/annotation.ts +3 -1
- package/src/parser/inline/autolink/hashnum.ts +5 -1
- package/src/parser/inline/bracket.ts +8 -4
- package/src/parser/inline/code.ts +2 -1
- package/src/parser/inline/extension/index.ts +3 -1
- package/src/parser/inline/extension/label.ts +1 -1
- package/src/parser/inline/extension/placeholder.ts +2 -1
- package/src/parser/inline/link.ts +5 -2
- package/src/parser/inline/media.ts +4 -2
- package/src/parser/inline/reference.ts +2 -1
- package/src/parser/inline/ruby.ts +4 -2
- package/src/parser/inline/template.ts +2 -1
- package/src/parser/util.ts +10 -10
- package/src/parser/visibility.ts +11 -11
- package/src/util/quote.ts +1 -1
package/CHANGELOG.md
CHANGED
package/design.md
CHANGED
|
@@ -321,9 +321,10 @@ Markdownに本当に必要な仕様はSecuremarkのクラス化制約のよう
|
|
|
321
321
|
- 画像のalt(`![*a*]()`, `![![a]()`)をMarkdownとして解釈
|
|
322
322
|
- 再帰的バックトラック回避の必要上修正不可能
|
|
323
323
|
- リンクのURLを効率的に解析不可能
|
|
324
|
-
- altはまだしもURLは文脈依存構文としての解析を避けられないため再帰もまた避けられず公式デモページのCommonMarkで`[](`を1
|
|
324
|
+
- altはまだしもURLは文脈依存構文としての解析を避けられないため再帰もまた避けられず公式デモページのCommonMarkで`[](`を1万回程度繰り返しただけで解析時間が1秒を超える
|
|
325
325
|
- この欠陥は入れ子数を制限することで回避可能だがこれはCommonmarkは文脈依存構文全般に入れ子数制限を要することを意味する
|
|
326
326
|
- CommonMarkは最初のバージョンから数年後にこの欠陥を入れ子数制限により修正しこれにより最悪計算量が当初の想定の2nから32nへと32倍に劇的に悪化したことから文脈自由言語および最小計算量としての設計と開発が破綻し失敗に終わったことが明らかである
|
|
327
|
+
- GFMも`[1]([2]()(...[34]()...))`で32回の再帰的バックトラックを行い最悪計算量が32nであることが確認できる
|
|
327
328
|
- これほど計算量が悪ければ入れ子数制限付き文脈依存言語と大差ない計算量であり素直に文脈依存言語として作り直したほうが遥かに拡張性と発展性が高く優れている
|
|
328
329
|
- 計算資源は使うためにあるにもかかわらず言語と一致しない不適切な解析方法を使用してまでこの程度の計算資源を惜しんで人間に不便と不自由を強いて生産性を下げるのは本末転倒である
|
|
329
330
|
- 計算機は人間の生産性に奉仕しなければならない
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.289.
|
|
1
|
+
/*! securemark v0.289.3 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"));
|
|
@@ -2680,6 +2680,7 @@ __exportStar(__webpack_require__(4271), exports);
|
|
|
2680
2680
|
__exportStar(__webpack_require__(7190), exports);
|
|
2681
2681
|
__exportStar(__webpack_require__(549), exports);
|
|
2682
2682
|
__exportStar(__webpack_require__(7723), exports);
|
|
2683
|
+
__exportStar(__webpack_require__(8606), exports);
|
|
2683
2684
|
__exportStar(__webpack_require__(5781), exports);
|
|
2684
2685
|
__exportStar(__webpack_require__(1638), exports);
|
|
2685
2686
|
__exportStar(__webpack_require__(6572), exports);
|
|
@@ -2821,6 +2822,24 @@ exports.isBlank = isBlank;
|
|
|
2821
2822
|
|
|
2822
2823
|
/***/ },
|
|
2823
2824
|
|
|
2825
|
+
/***/ 8606
|
|
2826
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
2827
|
+
|
|
2828
|
+
"use strict";
|
|
2829
|
+
|
|
2830
|
+
|
|
2831
|
+
Object.defineProperty(exports, "__esModule", ({
|
|
2832
|
+
value: true
|
|
2833
|
+
}));
|
|
2834
|
+
exports.clear = void 0;
|
|
2835
|
+
const fmap_1 = __webpack_require__(2705);
|
|
2836
|
+
function clear(parser) {
|
|
2837
|
+
return (0, fmap_1.fmap)(parser, () => []);
|
|
2838
|
+
}
|
|
2839
|
+
exports.clear = clear;
|
|
2840
|
+
|
|
2841
|
+
/***/ },
|
|
2842
|
+
|
|
2824
2843
|
/***/ 6572
|
|
2825
2844
|
(__unused_webpack_module, exports, __webpack_require__) {
|
|
2826
2845
|
|
|
@@ -2972,7 +2991,7 @@ function indent(opener, parser, separation = false) {
|
|
|
2972
2991
|
if (typeof opener === 'function') return indent(/^([ \t])\1*/, opener, parser);
|
|
2973
2992
|
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, ({
|
|
2974
2993
|
source
|
|
2975
|
-
}) => [[source], '']))), ([indent]) => indent.length * 2 + +(indent[0] === ' '), {})
|
|
2994
|
+
}) => [[source], '']))), ([indent]) => indent.length * 2 + +(indent[0] === ' '), {})), separation), (lines, rest, context) => {
|
|
2976
2995
|
// 影響する使用はないはず
|
|
2977
2996
|
//const { backtracks } = context;
|
|
2978
2997
|
//context.backtracks = {};
|
|
@@ -3022,7 +3041,7 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
3022
3041
|
exports.match = void 0;
|
|
3023
3042
|
const parser_1 = __webpack_require__(605);
|
|
3024
3043
|
const combinator_1 = __webpack_require__(3484);
|
|
3025
|
-
function match(pattern, f, cost =
|
|
3044
|
+
function match(pattern, f, cost = false) {
|
|
3026
3045
|
return input => {
|
|
3027
3046
|
const {
|
|
3028
3047
|
source,
|
|
@@ -3156,11 +3175,10 @@ exports.rewrite = rewrite;
|
|
|
3156
3175
|
Object.defineProperty(exports, "__esModule", ({
|
|
3157
3176
|
value: true
|
|
3158
3177
|
}));
|
|
3159
|
-
exports.
|
|
3178
|
+
exports.close = exports.open = exports.surround = void 0;
|
|
3160
3179
|
const parser_1 = __webpack_require__(605);
|
|
3161
|
-
const fmap_1 = __webpack_require__(2705);
|
|
3162
3180
|
const array_1 = __webpack_require__(6876);
|
|
3163
|
-
function surround(opener, parser, closer, optional = false, f, g, backtracks = [],
|
|
3181
|
+
function surround(opener, parser, closer, optional = false, f, g, backtracks = [], backtrackstate = 0) {
|
|
3164
3182
|
switch (typeof opener) {
|
|
3165
3183
|
case 'string':
|
|
3166
3184
|
case 'object':
|
|
@@ -3171,23 +3189,24 @@ function surround(opener, parser, closer, optional = false, f, g, backtracks = [
|
|
|
3171
3189
|
case 'object':
|
|
3172
3190
|
closer = match(closer);
|
|
3173
3191
|
}
|
|
3192
|
+
const statesize = 2;
|
|
3174
3193
|
return ({
|
|
3175
3194
|
source,
|
|
3176
3195
|
context
|
|
3177
3196
|
}) => {
|
|
3178
|
-
const
|
|
3179
|
-
if (
|
|
3197
|
+
const sme_ = source;
|
|
3198
|
+
if (sme_ === '') return;
|
|
3180
3199
|
const {
|
|
3181
3200
|
linebreak
|
|
3182
3201
|
} = context;
|
|
3183
3202
|
context.linebreak = undefined;
|
|
3184
|
-
const
|
|
3185
|
-
source:
|
|
3203
|
+
const resultS = opener({
|
|
3204
|
+
source: sme_,
|
|
3186
3205
|
context
|
|
3187
3206
|
});
|
|
3188
|
-
if (
|
|
3189
|
-
const
|
|
3190
|
-
const
|
|
3207
|
+
if (resultS === undefined) return void revert(context, linebreak);
|
|
3208
|
+
const nodesS = (0, parser_1.eval)(resultS);
|
|
3209
|
+
const me_ = (0, parser_1.exec)(resultS);
|
|
3191
3210
|
for (const backtrack of backtracks) {
|
|
3192
3211
|
if (backtrack & 1) {
|
|
3193
3212
|
const {
|
|
@@ -3195,49 +3214,48 @@ function surround(opener, parser, closer, optional = false, f, g, backtracks = [
|
|
|
3195
3214
|
backtrack: state = 0,
|
|
3196
3215
|
offset = 0
|
|
3197
3216
|
} = context;
|
|
3198
|
-
for (let i = 0; i < source.length -
|
|
3217
|
+
for (let i = 0; i < source.length - me_.length; ++i) {
|
|
3199
3218
|
if (source[i] !== source[0]) break;
|
|
3200
|
-
const pos = source.length + offset -
|
|
3219
|
+
const pos = source.length - i + offset - 1;
|
|
3201
3220
|
if (!(pos in backtracks)) continue;
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
if (backtracks[pos] & 1 << (backtrack >>> 2) + shift) return void revert(context, linebreak);
|
|
3221
|
+
const shift = backtrack >>> statesize & state >>> statesize ? state & (1 << statesize) - 1 : 0;
|
|
3222
|
+
if (backtracks[pos] & 1 << size(backtrack >>> statesize) + shift) return void revert(context, linebreak);
|
|
3205
3223
|
}
|
|
3206
3224
|
}
|
|
3207
3225
|
}
|
|
3208
3226
|
const {
|
|
3209
|
-
backtrack
|
|
3227
|
+
backtrack = 0
|
|
3210
3228
|
} = context;
|
|
3211
|
-
context.backtrack =
|
|
3212
|
-
const
|
|
3213
|
-
source:
|
|
3229
|
+
context.backtrack = backtrack | backtrackstate;
|
|
3230
|
+
const resultM = me_ !== '' ? parser({
|
|
3231
|
+
source: me_,
|
|
3214
3232
|
context
|
|
3215
3233
|
}) : undefined;
|
|
3216
|
-
context.backtrack =
|
|
3217
|
-
const
|
|
3218
|
-
const
|
|
3219
|
-
if (!
|
|
3220
|
-
const
|
|
3221
|
-
source:
|
|
3234
|
+
context.backtrack = backtrack;
|
|
3235
|
+
const nodesM = (0, parser_1.eval)(resultM);
|
|
3236
|
+
const e_ = (0, parser_1.exec)(resultM, me_);
|
|
3237
|
+
if (!nodesM && !optional) return void revert(context, linebreak);
|
|
3238
|
+
const resultE = closer({
|
|
3239
|
+
source: e_,
|
|
3222
3240
|
context
|
|
3223
3241
|
});
|
|
3224
|
-
const
|
|
3225
|
-
const rest = (0, parser_1.exec)(
|
|
3226
|
-
if (rest.length ===
|
|
3242
|
+
const nodesE = (0, parser_1.eval)(resultE);
|
|
3243
|
+
const rest = (0, parser_1.exec)(resultE, e_);
|
|
3244
|
+
if (rest.length === sme_.length) return void revert(context, linebreak);
|
|
3227
3245
|
for (const backtrack of backtracks) {
|
|
3228
|
-
if (backtrack & 2 &&
|
|
3246
|
+
if (backtrack & 2 && nodesE === undefined) {
|
|
3229
3247
|
const {
|
|
3230
3248
|
backtracks = {},
|
|
3231
3249
|
backtrack: state = 0,
|
|
3232
3250
|
offset = 0
|
|
3233
3251
|
} = context;
|
|
3234
|
-
|
|
3235
|
-
const shift = backtrack >>>
|
|
3236
|
-
backtracks[
|
|
3252
|
+
const pos = source.length + offset - 1;
|
|
3253
|
+
const shift = backtrack >>> statesize & state >>> statesize ? state & (1 << statesize) - 1 : 0;
|
|
3254
|
+
backtracks[pos] |= 1 << size(backtrack >>> statesize) + shift;
|
|
3237
3255
|
}
|
|
3238
3256
|
}
|
|
3239
|
-
context.recent = [
|
|
3240
|
-
const result =
|
|
3257
|
+
context.recent = [sme_.slice(0, sme_.length - me_.length), me_.slice(0, me_.length - e_.length), e_.slice(0, e_.length - rest.length)];
|
|
3258
|
+
const result = nodesE ? f ? f([nodesS, nodesM, nodesE], rest, context) : [(0, array_1.push)((0, array_1.unshift)(nodesS, nodesM ?? []), nodesE), rest] : g ? g([nodesS, nodesM, me_], rest, context) : undefined;
|
|
3241
3259
|
if (result) {
|
|
3242
3260
|
context.linebreak ??= linebreak;
|
|
3243
3261
|
} else {
|
|
@@ -3247,6 +3265,14 @@ function surround(opener, parser, closer, optional = false, f, g, backtracks = [
|
|
|
3247
3265
|
};
|
|
3248
3266
|
}
|
|
3249
3267
|
exports.surround = surround;
|
|
3268
|
+
function open(opener, parser, optional = false) {
|
|
3269
|
+
return surround(opener, parser, '', optional);
|
|
3270
|
+
}
|
|
3271
|
+
exports.open = open;
|
|
3272
|
+
function close(parser, closer, optional = false) {
|
|
3273
|
+
return surround('', parser, closer, optional);
|
|
3274
|
+
}
|
|
3275
|
+
exports.close = close;
|
|
3250
3276
|
function match(pattern) {
|
|
3251
3277
|
switch (typeof pattern) {
|
|
3252
3278
|
case 'string':
|
|
@@ -3265,18 +3291,16 @@ function match(pattern) {
|
|
|
3265
3291
|
function revert(context, linebreak) {
|
|
3266
3292
|
context.linebreak = linebreak;
|
|
3267
3293
|
}
|
|
3268
|
-
function
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
return (0, fmap_1.fmap)(parser, () => []);
|
|
3294
|
+
function size(bits) {
|
|
3295
|
+
if (bits === 0) return 0;
|
|
3296
|
+
let p = 0;
|
|
3297
|
+
for (let s = 32 / 2; s > 0; s >>>= 1) {
|
|
3298
|
+
const q = p + s;
|
|
3299
|
+
if (bits >>> q === 0) continue;
|
|
3300
|
+
p = q;
|
|
3301
|
+
}
|
|
3302
|
+
return p + 1;
|
|
3278
3303
|
}
|
|
3279
|
-
exports.clear = clear;
|
|
3280
3304
|
|
|
3281
3305
|
/***/ },
|
|
3282
3306
|
|
|
@@ -3548,7 +3572,6 @@ exports.constraint = constraint;
|
|
|
3548
3572
|
"use strict";
|
|
3549
3573
|
|
|
3550
3574
|
|
|
3551
|
-
var _a;
|
|
3552
3575
|
Object.defineProperty(exports, "__esModule", ({
|
|
3553
3576
|
value: true
|
|
3554
3577
|
}));
|
|
@@ -3561,14 +3584,24 @@ class Delimiters {
|
|
|
3561
3584
|
this.stack = [];
|
|
3562
3585
|
this.states = [];
|
|
3563
3586
|
}
|
|
3564
|
-
static signature(pattern) {
|
|
3587
|
+
static signature(pattern, linebreakable) {
|
|
3565
3588
|
switch (typeof pattern) {
|
|
3566
3589
|
case 'undefined':
|
|
3567
3590
|
return `undefined`;
|
|
3568
3591
|
case 'string':
|
|
3569
|
-
return `s:${pattern}`;
|
|
3592
|
+
return `s:${pattern}:${+linebreakable}`;
|
|
3570
3593
|
case 'object':
|
|
3571
|
-
return `r/${pattern.source}/${
|
|
3594
|
+
return `r/${pattern.source}/${+linebreakable}`;
|
|
3595
|
+
}
|
|
3596
|
+
}
|
|
3597
|
+
static matcher(pattern) {
|
|
3598
|
+
switch (typeof pattern) {
|
|
3599
|
+
case 'undefined':
|
|
3600
|
+
return () => undefined;
|
|
3601
|
+
case 'string':
|
|
3602
|
+
return source => source.slice(0, pattern.length) === pattern || undefined;
|
|
3603
|
+
case 'object':
|
|
3604
|
+
return source => pattern.test(source) || undefined;
|
|
3572
3605
|
}
|
|
3573
3606
|
}
|
|
3574
3607
|
push(delims) {
|
|
@@ -3588,13 +3621,14 @@ class Delimiters {
|
|
|
3588
3621
|
} = delims[i];
|
|
3589
3622
|
const memory = registry(signature);
|
|
3590
3623
|
const index = memory[0]?.index ?? delimiters.length;
|
|
3591
|
-
if (memory.length === 0
|
|
3624
|
+
if (memory.length === 0) {
|
|
3592
3625
|
const delimiter = {
|
|
3626
|
+
memory,
|
|
3593
3627
|
index,
|
|
3594
3628
|
signature,
|
|
3595
3629
|
matcher,
|
|
3596
3630
|
precedence,
|
|
3597
|
-
linebreakable
|
|
3631
|
+
linebreakable,
|
|
3598
3632
|
state: true
|
|
3599
3633
|
};
|
|
3600
3634
|
delimiters[index] = delimiter;
|
|
@@ -3608,14 +3642,15 @@ class Delimiters {
|
|
|
3608
3642
|
}
|
|
3609
3643
|
pop(count) {
|
|
3610
3644
|
const {
|
|
3611
|
-
registry,
|
|
3612
3645
|
delimiters,
|
|
3613
3646
|
stack
|
|
3614
3647
|
} = this;
|
|
3615
3648
|
for (let i = 0; i < count; ++i) {
|
|
3616
3649
|
const index = stack.pop();
|
|
3617
3650
|
if (index === -1) continue;
|
|
3618
|
-
const
|
|
3651
|
+
const {
|
|
3652
|
+
memory
|
|
3653
|
+
} = delimiters[index];
|
|
3619
3654
|
if (memory.length === 1) {
|
|
3620
3655
|
memory.pop();
|
|
3621
3656
|
delimiters.pop();
|
|
@@ -3671,17 +3706,6 @@ class Delimiters {
|
|
|
3671
3706
|
}
|
|
3672
3707
|
}
|
|
3673
3708
|
exports.Delimiters = Delimiters;
|
|
3674
|
-
_a = Delimiters;
|
|
3675
|
-
Delimiters.matcher = (0, memoize_1.memoize)(pattern => {
|
|
3676
|
-
switch (typeof pattern) {
|
|
3677
|
-
case 'undefined':
|
|
3678
|
-
return () => undefined;
|
|
3679
|
-
case 'string':
|
|
3680
|
-
return source => source.slice(0, pattern.length) === pattern || undefined;
|
|
3681
|
-
case 'object':
|
|
3682
|
-
return source => pattern.test(source) || undefined;
|
|
3683
|
-
}
|
|
3684
|
-
}, _a.signature);
|
|
3685
3709
|
|
|
3686
3710
|
/***/ },
|
|
3687
3711
|
|
|
@@ -3780,7 +3804,7 @@ function some(parser, end, delimiters = [], limit = -1) {
|
|
|
3780
3804
|
if (typeof end === 'number') return some(parser, undefined, delimiters, end);
|
|
3781
3805
|
const match = delimiter_1.Delimiters.matcher(end);
|
|
3782
3806
|
const delims = delimiters.map(([delimiter, precedence, linebreakable = true]) => ({
|
|
3783
|
-
signature: delimiter_1.Delimiters.signature(delimiter),
|
|
3807
|
+
signature: delimiter_1.Delimiters.signature(delimiter, linebreakable),
|
|
3784
3808
|
matcher: delimiter_1.Delimiters.matcher(delimiter),
|
|
3785
3809
|
precedence,
|
|
3786
3810
|
linebreakable
|
|
@@ -4794,7 +4818,7 @@ const memoize_1 = __webpack_require__(6925);
|
|
|
4794
4818
|
const dom_1 = __webpack_require__(394);
|
|
4795
4819
|
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)([
|
|
4796
4820
|
// All parsers which can include closing terms.
|
|
4797
|
-
(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, {})
|
|
4821
|
+
(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, {})));
|
|
4798
4822
|
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', {
|
|
4799
4823
|
class: 'figindex'
|
|
4800
4824
|
}), (0, dom_1.html)('span', {
|
|
@@ -5341,7 +5365,7 @@ const openers = {
|
|
|
5341
5365
|
'(': /^\(([0-9]*|[a-z]*)(?![^)\n])\)?(?:-(?!-)[0-9]*)*(?:$|\s)/
|
|
5342
5366
|
};
|
|
5343
5367
|
exports.olist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(new RegExp([/^([0-9]+|[a-z]+|[A-Z]+)(?:-[0-9]+)*\.(?=[^\S\n]|\n[^\S\n]*\S)/.source, /^\(([0-9]+|[a-z]+)\)(?:-[0-9]+)*(?=[^\S\n]|\n[^\S\n]*\S)/.source].join('|')), exports.olist_)));
|
|
5344
|
-
exports.olist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.union)([(0, combinator_1.match)(openers['.'], (0, memoize_1.memoize)(ms => list(type(ms[1]), '.'), ms => idx(ms[1]), [])
|
|
5368
|
+
exports.olist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.union)([(0, combinator_1.match)(openers['.'], (0, memoize_1.memoize)(ms => list(type(ms[1]), '.'), ms => idx(ms[1]), [])), (0, combinator_1.match)(openers['('], (0, memoize_1.memoize)(ms => list(type(ms[1]), '('), ms => idx(ms[1]), []))])));
|
|
5345
5369
|
const list = (type, form) => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.recursion)(3 /* Recursion.listitem */, (0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(heads[form], (0, combinator_1.subsequence)([ulist_1.checkbox, (0, combinator_1.trim)((0, visibility_1.visualize)((0, util_1.lineable)((0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline]))))))]), true)), (0, combinator_1.indent)((0, combinator_1.union)([ulist_1.ulist_, exports.olist_, ilist_1.ilist_]))]), ilist_1.ilistitem), ns => [(0, dom_1.html)('li', {
|
|
5346
5370
|
'data-index': (0, inline_1.dataindex)(ns),
|
|
5347
5371
|
'data-marker': ns.shift() || undefined
|
|
@@ -5349,10 +5373,10 @@ const list = (type, form) => (0, combinator_1.fmap)((0, combinator_1.some)((0, c
|
|
|
5349
5373
|
const heads = {
|
|
5350
5374
|
'.': (0, combinator_1.focus)(openers['.'], ({
|
|
5351
5375
|
source
|
|
5352
|
-
}) => [[source.trimEnd().split('.', 1)[0] + '.'], '']
|
|
5376
|
+
}) => [[source.trimEnd().split('.', 1)[0] + '.'], '']),
|
|
5353
5377
|
'(': (0, combinator_1.focus)(openers['('], ({
|
|
5354
5378
|
source
|
|
5355
|
-
}) => [[source.trimEnd().replace(/^\($/, '(1)').replace(/^\((\w+)$/, '($1)')], '']
|
|
5379
|
+
}) => [[source.trimEnd().replace(/^\($/, '(1)').replace(/^\((\w+)$/, '($1)')], ''])
|
|
5356
5380
|
};
|
|
5357
5381
|
function idx(value) {
|
|
5358
5382
|
switch (value) {
|
|
@@ -5525,15 +5549,15 @@ exports.cite = (0, combinator_1.line)((0, combinator_1.fmap)((0, combinator_1.va
|
|
|
5525
5549
|
source
|
|
5526
5550
|
}) => [[(0, dom_1.html)('a', {
|
|
5527
5551
|
class: 'anchor'
|
|
5528
|
-
}, source)], '']
|
|
5552
|
+
}, source)], '']), (0, combinator_1.focus)(/^>>https?:\/\/\S+(?=\s*$)/, ({
|
|
5529
5553
|
source
|
|
5530
5554
|
}) => [[(0, dom_1.html)('a', {
|
|
5531
5555
|
class: 'anchor',
|
|
5532
5556
|
href: source.slice(2).trimEnd(),
|
|
5533
5557
|
target: '_blank'
|
|
5534
|
-
}, source)], '']
|
|
5558
|
+
}, source)], '']), (0, combinator_1.focus)(/^>>.+(?=\s*$)/, ({
|
|
5535
5559
|
source
|
|
5536
|
-
}) => [[source], '']
|
|
5560
|
+
}) => [[source], ''])]))), ([quotes, node]) => [(0, dom_1.html)('span', typeof node === 'object' ? {
|
|
5537
5561
|
class: 'cite'
|
|
5538
5562
|
} : {
|
|
5539
5563
|
class: 'cite invalid',
|
|
@@ -5668,7 +5692,7 @@ exports.checkbox = (0, combinator_1.focus)(/^\[[xX ]\](?=$|\s)/, ({
|
|
|
5668
5692
|
source
|
|
5669
5693
|
}) => [[(0, dom_1.html)('span', {
|
|
5670
5694
|
class: 'checkbox'
|
|
5671
|
-
}, source[1].trimStart() ? '☑' : '☐')], '']
|
|
5695
|
+
}, source[1].trimStart() ? '☑' : '☐')], '']);
|
|
5672
5696
|
function fillFirstLine(ns) {
|
|
5673
5697
|
return ns.length === 1 && typeof ns[0] === 'object' && ['UL', 'OL'].includes(ns[0].tagName) ? (0, array_1.unshift)([(0, dom_1.html)('br')], ns) : ns;
|
|
5674
5698
|
}
|
|
@@ -5889,7 +5913,7 @@ const visibility_1 = __webpack_require__(6364);
|
|
|
5889
5913
|
const dom_1 = __webpack_require__(394);
|
|
5890
5914
|
exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(128 /* State.annotation */, false, (0, combinator_1.surround)('((', (0, combinator_1.precedence)(1, (0, combinator_1.state)(128 /* State.annotation */ | 4 /* State.media */, (0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ')', [['\n', 9], [')', 1]])))), '))', false, ([, ns], rest) => (0, visibility_1.trimBlankNodeEnd)(ns).length > 0 ? [[(0, dom_1.html)('sup', {
|
|
5891
5915
|
class: 'annotation'
|
|
5892
|
-
}, [(0, dom_1.html)('span', (0, dom_1.defrag)(ns))])], rest] : undefined, undefined, [3 |
|
|
5916
|
+
}, [(0, dom_1.html)('span', (0, dom_1.defrag)(ns))])], rest] : undefined, undefined, [3 | 32 /* Backtrack.linedoublebracket */, 1 | 16 /* Backtrack.linebracket */], 8 /* Backtrack.bracket */ | 1 /* BacktrackState.nobreak */)));
|
|
5893
5917
|
|
|
5894
5918
|
/***/ },
|
|
5895
5919
|
|
|
@@ -6046,7 +6070,7 @@ const link_1 = __webpack_require__(3628);
|
|
|
6046
6070
|
const hashtag_1 = __webpack_require__(5764);
|
|
6047
6071
|
const source_1 = __webpack_require__(8745);
|
|
6048
6072
|
const dom_1 = __webpack_require__(394);
|
|
6049
|
-
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, {
|
|
6073
|
+
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].join('').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, {
|
|
6050
6074
|
class: 'hashnum',
|
|
6051
6075
|
href: null
|
|
6052
6076
|
})]))), ({
|
|
@@ -6153,7 +6177,7 @@ exports.code = (0, combinator_1.match)(/^(`+)(?!`)([^\n]*?[^`\n])\1(?!`)/, ([who
|
|
|
6153
6177
|
source
|
|
6154
6178
|
}) => [[(0, dom_1.html)('code', {
|
|
6155
6179
|
'data-src': whole
|
|
6156
|
-
}, format(body))], source.slice(whole.length)]);
|
|
6180
|
+
}, format(body))], source.slice(whole.length)], true);
|
|
6157
6181
|
function format(text) {
|
|
6158
6182
|
return `${text[0]}${text.at(-1)}` === ' ' && text.trimStart() ? text.slice(1, -1) : text;
|
|
6159
6183
|
}
|
|
@@ -6313,7 +6337,7 @@ const array_1 = __webpack_require__(6876);
|
|
|
6313
6337
|
const dom_1 = __webpack_require__(394);
|
|
6314
6338
|
exports.index = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(32 /* State.index */, false, (0, combinator_1.fmap)((0, indexee_1.indexee)((0, combinator_1.surround)('[#', (0, combinator_1.precedence)(1, (0, combinator_1.state)(251 /* State.linkers */ | 4 /* State.media */, (0, visibility_1.tightStart)((0, combinator_1.some)((0, combinator_1.inits)([inline_1.inline, exports.signature]), ']', [['\n', 9], [']', 1]])))), ']', false, ([, ns], rest) => (0, visibility_1.trimBlankNodeEnd)(ns).length > 0 ? [[(0, dom_1.html)('a', {
|
|
6315
6339
|
'data-index': dataindex(ns)
|
|
6316
|
-
}, (0, dom_1.defrag)(ns))], rest] : undefined, undefined, [3 |
|
|
6340
|
+
}, (0, dom_1.defrag)(ns))], rest] : undefined, undefined, [3 | 16 /* Backtrack.linebracket */], 8 /* Backtrack.bracket */ | 1 /* BacktrackState.nobreak */)), ([el]) => [(0, dom_1.define)(el, {
|
|
6317
6341
|
id: el.id ? null : undefined,
|
|
6318
6342
|
class: 'index',
|
|
6319
6343
|
href: el.id ? `#${el.id}` : undefined
|
|
@@ -6518,7 +6542,7 @@ const source_1 = __webpack_require__(8745);
|
|
|
6518
6542
|
const dom_1 = __webpack_require__(394);
|
|
6519
6543
|
const body = (0, source_1.str)(/^\$[A-Za-z]*(?:(?:-[A-Za-z][0-9A-Za-z]*)+|-(?:(?:0|[1-9][0-9]*)\.)*(?:0|[1-9][0-9]*)(?![0-9A-Za-z]))/);
|
|
6520
6544
|
exports.segment = (0, combinator_1.clear)((0, combinator_1.union)([(0, combinator_1.surround)('[', body, ']'), body]));
|
|
6521
|
-
exports.label = (0, combinator_1.constraint)(16 /* State.label */, false, (0, combinator_1.fmap)((0, combinator_1.union)([(0, combinator_1.surround)('[', body, ']', false, undefined, undefined, [1 |
|
|
6545
|
+
exports.label = (0, combinator_1.constraint)(16 /* State.label */, false, (0, combinator_1.fmap)((0, combinator_1.union)([(0, combinator_1.surround)('[', body, ']', false, undefined, undefined, [1 | 16 /* Backtrack.linebracket */, 1]), body]), ([text]) => [(0, dom_1.html)('a', {
|
|
6522
6546
|
class: 'label',
|
|
6523
6547
|
'data-label': text.slice(text[1] === '-' ? 0 : 1).toLowerCase()
|
|
6524
6548
|
}, text)]));
|
|
@@ -6734,7 +6758,7 @@ const optspec = {
|
|
|
6734
6758
|
rel: ['nofollow']
|
|
6735
6759
|
};
|
|
6736
6760
|
Object.setPrototypeOf(optspec, null);
|
|
6737
|
-
exports.textlink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(8 /* State.link */, false, (0, combinator_1.creation)(10, (0, combinator_1.precedence)(1, (0, combinator_1.state)(251 /* State.linkers */ | 4 /* State.media */, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [['\n', 9], [']', 1]])), ']', true, undefined, undefined, [1 |
|
|
6761
|
+
exports.textlink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(8 /* State.link */, false, (0, combinator_1.creation)(10, (0, combinator_1.precedence)(1, (0, combinator_1.state)(251 /* State.linkers */ | 4 /* State.media */, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [['\n', 9], [']', 1]])), ']', true, undefined, undefined, [1 | 16 /* Backtrack.linebracket */], 8 /* Backtrack.bracket */ | 1 /* BacktrackState.nobreak */)), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/, false, undefined, undefined, [3 | 128 /* Backtrack.link */]))])), ([params, content = []], rest, context) => {
|
|
6738
6762
|
if (content.length !== 0 && (0, visibility_1.trimBlankNodeEnd)(content).length === 0) return;
|
|
6739
6763
|
return [[parse((0, dom_1.defrag)(content), params, context)], rest];
|
|
6740
6764
|
}))))));
|
|
@@ -6917,7 +6941,7 @@ const optspec = {
|
|
|
6917
6941
|
rel: undefined
|
|
6918
6942
|
};
|
|
6919
6943
|
Object.setPrototypeOf(optspec, null);
|
|
6920
|
-
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 |
|
|
6944
|
+
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 | 128 /* Backtrack.link */]))]), ([as, bs]) => bs ? [[as.join('').trim() || as.join('')], bs] : [[''], as]), ([[text]]) => text === '' || text.trim() !== ''), ([[text], params], rest, context) => {
|
|
6921
6945
|
const INSECURE_URI = params.shift();
|
|
6922
6946
|
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);
|
|
6923
6947
|
let cache;
|
|
@@ -6997,7 +7021,7 @@ const array_1 = __webpack_require__(6876);
|
|
|
6997
7021
|
const util_1 = __webpack_require__(4992);
|
|
6998
7022
|
exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(64 /* State.reference */, false, (0, combinator_1.surround)((0, source_1.str)('[['), (0, combinator_1.precedence)(1, (0, combinator_1.state)(128 /* State.annotation */ | 64 /* State.reference */ | 4 /* State.media */, (0, combinator_1.subsequence)([abbr, (0, visibility_1.trimBlankStart)((0, combinator_1.some)(inline_1.inline, ']', [['\n', 9], [']', 1]]))]))), ']]', false, ([, ns], rest) => (0, visibility_1.trimBlankNodeEnd)(ns).length > 0 ? [[(0, dom_1.html)('sup', attributes(ns), [(0, dom_1.html)('span', (0, dom_1.defrag)(ns))])], rest] : undefined, ([as, bs], rest, {
|
|
6999
7023
|
state = 0
|
|
7000
|
-
}) => state & 128 /* State.annotation */ ? [(0, array_1.unshift)(as, bs), rest] : undefined, [3 |
|
|
7024
|
+
}) => state & 128 /* State.annotation */ ? [(0, array_1.unshift)(as, bs), rest] : undefined, [3 | 32 /* Backtrack.linedoublebracket */, 1 | 16 /* Backtrack.linebracket */], 8 /* Backtrack.bracket */ | 1 /* BacktrackState.nobreak */)));
|
|
7001
7025
|
// Chicago-Style
|
|
7002
7026
|
const abbr = (0, combinator_1.surround)('^', (0, combinator_1.union)([(0, source_1.str)(/^(?=[A-Z])(?:[0-9A-Za-z]'?|(?:[-.:]|\.?\??,? ?)(?!['\-.:?, ]))+/)]), /^\|?(?=]])|^\|[^\S\n]*/, true, ([, ns], rest) => ns ? [['\n', ns[0].trimEnd()], rest.replace(visibility_1.blank.start, '')] : [[''], `^${rest}`], ([,, rest]) => [[''], `^${rest}`]);
|
|
7003
7027
|
function attributes(ns) {
|
|
@@ -7073,13 +7097,13 @@ exports.ruby = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinato
|
|
|
7073
7097
|
}), [undefined])[0];
|
|
7074
7098
|
ns && ns.at(-1) === '' && ns.pop();
|
|
7075
7099
|
return ns && (0, visibility_1.isTightNodeStart)(ns) ? [ns, rest] : undefined;
|
|
7076
|
-
}, undefined, [3 |
|
|
7100
|
+
}, undefined, [3 | 64 /* Backtrack.ruby */])), (0, combinator_1.dup)((0, combinator_1.surround)('(', (0, source_1.str)(/^(?:\\[^\n]|[^\\[\](){}<>"\n])+/u), ')', false, ([, [source]], rest, context) => {
|
|
7077
7101
|
const ns = (0, parser_1.eval)(text({
|
|
7078
7102
|
source,
|
|
7079
7103
|
context
|
|
7080
7104
|
}), [undefined])[0];
|
|
7081
7105
|
return ns && [ns, rest];
|
|
7082
|
-
}, undefined, [3 |
|
|
7106
|
+
}, undefined, [3 | 64 /* Backtrack.ruby */]))]), ([texts, rubies]) => {
|
|
7083
7107
|
switch (true) {
|
|
7084
7108
|
case rubies.length <= texts.length:
|
|
7085
7109
|
return [(0, dom_1.html)('ruby', attributes(texts, rubies), (0, dom_1.defrag)(texts.reduce((acc, _, i) => (0, array_1.push)(acc, (0, array_1.unshift)([texts[i]], i < rubies.length && rubies[i] ? [(0, dom_1.html)('rp', '('), (0, dom_1.html)('rt', rubies[i]), (0, dom_1.html)('rp', ')')] : [(0, dom_1.html)('rt')])), [])))];
|
|
@@ -7201,7 +7225,7 @@ const source_1 = __webpack_require__(8745);
|
|
|
7201
7225
|
const dom_1 = __webpack_require__(394);
|
|
7202
7226
|
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', {
|
|
7203
7227
|
class: 'template'
|
|
7204
|
-
}, `{{${ns.join('')}}}`)], rest], undefined, [3 |
|
|
7228
|
+
}, `{{${ns.join('')}}}`)], rest], undefined, [3 | 32 /* Backtrack.linedoublebracket */, 1 | 4 /* Backtrack.lineescbracket */]));
|
|
7205
7229
|
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 */])]));
|
|
7206
7230
|
|
|
7207
7231
|
/***/ },
|
|
@@ -8126,15 +8150,15 @@ function trimBlankEnd(parser) {
|
|
|
8126
8150
|
return (0, combinator_1.fmap)(parser, trimBlankNodeEnd);
|
|
8127
8151
|
}
|
|
8128
8152
|
exports.trimBlankEnd = trimBlankEnd;
|
|
8129
|
-
//export function trimBlankNode<
|
|
8153
|
+
//export function trimBlankNode<N extends HTMLElement | string>(nodes: N[]): N[] {
|
|
8130
8154
|
// return trimBlankNodeStart(trimBlankNodeEnd(nodes));
|
|
8131
8155
|
//}
|
|
8132
|
-
//function trimBlankNodeStart<
|
|
8156
|
+
//function trimBlankNodeStart<N extends HTMLElement | string>(nodes: N[]): N[] {
|
|
8133
8157
|
// for (let node = nodes[0]; nodes.length > 0 && !isVisible(node = nodes[0], 0);) {
|
|
8134
8158
|
// if (typeof node === 'string') {
|
|
8135
8159
|
// const pos = node.trimStart().length;
|
|
8136
8160
|
// if (pos > 0) {
|
|
8137
|
-
// nodes[0] = node.slice(-pos) as
|
|
8161
|
+
// nodes[0] = node.slice(-pos) as N;
|
|
8138
8162
|
// break;
|
|
8139
8163
|
// }
|
|
8140
8164
|
// }
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import { Parser, exec } from '../../data/parser';
|
|
|
2
2
|
import { firstline, isBlank } from './line';
|
|
3
3
|
|
|
4
4
|
export function block<P extends Parser<unknown>>(parser: P, separation?: boolean): P;
|
|
5
|
-
export function block<
|
|
5
|
+
export function block<N>(parser: Parser<N>, separation = true): Parser<N> {
|
|
6
6
|
assert(parser);
|
|
7
7
|
return input => {
|
|
8
8
|
const { source } = input;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { isArray } from 'spica/alias';
|
|
2
|
-
import { Parser, Input, Ctx,
|
|
2
|
+
import { Parser, Input, Ctx, Node, Context, eval, exec, check } from '../../data/parser';
|
|
3
3
|
|
|
4
4
|
//export function contract<P extends Parser<unknown>>(patterns: string | RegExp | (string | RegExp)[], parser: P, cond: (nodes: readonly Data<P>[], rest: string) => boolean): P;
|
|
5
|
-
//export function contract<
|
|
5
|
+
//export function contract<N>(patterns: string | RegExp | (string | RegExp)[], parser: Parser<N>, cond: (nodes: readonly N[], rest: string) => boolean): Parser<N> {
|
|
6
6
|
// return verify(validate(patterns, parser), cond);
|
|
7
7
|
//}
|
|
8
8
|
|
|
9
9
|
export function validate<P extends Parser<unknown>>(patterns: string | RegExp | (string | RegExp)[], parser: P): P;
|
|
10
10
|
export function validate<P extends Parser<unknown>>(patterns: string | RegExp | (string | RegExp)[], has: string, parser: P): P;
|
|
11
11
|
export function validate<P extends Parser<unknown>>(cond: ((input: Input<Context<P>>) => boolean), parser: P): P;
|
|
12
|
-
export function validate<
|
|
13
|
-
if (typeof patterns === 'function') return guard(patterns, has as Parser<
|
|
12
|
+
export function validate<N>(patterns: string | RegExp | (string | RegExp)[] | ((input: Input<Ctx>) => boolean), has: string | Parser<N>, parser?: Parser<N>): Parser<N> {
|
|
13
|
+
if (typeof patterns === 'function') return guard(patterns, has as Parser<N>);
|
|
14
14
|
if (typeof has === 'function') return validate(patterns, '', has);
|
|
15
15
|
if (!isArray(patterns)) return validate([patterns], has, parser!);
|
|
16
16
|
assert(patterns.length > 0);
|
|
@@ -38,15 +38,15 @@ export function validate<T>(patterns: string | RegExp | (string | RegExp)[] | ((
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
function guard<P extends Parser<unknown>>(f: (input: Input<Context<P>>) => boolean, parser: P): P;
|
|
41
|
-
function guard<
|
|
41
|
+
function guard<N>(f: (input: Input<Ctx>) => boolean, parser: Parser<N>): Parser<N> {
|
|
42
42
|
return input =>
|
|
43
43
|
f(input)
|
|
44
44
|
? parser(input)
|
|
45
45
|
: undefined;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
export function verify<P extends Parser<unknown>>(parser: P, cond: (nodes: readonly
|
|
49
|
-
export function verify<
|
|
48
|
+
export function verify<P extends Parser<unknown>>(parser: P, cond: (nodes: readonly Node<P>[], rest: string, context: Context<P>) => boolean): P;
|
|
49
|
+
export function verify<N>(parser: Parser<N>, cond: (nodes: readonly N[], rest: string, context: Ctx) => boolean): Parser<N> {
|
|
50
50
|
assert(parser);
|
|
51
51
|
return input => {
|
|
52
52
|
const { source, context } = input;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Parser, eval, exec, check } from '../../data/parser';
|
|
2
2
|
|
|
3
3
|
export function line<P extends Parser<unknown>>(parser: P): P;
|
|
4
|
-
export function line<
|
|
4
|
+
export function line<N>(parser: Parser<N>): Parser<N> {
|
|
5
5
|
assert(parser);
|
|
6
6
|
return ({ source, context }) => {
|
|
7
7
|
if (source === '') return;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Parser, Ctx } from '../../data/parser';
|
|
2
|
+
import { fmap } from '../monad/fmap';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export function clear<D extends Parser<unknown, C>[], C extends Ctx>(parser: Parser<unknown, C, D>): Parser<never, C, D> {
|
|
6
|
+
return fmap<never, Parser<unknown, C, D>>(parser, () => []);
|
|
7
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Parser, Ctx, Context, check } from '../../data/parser';
|
|
2
2
|
|
|
3
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<
|
|
4
|
+
export function convert<N>(conv: (source: string, context: Ctx) => string, parser: Parser<N>, continuous: boolean, empty = false): Parser<N> {
|
|
5
5
|
assert(parser);
|
|
6
6
|
return ({ source, context }) => {
|
|
7
7
|
if (source === '') return;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Parser, Ctx,
|
|
1
|
+
import { Parser, Ctx, Node, Context, SubParsers } from '../../data/parser';
|
|
2
2
|
import { fmap } from '../monad/fmap';
|
|
3
3
|
|
|
4
|
-
export function dup<P extends Parser<unknown[]>>(parser: Parser<
|
|
5
|
-
export function dup<
|
|
6
|
-
export function dup<
|
|
4
|
+
export function dup<P extends Parser<unknown[]>>(parser: Parser<Node<P>[number], Context<P>, SubParsers<P>>): P;
|
|
5
|
+
export function dup<N, C extends Ctx, D extends Parser<unknown, C>[]>(parser: Parser<N, C, D>): Parser<N[], C, D>;
|
|
6
|
+
export function dup<N>(parser: Parser<N>): Parser<N[]> {
|
|
7
7
|
return fmap(parser, nodes => [nodes]);
|
|
8
8
|
}
|