securemark 0.294.0 → 0.294.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 +8 -0
- package/design.md +27 -39
- package/dist/index.js +208 -180
- package/package.json +2 -2
- package/src/combinator/control/constraint/contract.ts +2 -2
- package/src/combinator/control/constraint/line.ts +2 -2
- package/src/combinator/control/manipulation/clear.ts +2 -2
- package/src/combinator/control/manipulation/indent.ts +3 -7
- package/src/combinator/control/manipulation/lazy.ts +1 -3
- package/src/combinator/control/manipulation/scope.ts +4 -6
- package/src/combinator/control/manipulation/surround.ts +5 -8
- package/src/combinator/control/monad/bind.ts +2 -3
- package/src/combinator/data/data.ts +38 -32
- package/src/combinator/data/parser/context.test.ts +4 -4
- package/src/combinator/data/parser/inits.ts +6 -8
- package/src/combinator/data/parser/sequence.test.ts +2 -2
- package/src/combinator/data/parser/sequence.ts +5 -7
- package/src/combinator/data/parser/some.test.ts +2 -2
- package/src/combinator/data/parser/some.ts +5 -7
- package/src/combinator/data/parser/subsequence.test.ts +2 -2
- package/src/combinator/data/parser/subsequence.ts +2 -2
- package/src/combinator/data/parser/tails.ts +2 -2
- package/src/combinator/data/parser/union.test.ts +2 -2
- package/src/combinator/data/parser/union.ts +2 -2
- package/src/combinator/data/parser.ts +36 -39
- package/src/debug.test.ts +2 -2
- package/src/parser/api/bind.ts +6 -6
- package/src/parser/api/header.ts +2 -2
- package/src/parser/api/normalize.ts +2 -2
- package/src/parser/api/parse.ts +11 -11
- package/src/parser/block/codeblock.ts +2 -2
- package/src/parser/block/extension/example.ts +2 -2
- package/src/parser/block/extension/figure.ts +1 -1
- package/src/parser/block/extension/message.ts +2 -2
- package/src/parser/block/extension/table.ts +2 -2
- package/src/parser/block.ts +5 -1
- package/src/parser/inline/autolink/url.test.ts +71 -72
- package/src/parser/inline/autolink/url.ts +4 -4
- package/src/parser/inline/emstrong.ts +5 -5
- package/src/parser/inline/reference.ts +2 -2
- package/src/parser/inline/ruby.ts +4 -4
- package/src/parser/processor/note.ts +2 -2
- package/src/parser/segment.ts +6 -12
- package/src/parser/source/line.ts +5 -0
- package/src/parser/source/str.ts +1 -1
- package/src/parser/util.ts +5 -4
- package/src/parser/visibility.ts +2 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.294.
|
|
1
|
+
/*! securemark v0.294.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("Prism"), require("DOMPurify"));
|
|
@@ -840,41 +840,71 @@ class List {
|
|
|
840
840
|
if (this.length === 0) return;
|
|
841
841
|
return this.delete(this.head.prev);
|
|
842
842
|
}
|
|
843
|
+
import(list, before) {
|
|
844
|
+
if (list.length === 0) return this;
|
|
845
|
+
if (this.length === 0) {
|
|
846
|
+
this.head = list.head;
|
|
847
|
+
this.length += list.length;
|
|
848
|
+
list.head = undefined;
|
|
849
|
+
list.length = 0;
|
|
850
|
+
return this;
|
|
851
|
+
}
|
|
852
|
+
const head = list.head;
|
|
853
|
+
const last = list.last;
|
|
854
|
+
const next = last.next = before ?? this.head;
|
|
855
|
+
const prev = head.prev = next.prev;
|
|
856
|
+
next.prev = last;
|
|
857
|
+
prev.next = head;
|
|
858
|
+
this.length += list.length;
|
|
859
|
+
list.length = 0;
|
|
860
|
+
list.head = undefined;
|
|
861
|
+
return this;
|
|
862
|
+
}
|
|
843
863
|
clear() {
|
|
844
864
|
this.length = 0;
|
|
845
865
|
this.head = undefined;
|
|
846
866
|
}
|
|
847
867
|
*[Symbol.iterator]() {
|
|
848
|
-
for (let node = this.head; node
|
|
868
|
+
for (let node = this.head; node && this.head;) {
|
|
869
|
+
const next = node.next;
|
|
849
870
|
yield node;
|
|
850
|
-
node =
|
|
871
|
+
node = next;
|
|
851
872
|
if (node === this.head) break;
|
|
852
873
|
}
|
|
853
874
|
}
|
|
854
875
|
flatMap(f) {
|
|
855
|
-
const acc =
|
|
856
|
-
for (let node = this.head; node
|
|
857
|
-
const
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
break;
|
|
861
|
-
case 1:
|
|
862
|
-
acc.push(as[0]);
|
|
863
|
-
break;
|
|
864
|
-
default:
|
|
865
|
-
for (let len = as.length, i = 0; i < len; ++i) {
|
|
866
|
-
acc.push(as[i]);
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
node = node.next;
|
|
876
|
+
const acc = new List();
|
|
877
|
+
for (let node = this.head; node && this.head;) {
|
|
878
|
+
const next = node.next;
|
|
879
|
+
acc.import(f(node));
|
|
880
|
+
node = next;
|
|
870
881
|
if (node === this.head) break;
|
|
871
882
|
}
|
|
872
883
|
return acc;
|
|
873
884
|
}
|
|
885
|
+
foldl(f, acc) {
|
|
886
|
+
for (let node = this.head; node && this.head;) {
|
|
887
|
+
const next = node.next;
|
|
888
|
+
acc = f(acc, node);
|
|
889
|
+
node = next;
|
|
890
|
+
if (node === this.head) break;
|
|
891
|
+
}
|
|
892
|
+
return acc;
|
|
893
|
+
}
|
|
894
|
+
foldr(f, acc) {
|
|
895
|
+
for (let node = this.head?.prev; node && this.head;) {
|
|
896
|
+
const prev = node.prev;
|
|
897
|
+
acc = f(node, acc);
|
|
898
|
+
if (node === this.head) break;
|
|
899
|
+
node = prev;
|
|
900
|
+
}
|
|
901
|
+
return acc;
|
|
902
|
+
}
|
|
874
903
|
find(f) {
|
|
875
|
-
for (let node = this.head; node
|
|
904
|
+
for (let node = this.head; node && this.head;) {
|
|
905
|
+
const next = node.next;
|
|
876
906
|
if (f(node)) return node;
|
|
877
|
-
node =
|
|
907
|
+
node = next;
|
|
878
908
|
if (node === this.head) break;
|
|
879
909
|
}
|
|
880
910
|
}
|
|
@@ -959,36 +989,67 @@ class List {
|
|
|
959
989
|
if (this.length === 0) return;
|
|
960
990
|
return this.delete(this.last);
|
|
961
991
|
}
|
|
992
|
+
import(list, before) {
|
|
993
|
+
if (list.length === 0) return this;
|
|
994
|
+
if (this.length === 0) {
|
|
995
|
+
this.head = list.head;
|
|
996
|
+
this.length += list.length;
|
|
997
|
+
list.head = undefined;
|
|
998
|
+
list.length = 0;
|
|
999
|
+
return this;
|
|
1000
|
+
}
|
|
1001
|
+
const head = list.head;
|
|
1002
|
+
const last = list.last;
|
|
1003
|
+
const next = last.next = before ?? this.head;
|
|
1004
|
+
const prev = head.prev = next.prev;
|
|
1005
|
+
next.prev = last;
|
|
1006
|
+
prev.next = head;
|
|
1007
|
+
this.length += list.length;
|
|
1008
|
+
list.length = 0;
|
|
1009
|
+
list.head = undefined;
|
|
1010
|
+
return this;
|
|
1011
|
+
}
|
|
962
1012
|
clear() {
|
|
963
1013
|
this.length = 0;
|
|
964
1014
|
this.head = this.last = undefined;
|
|
965
1015
|
}
|
|
966
1016
|
*[Symbol.iterator]() {
|
|
967
|
-
for (let node = this.head; node
|
|
1017
|
+
for (let node = this.head; node && this.head;) {
|
|
1018
|
+
const next = node.next;
|
|
968
1019
|
yield node;
|
|
1020
|
+
node = next;
|
|
969
1021
|
}
|
|
970
1022
|
}
|
|
971
1023
|
flatMap(f) {
|
|
972
|
-
const acc =
|
|
973
|
-
for (let node = this.head; node
|
|
974
|
-
const
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1024
|
+
const acc = new List();
|
|
1025
|
+
for (let node = this.head; node && this.head;) {
|
|
1026
|
+
const next = node.next;
|
|
1027
|
+
acc.import(f(node));
|
|
1028
|
+
node = next;
|
|
1029
|
+
}
|
|
1030
|
+
return acc;
|
|
1031
|
+
}
|
|
1032
|
+
foldl(f, acc) {
|
|
1033
|
+
for (let node = this.head; node && this.head;) {
|
|
1034
|
+
const next = node.next;
|
|
1035
|
+
acc = f(acc, node);
|
|
1036
|
+
node = next;
|
|
1037
|
+
}
|
|
1038
|
+
return acc;
|
|
1039
|
+
}
|
|
1040
|
+
foldr(f, acc) {
|
|
1041
|
+
for (let node = this.head?.prev; node && this.head;) {
|
|
1042
|
+
const prev = node.prev;
|
|
1043
|
+
acc = f(node, acc);
|
|
1044
|
+
node = prev;
|
|
986
1045
|
}
|
|
987
1046
|
return acc;
|
|
988
1047
|
}
|
|
989
1048
|
find(f) {
|
|
990
|
-
for (let node = this.head; node
|
|
1049
|
+
for (let node = this.head; node && this.head;) {
|
|
1050
|
+
const next = node.next;
|
|
991
1051
|
if (f(node)) return node;
|
|
1052
|
+
node = next;
|
|
992
1053
|
}
|
|
993
1054
|
}
|
|
994
1055
|
}
|
|
@@ -1036,6 +1097,7 @@ exports.memoize = memoize;
|
|
|
1036
1097
|
function memoizeArray(f, identify, memory) {
|
|
1037
1098
|
return (...as) => {
|
|
1038
1099
|
const b = identify(...as);
|
|
1100
|
+
if (!(b >= 0)) return f(...as);
|
|
1039
1101
|
let z = memory[b];
|
|
1040
1102
|
if (z !== undefined) return z;
|
|
1041
1103
|
z = f(...as);
|
|
@@ -1047,6 +1109,7 @@ function memoizeObject(f, identify, memory) {
|
|
|
1047
1109
|
let nullable = false;
|
|
1048
1110
|
return (...as) => {
|
|
1049
1111
|
const b = identify(...as);
|
|
1112
|
+
if (!(b >= 0)) return f(...as);
|
|
1050
1113
|
let z = memory[b];
|
|
1051
1114
|
if (z !== undefined || nullable && b in memory) return z;
|
|
1052
1115
|
z = f(...as);
|
|
@@ -2527,7 +2590,7 @@ function verify(parser, cond) {
|
|
|
2527
2590
|
} = context;
|
|
2528
2591
|
if (position === source.length) return;
|
|
2529
2592
|
const result = parser(input);
|
|
2530
|
-
if (result && !cond(
|
|
2593
|
+
if (result && !cond(result, context)) return;
|
|
2531
2594
|
return result;
|
|
2532
2595
|
});
|
|
2533
2596
|
}
|
|
@@ -2566,7 +2629,7 @@ function line(parser) {
|
|
|
2566
2629
|
if (result === undefined) return;
|
|
2567
2630
|
if (!isBlank(source.slice(context.position, position + line.length))) return;
|
|
2568
2631
|
context.position = position + line.length;
|
|
2569
|
-
return
|
|
2632
|
+
return result;
|
|
2570
2633
|
});
|
|
2571
2634
|
}
|
|
2572
2635
|
exports.line = line;
|
|
@@ -2783,9 +2846,8 @@ function indent(opener, parser = false, separation = false) {
|
|
|
2783
2846
|
} = context;
|
|
2784
2847
|
context.position = source.length;
|
|
2785
2848
|
return new parser_1.List([new parser_1.Data(source.slice(position))]);
|
|
2786
|
-
}))), ([indent]) => indent.length * 2 + +(indent[0] === ' '),
|
|
2787
|
-
|
|
2788
|
-
return result ? (0, parser_1.eval)(result) : undefined;
|
|
2849
|
+
}))), ([indent]) => indent.length <= 16 ? indent.length * 2 + +(indent[0] === ' ') : -1, [])), separation), (lines, context) => {
|
|
2850
|
+
return parser((0, parser_1.subinput)(trimBlockEnd(lines.foldl((acc, node) => acc + node.value, '')), context));
|
|
2789
2851
|
}));
|
|
2790
2852
|
}
|
|
2791
2853
|
exports.indent = indent;
|
|
@@ -2807,7 +2869,7 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
2807
2869
|
exports.lazy = void 0;
|
|
2808
2870
|
function lazy(builder) {
|
|
2809
2871
|
let parser;
|
|
2810
|
-
return input =>
|
|
2872
|
+
return input => (parser ??= builder())(input);
|
|
2811
2873
|
}
|
|
2812
2874
|
exports.lazy = lazy;
|
|
2813
2875
|
|
|
@@ -2921,9 +2983,9 @@ function focus(scope, parser) {
|
|
|
2921
2983
|
position
|
|
2922
2984
|
} = context;
|
|
2923
2985
|
if (position === source.length) return;
|
|
2924
|
-
const src =
|
|
2986
|
+
const src = match({
|
|
2925
2987
|
context
|
|
2926
|
-
})
|
|
2988
|
+
})?.head?.value ?? '';
|
|
2927
2989
|
if (src === '') return;
|
|
2928
2990
|
context.range = src.length;
|
|
2929
2991
|
context.offset ??= 0;
|
|
@@ -2933,8 +2995,7 @@ function focus(scope, parser) {
|
|
|
2933
2995
|
context.position += result && context.position === position ? src.length : 0;
|
|
2934
2996
|
context.source = source;
|
|
2935
2997
|
context.offset -= position;
|
|
2936
|
-
|
|
2937
|
-
return (0, parser_1.eval)(result);
|
|
2998
|
+
return result;
|
|
2938
2999
|
});
|
|
2939
3000
|
}
|
|
2940
3001
|
exports.focus = focus;
|
|
@@ -2959,8 +3020,7 @@ function rewrite(scope, parser) {
|
|
|
2959
3020
|
context.position += res2 && context.position === position ? src.length : 0;
|
|
2960
3021
|
context.source = source;
|
|
2961
3022
|
context.offset -= position;
|
|
2962
|
-
|
|
2963
|
-
return (0, parser_1.eval)(res2);
|
|
3023
|
+
return res2;
|
|
2964
3024
|
});
|
|
2965
3025
|
}
|
|
2966
3026
|
exports.rewrite = rewrite;
|
|
@@ -3003,26 +3063,23 @@ function surround(opener, parser, closer, optional = false, f, g, backtracks = [
|
|
|
3003
3063
|
linebreak
|
|
3004
3064
|
} = context;
|
|
3005
3065
|
context.linebreak = 0;
|
|
3006
|
-
const
|
|
3007
|
-
const nodesO = (0, parser_1.eval)(resultO);
|
|
3066
|
+
const nodesO = opener(input);
|
|
3008
3067
|
if (!nodesO) {
|
|
3009
3068
|
return void revert(context, linebreak);
|
|
3010
3069
|
}
|
|
3011
3070
|
if (isBacktrack(context, backtracks, position, context.position - position || 1)) {
|
|
3012
3071
|
return void revert(context, linebreak);
|
|
3013
3072
|
}
|
|
3014
|
-
const
|
|
3073
|
+
const nodesM = context.position < source.length ? parser(input) : undefined;
|
|
3015
3074
|
context.range = context.position - position;
|
|
3016
|
-
|
|
3017
|
-
if (!resultM && !optional) {
|
|
3075
|
+
if (!nodesM && !optional) {
|
|
3018
3076
|
setBacktrack(context, backtracks, position);
|
|
3019
3077
|
const result = g?.([nodesO, nodesM], context);
|
|
3020
3078
|
revert(context, linebreak);
|
|
3021
3079
|
return result;
|
|
3022
3080
|
}
|
|
3023
|
-
const
|
|
3081
|
+
const nodesC = nodesM || optional ? closer(input) : undefined;
|
|
3024
3082
|
context.range = context.position - position;
|
|
3025
|
-
const nodesC = (0, parser_1.eval)(resultC);
|
|
3026
3083
|
if (!nodesC) {
|
|
3027
3084
|
setBacktrack(context, backtracks, position);
|
|
3028
3085
|
const result = g?.([nodesO, nodesM], context);
|
|
@@ -3138,8 +3195,7 @@ function bind(parser, f) {
|
|
|
3138
3195
|
const res1 = parser(input);
|
|
3139
3196
|
if (res1 === undefined) return;
|
|
3140
3197
|
context.range = context.position - position;
|
|
3141
|
-
const res2 = f(
|
|
3142
|
-
if (res2 === undefined) return;
|
|
3198
|
+
const res2 = f(res1, context);
|
|
3143
3199
|
return context.position > position ? res2 : undefined;
|
|
3144
3200
|
});
|
|
3145
3201
|
}
|
|
@@ -3171,7 +3227,6 @@ exports.fmap = fmap;
|
|
|
3171
3227
|
"use strict";
|
|
3172
3228
|
|
|
3173
3229
|
|
|
3174
|
-
// Memory-efficient flexible list.
|
|
3175
3230
|
Object.defineProperty(exports, "__esModule", ({
|
|
3176
3231
|
value: true
|
|
3177
3232
|
}));
|
|
@@ -3180,6 +3235,7 @@ class List {
|
|
|
3180
3235
|
constructor(nodes) {
|
|
3181
3236
|
this.length = 0;
|
|
3182
3237
|
this.head = undefined;
|
|
3238
|
+
this.last = undefined;
|
|
3183
3239
|
if (nodes === undefined) return;
|
|
3184
3240
|
for (let i = 0; i < nodes.length; ++i) {
|
|
3185
3241
|
this.push(nodes[i]);
|
|
@@ -3188,40 +3244,43 @@ class List {
|
|
|
3188
3244
|
get tail() {
|
|
3189
3245
|
return this.head?.next;
|
|
3190
3246
|
}
|
|
3191
|
-
get last() {
|
|
3192
|
-
return this.head?.prev;
|
|
3193
|
-
}
|
|
3194
3247
|
insert(node, before) {
|
|
3248
|
+
if (before === undefined) return this.push(node);
|
|
3249
|
+
if (before === this.head) return this.unshift(node);
|
|
3195
3250
|
if (++this.length === 1) {
|
|
3196
|
-
return this.head =
|
|
3251
|
+
return this.head = this.last = node;
|
|
3197
3252
|
}
|
|
3198
|
-
const next = node.next = before
|
|
3253
|
+
const next = node.next = before;
|
|
3199
3254
|
const prev = node.prev = next.prev;
|
|
3200
3255
|
return next.prev = prev.next = node;
|
|
3201
3256
|
}
|
|
3202
3257
|
delete(node) {
|
|
3203
3258
|
if (--this.length === 0) {
|
|
3204
|
-
this.head = undefined;
|
|
3259
|
+
this.head = this.last = undefined;
|
|
3205
3260
|
} else {
|
|
3206
3261
|
const {
|
|
3207
3262
|
next,
|
|
3208
3263
|
prev
|
|
3209
3264
|
} = node;
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
}
|
|
3213
|
-
// Error if not used.
|
|
3214
|
-
prev.next = next;
|
|
3215
|
-
next.prev = prev;
|
|
3265
|
+
prev === undefined ? this.head = next : prev.next = next;
|
|
3266
|
+
next === undefined ? this.last = prev : next.prev = prev;
|
|
3216
3267
|
}
|
|
3217
3268
|
node.next = node.prev = undefined;
|
|
3218
3269
|
return node;
|
|
3219
3270
|
}
|
|
3220
3271
|
unshift(node) {
|
|
3221
|
-
|
|
3272
|
+
if (++this.length === 1) {
|
|
3273
|
+
return this.head = this.last = node;
|
|
3274
|
+
}
|
|
3275
|
+
node.next = this.head;
|
|
3276
|
+
return this.head = this.head.prev = node;
|
|
3222
3277
|
}
|
|
3223
3278
|
push(node) {
|
|
3224
|
-
|
|
3279
|
+
if (++this.length === 1) {
|
|
3280
|
+
return this.head = this.last = node;
|
|
3281
|
+
}
|
|
3282
|
+
node.prev = this.last;
|
|
3283
|
+
return this.last = this.last.next = node;
|
|
3225
3284
|
}
|
|
3226
3285
|
shift() {
|
|
3227
3286
|
if (this.length === 0) return;
|
|
@@ -3229,21 +3288,22 @@ class List {
|
|
|
3229
3288
|
}
|
|
3230
3289
|
pop() {
|
|
3231
3290
|
if (this.length === 0) return;
|
|
3232
|
-
return this.delete(this.
|
|
3291
|
+
return this.delete(this.last);
|
|
3233
3292
|
}
|
|
3234
3293
|
import(list, before) {
|
|
3235
3294
|
if (list.length === 0) return this;
|
|
3236
3295
|
if (this.length === 0) {
|
|
3237
3296
|
this.head = list.head;
|
|
3238
|
-
this.
|
|
3297
|
+
this.last = list.last;
|
|
3298
|
+
this.length = list.length;
|
|
3239
3299
|
list.clear();
|
|
3240
3300
|
return this;
|
|
3241
3301
|
}
|
|
3242
3302
|
const head = list.head;
|
|
3243
3303
|
const last = list.last;
|
|
3244
|
-
const next = last.next = before
|
|
3245
|
-
const prev = head.prev =
|
|
3246
|
-
next.prev = last;
|
|
3304
|
+
const next = last.next = before;
|
|
3305
|
+
const prev = head.prev = before?.prev ?? this.last;
|
|
3306
|
+
next === undefined ? this.last = last : next.prev = last;
|
|
3247
3307
|
prev.next = head;
|
|
3248
3308
|
this.length += list.length;
|
|
3249
3309
|
list.clear();
|
|
@@ -3251,14 +3311,13 @@ class List {
|
|
|
3251
3311
|
}
|
|
3252
3312
|
clear() {
|
|
3253
3313
|
this.length = 0;
|
|
3254
|
-
this.head = undefined;
|
|
3314
|
+
this.head = this.last = undefined;
|
|
3255
3315
|
}
|
|
3256
3316
|
*[Symbol.iterator]() {
|
|
3257
3317
|
for (let node = this.head; node && this.head;) {
|
|
3258
3318
|
const next = node.next;
|
|
3259
3319
|
yield node;
|
|
3260
3320
|
node = next;
|
|
3261
|
-
if (node === this.head) break;
|
|
3262
3321
|
}
|
|
3263
3322
|
}
|
|
3264
3323
|
flatMap(f) {
|
|
@@ -3267,7 +3326,6 @@ class List {
|
|
|
3267
3326
|
const next = node.next;
|
|
3268
3327
|
acc.import(f(node));
|
|
3269
3328
|
node = next;
|
|
3270
|
-
if (node === this.head) break;
|
|
3271
3329
|
}
|
|
3272
3330
|
return acc;
|
|
3273
3331
|
}
|
|
@@ -3276,15 +3334,13 @@ class List {
|
|
|
3276
3334
|
const next = node.next;
|
|
3277
3335
|
acc = f(acc, node);
|
|
3278
3336
|
node = next;
|
|
3279
|
-
if (node === this.head) break;
|
|
3280
3337
|
}
|
|
3281
3338
|
return acc;
|
|
3282
3339
|
}
|
|
3283
3340
|
foldr(f, acc) {
|
|
3284
|
-
for (let node = this.
|
|
3341
|
+
for (let node = this.last; node && this.head;) {
|
|
3285
3342
|
const prev = node.prev;
|
|
3286
3343
|
acc = f(node, acc);
|
|
3287
|
-
if (node === this.head) break;
|
|
3288
3344
|
node = prev;
|
|
3289
3345
|
}
|
|
3290
3346
|
return acc;
|
|
@@ -3294,7 +3350,6 @@ class List {
|
|
|
3294
3350
|
const next = node.next;
|
|
3295
3351
|
if (f(node)) return node;
|
|
3296
3352
|
node = next;
|
|
3297
|
-
if (node === this.head) break;
|
|
3298
3353
|
}
|
|
3299
3354
|
}
|
|
3300
3355
|
}
|
|
@@ -3320,7 +3375,7 @@ exports.List = List;
|
|
|
3320
3375
|
Object.defineProperty(exports, "__esModule", ({
|
|
3321
3376
|
value: true
|
|
3322
3377
|
}));
|
|
3323
|
-
exports.failsafe = exports.
|
|
3378
|
+
exports.failsafe = exports.subinput = exports.input = exports.Data = exports.List = void 0;
|
|
3324
3379
|
const data_1 = __webpack_require__(3602);
|
|
3325
3380
|
Object.defineProperty(exports, "List", ({
|
|
3326
3381
|
enumerable: true,
|
|
@@ -3359,38 +3414,10 @@ function subinput(source, context) {
|
|
|
3359
3414
|
};
|
|
3360
3415
|
}
|
|
3361
3416
|
exports.subinput = subinput;
|
|
3362
|
-
function clean(context) {
|
|
3363
|
-
const {
|
|
3364
|
-
source,
|
|
3365
|
-
position
|
|
3366
|
-
} = context;
|
|
3367
|
-
for (const p of Object.keys(context)) {
|
|
3368
|
-
context[p] = undefined;
|
|
3369
|
-
}
|
|
3370
|
-
context.source = source;
|
|
3371
|
-
context.position = position;
|
|
3372
|
-
return context;
|
|
3373
|
-
}
|
|
3374
|
-
exports.clean = clean;
|
|
3375
|
-
function eval_(result, default_) {
|
|
3376
|
-
return result ? result : default_;
|
|
3377
|
-
}
|
|
3378
|
-
exports.eval = eval_;
|
|
3379
3417
|
function failsafe(parser) {
|
|
3380
3418
|
return input => {
|
|
3381
|
-
const
|
|
3382
|
-
|
|
3383
|
-
} = input;
|
|
3384
|
-
const {
|
|
3385
|
-
source,
|
|
3386
|
-
position
|
|
3387
|
-
} = context;
|
|
3388
|
-
const result = parser(input);
|
|
3389
|
-
if (result === undefined) {
|
|
3390
|
-
context.source = source;
|
|
3391
|
-
context.position = position;
|
|
3392
|
-
}
|
|
3393
|
-
return result;
|
|
3419
|
+
const position = input.context.position;
|
|
3420
|
+
return parser(input) ?? (input.context.position = position, undefined);
|
|
3394
3421
|
};
|
|
3395
3422
|
}
|
|
3396
3423
|
exports.failsafe = failsafe;
|
|
@@ -3763,7 +3790,7 @@ exports.Delimiters = Delimiters;
|
|
|
3763
3790
|
/***/ },
|
|
3764
3791
|
|
|
3765
3792
|
/***/ 2861
|
|
3766
|
-
(__unused_webpack_module, exports
|
|
3793
|
+
(__unused_webpack_module, exports) {
|
|
3767
3794
|
|
|
3768
3795
|
"use strict";
|
|
3769
3796
|
|
|
@@ -3772,7 +3799,6 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
3772
3799
|
value: true
|
|
3773
3800
|
}));
|
|
3774
3801
|
exports.inits = void 0;
|
|
3775
|
-
const parser_1 = __webpack_require__(605);
|
|
3776
3802
|
function inits(parsers, resume) {
|
|
3777
3803
|
if (parsers.length === 1) return parsers[0];
|
|
3778
3804
|
return input => {
|
|
@@ -3789,10 +3815,10 @@ function inits(parsers, resume) {
|
|
|
3789
3815
|
if (context.delimiters?.match(input)) break;
|
|
3790
3816
|
const result = parsers[i](input);
|
|
3791
3817
|
if (result === undefined) break;
|
|
3792
|
-
nodes = nodes
|
|
3793
|
-
if (resume?.(
|
|
3818
|
+
nodes = nodes?.import(result) ?? result;
|
|
3819
|
+
if (resume?.(result) === false) break;
|
|
3794
3820
|
}
|
|
3795
|
-
return
|
|
3821
|
+
return context.position > position ? nodes : undefined;
|
|
3796
3822
|
};
|
|
3797
3823
|
}
|
|
3798
3824
|
exports.inits = inits;
|
|
@@ -3800,7 +3826,7 @@ exports.inits = inits;
|
|
|
3800
3826
|
/***/ },
|
|
3801
3827
|
|
|
3802
3828
|
/***/ 3989
|
|
3803
|
-
(__unused_webpack_module, exports
|
|
3829
|
+
(__unused_webpack_module, exports) {
|
|
3804
3830
|
|
|
3805
3831
|
"use strict";
|
|
3806
3832
|
|
|
@@ -3809,7 +3835,6 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
3809
3835
|
value: true
|
|
3810
3836
|
}));
|
|
3811
3837
|
exports.sequence = void 0;
|
|
3812
|
-
const parser_1 = __webpack_require__(605);
|
|
3813
3838
|
function sequence(parsers, resume) {
|
|
3814
3839
|
if (parsers.length === 1) return parsers[0];
|
|
3815
3840
|
return input => {
|
|
@@ -3826,10 +3851,10 @@ function sequence(parsers, resume) {
|
|
|
3826
3851
|
if (context.delimiters?.match(input)) return;
|
|
3827
3852
|
const result = parsers[i](input);
|
|
3828
3853
|
if (result === undefined) return;
|
|
3829
|
-
nodes = nodes
|
|
3830
|
-
if (resume?.(
|
|
3854
|
+
nodes = nodes?.import(result) ?? result;
|
|
3855
|
+
if (resume?.(result) === false) return;
|
|
3831
3856
|
}
|
|
3832
|
-
return
|
|
3857
|
+
return context.position > position ? nodes : undefined;
|
|
3833
3858
|
};
|
|
3834
3859
|
}
|
|
3835
3860
|
exports.sequence = sequence;
|
|
@@ -3846,7 +3871,6 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
3846
3871
|
value: true
|
|
3847
3872
|
}));
|
|
3848
3873
|
exports.some = void 0;
|
|
3849
|
-
const parser_1 = __webpack_require__(605);
|
|
3850
3874
|
const delimiter_1 = __webpack_require__(5691);
|
|
3851
3875
|
function some(parser, end, delimiters = [], limit = -1) {
|
|
3852
3876
|
if (typeof end === 'number') return some(parser, undefined, delimiters, end);
|
|
@@ -3870,19 +3894,19 @@ function some(parser, end, delimiters = [], limit = -1) {
|
|
|
3870
3894
|
context.delimiters ??= new delimiter_1.Delimiters();
|
|
3871
3895
|
context.delimiters.push(delims);
|
|
3872
3896
|
}
|
|
3873
|
-
while
|
|
3874
|
-
|
|
3897
|
+
// whileは数倍遅い
|
|
3898
|
+
for (; context.position < source.length;) {
|
|
3875
3899
|
if (match(input)) break;
|
|
3876
3900
|
if (context.delimiters?.match(input)) break;
|
|
3877
3901
|
const result = parser(input);
|
|
3878
3902
|
if (result === undefined) break;
|
|
3879
|
-
nodes = nodes
|
|
3903
|
+
nodes = nodes?.import(result) ?? result;
|
|
3880
3904
|
if (limit >= 0 && context.position - position > limit) break;
|
|
3881
3905
|
}
|
|
3882
3906
|
if (delims.length > 0) {
|
|
3883
3907
|
context.delimiters.pop(delims.length);
|
|
3884
3908
|
}
|
|
3885
|
-
return
|
|
3909
|
+
return context.position > position ? nodes : undefined;
|
|
3886
3910
|
};
|
|
3887
3911
|
}
|
|
3888
3912
|
exports.some = some;
|
|
@@ -4065,7 +4089,7 @@ const note_1 = __webpack_require__(165);
|
|
|
4065
4089
|
const url_1 = __webpack_require__(1904);
|
|
4066
4090
|
const array_1 = __webpack_require__(6876);
|
|
4067
4091
|
function bind(target, settings) {
|
|
4068
|
-
|
|
4092
|
+
const context = {
|
|
4069
4093
|
...settings,
|
|
4070
4094
|
host: settings.host ?? new url_1.ReadonlyURL(location.pathname, location.origin)
|
|
4071
4095
|
};
|
|
@@ -4112,7 +4136,7 @@ function bind(target, settings) {
|
|
|
4112
4136
|
let index = head;
|
|
4113
4137
|
for (; index < sourceSegments.length - last; ++index) {
|
|
4114
4138
|
const seg = sourceSegments[index];
|
|
4115
|
-
const es = (
|
|
4139
|
+
const es = ((0, header_1.header)((0, parser_1.input)(seg, {
|
|
4116
4140
|
header: index === 0
|
|
4117
4141
|
})) || (0, block_1.block)((0, parser_1.input)(seg, context)))?.foldl((acc, {
|
|
4118
4142
|
value
|
|
@@ -4123,7 +4147,7 @@ function bind(target, settings) {
|
|
|
4123
4147
|
// Therefore any `base` node will never be unavailable by deletions until all the dependent `el` nodes are added.
|
|
4124
4148
|
(0, array_1.push)(adds, es.map(el => [el, base]));
|
|
4125
4149
|
adds.reverse();
|
|
4126
|
-
|
|
4150
|
+
for (; adds.length > 0;) {
|
|
4127
4151
|
const [el, base] = adds.pop();
|
|
4128
4152
|
target.insertBefore(el, base);
|
|
4129
4153
|
yield {
|
|
@@ -4141,7 +4165,7 @@ function bind(target, settings) {
|
|
|
4141
4165
|
(0, array_1.push)(dels, es.map(el => [el]));
|
|
4142
4166
|
}
|
|
4143
4167
|
adds.reverse();
|
|
4144
|
-
|
|
4168
|
+
for (; adds.length > 0;) {
|
|
4145
4169
|
const [el, base] = adds.pop();
|
|
4146
4170
|
target.insertBefore(el, base);
|
|
4147
4171
|
yield {
|
|
@@ -4153,7 +4177,7 @@ function bind(target, settings) {
|
|
|
4153
4177
|
};
|
|
4154
4178
|
}
|
|
4155
4179
|
dels.reverse();
|
|
4156
|
-
|
|
4180
|
+
for (; dels.length > 0;) {
|
|
4157
4181
|
const [el] = dels.pop();
|
|
4158
4182
|
el.parentNode?.removeChild(el);
|
|
4159
4183
|
yield {
|
|
@@ -4297,7 +4321,7 @@ exports.headers = headers;
|
|
|
4297
4321
|
function parse(source) {
|
|
4298
4322
|
const i = (0, parser_1.input)(source, {});
|
|
4299
4323
|
const result = (0, header_1.header)(i);
|
|
4300
|
-
const el =
|
|
4324
|
+
const el = result?.head?.value;
|
|
4301
4325
|
return el?.tagName === 'ASIDE' ? [el, i.context.position] : [];
|
|
4302
4326
|
}
|
|
4303
4327
|
|
|
@@ -4330,7 +4354,7 @@ function sanitize(source) {
|
|
|
4330
4354
|
// https://en.wikipedia.org/wiki/Whitespace_character
|
|
4331
4355
|
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'];
|
|
4332
4356
|
const unreadableHTMLEntityNames = exports.invisibleHTMLEntityNames.slice(2);
|
|
4333
|
-
const unreadableEscapableCharacters = unreadableHTMLEntityNames.map(name => (0,
|
|
4357
|
+
const unreadableEscapableCharacters = unreadableHTMLEntityNames.map(name => (0, htmlentity_1.unsafehtmlentity)((0, parser_1.input)(`&${name};`, {})).head.value);
|
|
4334
4358
|
const unreadableEscapableCharacter = new RegExp(`[${unreadableEscapableCharacters.join('')}]`, 'g');
|
|
4335
4359
|
// https://www.pandanoir.info/entry/2018/03/11/193000
|
|
4336
4360
|
// http://anti.rosx.net/etc/memo/002_space.html
|
|
@@ -4392,13 +4416,13 @@ const figure_1 = __webpack_require__(1657);
|
|
|
4392
4416
|
const note_1 = __webpack_require__(165);
|
|
4393
4417
|
const url_1 = __webpack_require__(1904);
|
|
4394
4418
|
const dom_1 = __webpack_require__(394);
|
|
4395
|
-
function parse(source,
|
|
4419
|
+
function parse(source, options = {}, context) {
|
|
4396
4420
|
const url = (0, header_2.headers)(source).find(field => field.toLowerCase().startsWith('url:'))?.slice(4).trim() ?? '';
|
|
4397
4421
|
source = !context ? (0, normalize_1.normalize)(source) : source;
|
|
4398
4422
|
context = {
|
|
4399
|
-
host:
|
|
4423
|
+
host: options.host ?? context?.host ?? new url_1.ReadonlyURL(location.pathname, location.origin),
|
|
4400
4424
|
url: url ? new url_1.ReadonlyURL(url) : context?.url,
|
|
4401
|
-
id:
|
|
4425
|
+
id: options.id ?? context?.id,
|
|
4402
4426
|
caches: context?.caches,
|
|
4403
4427
|
resources: context?.resources
|
|
4404
4428
|
};
|
|
@@ -4407,15 +4431,15 @@ function parse(source, opts = {}, context) {
|
|
|
4407
4431
|
const node = (0, dom_1.frag)();
|
|
4408
4432
|
let index = 0;
|
|
4409
4433
|
for (const seg of (0, segment_1.segment)(source)) {
|
|
4410
|
-
node.append(...((
|
|
4434
|
+
node.append(...(((0, header_1.header)((0, parser_1.input)(seg, {
|
|
4411
4435
|
header: index++ === 0
|
|
4412
4436
|
})) || (0, block_1.block)((0, parser_1.input)(seg, context)))?.foldl((acc, {
|
|
4413
4437
|
value
|
|
4414
4438
|
}) => void acc.push(value) || acc, []) ?? []));
|
|
4415
4439
|
}
|
|
4416
|
-
if (
|
|
4417
|
-
for (const _ of (0, figure_1.figure)(node,
|
|
4418
|
-
for (const _ of (0, note_1.note)(node,
|
|
4440
|
+
if (options.test) return node;
|
|
4441
|
+
for (const _ of (0, figure_1.figure)(node, options.notes, context));
|
|
4442
|
+
for (const _ of (0, note_1.note)(node, options.notes, context));
|
|
4419
4443
|
return node;
|
|
4420
4444
|
}
|
|
4421
4445
|
exports.parse = parse;
|
|
@@ -4477,7 +4501,7 @@ exports.block = (0, combinator_1.reset)({
|
|
|
4477
4501
|
recursions: [10 || 0 /* Recursion.block */, 20 || 0 /* Recursion.blockquote */, 40 || 0 /* Recursion.listitem */, 20 || 0 /* Recursion.inline */, 20 || 0 /* Recursion.bracket */, 20 || 0 /* Recursion.terminal */]
|
|
4478
4502
|
},
|
|
4479
4503
|
backtracks: {}
|
|
4480
|
-
}, error((0, combinator_1.union)([input => {
|
|
4504
|
+
}, error((0, combinator_1.union)([source_1.emptyline, input => {
|
|
4481
4505
|
const {
|
|
4482
4506
|
context: {
|
|
4483
4507
|
source,
|
|
@@ -4487,6 +4511,9 @@ exports.block = (0, combinator_1.reset)({
|
|
|
4487
4511
|
if (position === source.length) return;
|
|
4488
4512
|
const fst = source[position];
|
|
4489
4513
|
switch (fst) {
|
|
4514
|
+
case '\n':
|
|
4515
|
+
input.context.position = source.length;
|
|
4516
|
+
return new parser_1.List();
|
|
4490
4517
|
case '=':
|
|
4491
4518
|
if (source.startsWith('===', position)) return (0, pagebreak_1.pagebreak)(input);
|
|
4492
4519
|
break;
|
|
@@ -4530,7 +4557,7 @@ exports.block = (0, combinator_1.reset)({
|
|
|
4530
4557
|
default:
|
|
4531
4558
|
if ('0' <= fst && fst <= '9') return (0, olist_1.olist)(input);
|
|
4532
4559
|
}
|
|
4533
|
-
},
|
|
4560
|
+
}, paragraph_1.paragraph])));
|
|
4534
4561
|
function error(parser) {
|
|
4535
4562
|
const reg = new RegExp(String.raw`^${"\u0007" /* Command.Error */}.*\n`);
|
|
4536
4563
|
return (0, combinator_1.recover)((0, combinator_1.fallback)((0, combinator_1.open)("\u0007" /* Command.Error */, ({
|
|
@@ -4655,7 +4682,7 @@ exports.codeblock = (0, combinator_1.block)((0, combinator_1.fmap)((0, combinato
|
|
|
4655
4682
|
'data-lang': params.lang || undefined,
|
|
4656
4683
|
'data-line': params.line || undefined,
|
|
4657
4684
|
'data-path': params.path || undefined
|
|
4658
|
-
}, params.lang ? context.caches?.code?.get(`${params.lang ?? ''}\n${body.slice(0, -1)}`)?.cloneNode(true).childNodes || body.slice(0, -1) || undefined : (0, dom_1.defrag)((0, util_1.unwrap)((0,
|
|
4685
|
+
}, params.lang ? context.caches?.code?.get(`${params.lang ?? ''}\n${body.slice(0, -1)}`)?.cloneNode(true).childNodes || body.slice(0, -1) || undefined : (0, dom_1.defrag)((0, util_1.unwrap)((0, autolink_1.autolink)((0, parser_1.subinput)(body.slice(0, -1), context)))));
|
|
4659
4686
|
return new parser_1.List([new parser_1.Data(el)]);
|
|
4660
4687
|
}));
|
|
4661
4688
|
|
|
@@ -4812,7 +4839,7 @@ exports.example = (0, combinator_1.recursion)(1 /* Recursion.block */, (0, combi
|
|
|
4812
4839
|
'data-type': 'math'
|
|
4813
4840
|
}, [(0, dom_1.html)('pre', {
|
|
4814
4841
|
translate: 'no'
|
|
4815
|
-
}, body.slice(0, -1)), (0, dom_1.html)('hr'), (0,
|
|
4842
|
+
}, body.slice(0, -1)), (0, dom_1.html)('hr'), (0, mathblock_1.mathblock)((0, parser_1.subinput)(`$$\n${body}$$`, context)).head.value]))]);
|
|
4816
4843
|
default:
|
|
4817
4844
|
return new parser_1.List([new parser_1.Data((0, dom_1.html)('pre', {
|
|
4818
4845
|
class: 'invalid',
|
|
@@ -4916,7 +4943,7 @@ const memoize_1 = __webpack_require__(6925);
|
|
|
4916
4943
|
const dom_1 = __webpack_require__(394);
|
|
4917
4944
|
exports.segment = (0, combinator_1.block)((0, combinator_1.match)(/(~{3,})(?:figure[^\S\n])?(?=\[?\$)/y, (0, memoize_1.memoize)(([, fence], closer = new RegExp(String.raw`${fence}[^\S\n]*(?:$|\n)`, 'y')) => (0, combinator_1.close)((0, combinator_1.sequence)([source_1.contentline, (0, combinator_1.inits)([
|
|
4918
4945
|
// All parsers which can include closing terms.
|
|
4919
|
-
(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,
|
|
4946
|
+
(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 <= 16 ? fence.length : -1, [])));
|
|
4920
4947
|
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/y)])), (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.lineshortmedia)])), source_1.emptyline, (0, combinator_1.block)((0, visibility_1.visualize)((0, visibility_1.trimBlank)((0, combinator_1.some)(inline_1.inline))))])]), false), nodes => {
|
|
4921
4948
|
const [label, param, content, ...caption] = (0, util_1.unwrap)(nodes);
|
|
4922
4949
|
return new parser_1.List([new parser_1.Data((0, dom_1.html)('figure', attributes(label.getAttribute('data-label'), param, content, caption), [(0, dom_1.html)('figcaption', [(0, dom_1.html)('span', {
|
|
@@ -5024,7 +5051,7 @@ exports.message = (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_
|
|
|
5024
5051
|
return new parser_1.List([new parser_1.Data((0, dom_1.html)('section', {
|
|
5025
5052
|
class: `message`,
|
|
5026
5053
|
'data-type': type
|
|
5027
|
-
}, [...(0, segment_1.segment)(body)].reduce((acc, seg) => (0, array_1.push)(acc, (0, util_1.unwrap)(
|
|
5054
|
+
}, [...(0, segment_1.segment)(body)].reduce((acc, seg) => (0, array_1.push)(acc, (0, util_1.unwrap)(content((0, parser_1.subinput)(seg, context)))), [(0, dom_1.html)('h1', title(type))])))]);
|
|
5028
5055
|
}));
|
|
5029
5056
|
function title(type) {
|
|
5030
5057
|
switch (type) {
|
|
@@ -5103,7 +5130,7 @@ exports.table = (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.
|
|
|
5103
5130
|
switch (type) {
|
|
5104
5131
|
case 'grid':
|
|
5105
5132
|
case undefined:
|
|
5106
|
-
return (
|
|
5133
|
+
return (parser((0, parser_1.subinput)(body, context)) ?? new parser_1.List([new parser_1.Data((0, dom_1.html)('table'))])).foldl((acc, {
|
|
5107
5134
|
value
|
|
5108
5135
|
}) => acc.push(new parser_1.Data((0, dom_1.define)(value, {
|
|
5109
5136
|
'data-type': type
|
|
@@ -6353,7 +6380,7 @@ const parser_1 = __webpack_require__(605);
|
|
|
6353
6380
|
const combinator_1 = __webpack_require__(3484);
|
|
6354
6381
|
const link_1 = __webpack_require__(3628);
|
|
6355
6382
|
const source_1 = __webpack_require__(8745);
|
|
6356
|
-
exports.url = (0, combinator_1.lazy)(() => (0, combinator_1.rewrite)((0, combinator_1.open)(/(?<![0-
|
|
6383
|
+
exports.url = (0, combinator_1.lazy)(() => (0, combinator_1.rewrite)((0, combinator_1.open)(/(?<![0-9A-Za-z][.+-]?)https?:\/\/(?=[\x21-\x7E])/y, (0, combinator_1.precedence)(0, (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(source_1.unescsource, /(?<![-+*=~^_,.;:!?])[-+*=~^_,.;:!?]*(?=[\\$"`\[\](){}<>()[]{}|]|[^\x21-\x7E]|$)/y), (0, combinator_1.precedence)(1, (0, combinator_1.verify)(bracket, ns => ns.length > 0))]), undefined, [[/[^\x21-\x7E]|\$/y, 9]])), false, [3 | 0 /* Backtrack.autolink */]), (0, combinator_1.union)([(0, combinator_1.constraint)(1 /* State.autolink */, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.convert)(url => `{ ${url} }`, link_1.unsafelink, false))), ({
|
|
6357
6384
|
context: {
|
|
6358
6385
|
source
|
|
6359
6386
|
}
|
|
@@ -6630,7 +6657,7 @@ nodes => new parser_1.List([new parser_1.Data((0, dom_1.html)('em', [(0, dom_1.h
|
|
|
6630
6657
|
case 0:
|
|
6631
6658
|
break;
|
|
6632
6659
|
case 1:
|
|
6633
|
-
nodes = (0,
|
|
6660
|
+
nodes = (0, combinator_1.bind)(subemphasis, ds => {
|
|
6634
6661
|
const {
|
|
6635
6662
|
source
|
|
6636
6663
|
} = context;
|
|
@@ -6642,11 +6669,11 @@ nodes => new parser_1.List([new parser_1.Data((0, dom_1.html)('em', [(0, dom_1.h
|
|
|
6642
6669
|
}
|
|
6643
6670
|
})({
|
|
6644
6671
|
context
|
|
6645
|
-
})
|
|
6672
|
+
}) ?? prepend('*', nodes);
|
|
6646
6673
|
prefix -= 1;
|
|
6647
6674
|
break;
|
|
6648
6675
|
case 2:
|
|
6649
|
-
nodes = (0,
|
|
6676
|
+
nodes = (0, combinator_1.bind)(substrong, ds => {
|
|
6650
6677
|
const {
|
|
6651
6678
|
source
|
|
6652
6679
|
} = context;
|
|
@@ -6658,7 +6685,7 @@ nodes => new parser_1.List([new parser_1.Data((0, dom_1.html)('em', [(0, dom_1.h
|
|
|
6658
6685
|
}
|
|
6659
6686
|
})({
|
|
6660
6687
|
context
|
|
6661
|
-
})
|
|
6688
|
+
}) ?? prepend('**', nodes);
|
|
6662
6689
|
prefix -= 2;
|
|
6663
6690
|
break;
|
|
6664
6691
|
}
|
|
@@ -7601,7 +7628,7 @@ exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(64
|
|
|
7601
7628
|
context
|
|
7602
7629
|
});
|
|
7603
7630
|
if (state & 128 /* State.annotation */ && next) {
|
|
7604
|
-
return as.import(bs).import(
|
|
7631
|
+
return as.import(bs).import(result).import(next);
|
|
7605
7632
|
}
|
|
7606
7633
|
}
|
|
7607
7634
|
context.position = position;
|
|
@@ -7744,7 +7771,7 @@ const text = input => {
|
|
|
7744
7771
|
case '&':
|
|
7745
7772
|
{
|
|
7746
7773
|
const result = (0, htmlentity_1.unsafehtmlentity)(input) ?? (0, source_1.txt)(input);
|
|
7747
|
-
acc.last.value +=
|
|
7774
|
+
acc.last.value += result.head.value;
|
|
7748
7775
|
continue;
|
|
7749
7776
|
}
|
|
7750
7777
|
default:
|
|
@@ -7756,7 +7783,7 @@ const text = input => {
|
|
|
7756
7783
|
continue;
|
|
7757
7784
|
}
|
|
7758
7785
|
const result = (0, source_1.txt)(input);
|
|
7759
|
-
acc.last.value +=
|
|
7786
|
+
acc.last.value += result.head?.value ?? '';
|
|
7760
7787
|
continue;
|
|
7761
7788
|
}
|
|
7762
7789
|
}
|
|
@@ -7768,7 +7795,7 @@ const text = input => {
|
|
|
7768
7795
|
function* zip(a, b) {
|
|
7769
7796
|
const ia = a[Symbol.iterator]();
|
|
7770
7797
|
const ib = b[Symbol.iterator]();
|
|
7771
|
-
|
|
7798
|
+
for (;;) {
|
|
7772
7799
|
const ra = ia.next();
|
|
7773
7800
|
const rb = ib.next();
|
|
7774
7801
|
if (ra.done) break;
|
|
@@ -8128,7 +8155,7 @@ function* proc(defs, note) {
|
|
|
8128
8155
|
I: for (const [key, def] of defs) {
|
|
8129
8156
|
defs.delete(key);
|
|
8130
8157
|
++count;
|
|
8131
|
-
|
|
8158
|
+
for (; length > size;) {
|
|
8132
8159
|
const node = children[count - 1];
|
|
8133
8160
|
if (equal(node, def)) continue I;
|
|
8134
8161
|
yield note.removeChild(node);
|
|
@@ -8139,7 +8166,7 @@ function* proc(defs, note) {
|
|
|
8139
8166
|
yield note.insertBefore(def, node);
|
|
8140
8167
|
++length;
|
|
8141
8168
|
}
|
|
8142
|
-
|
|
8169
|
+
for (; length > size;) {
|
|
8143
8170
|
yield note.removeChild(children[size]);
|
|
8144
8171
|
--length;
|
|
8145
8172
|
}
|
|
@@ -8160,7 +8187,6 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
8160
8187
|
value: true
|
|
8161
8188
|
}));
|
|
8162
8189
|
exports.validate = exports.segment = exports.MAX_INPUT_SIZE = exports.MAX_SEGMENT_SIZE = void 0;
|
|
8163
|
-
const parser_1 = __webpack_require__(605);
|
|
8164
8190
|
const combinator_1 = __webpack_require__(3484);
|
|
8165
8191
|
const heading_1 = __webpack_require__(2778);
|
|
8166
8192
|
const codeblock_1 = __webpack_require__(9194);
|
|
@@ -8198,26 +8224,22 @@ const parser = (0, combinator_1.union)([input => {
|
|
|
8198
8224
|
}, (0, combinator_1.some)(source_1.contentline, exports.MAX_SEGMENT_SIZE + 1), (0, combinator_1.some)(source_1.emptyline, exports.MAX_SEGMENT_SIZE + 1)]);
|
|
8199
8225
|
function* segment(source) {
|
|
8200
8226
|
if (!validate(source, exports.MAX_INPUT_SIZE)) return yield `${"\u0007" /* Command.Error */}Too large input over ${exports.MAX_INPUT_SIZE.toLocaleString('en')} bytes.\n${source.slice(0, 1001)}`;
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
|
|
8204
|
-
};
|
|
8205
|
-
const input = {
|
|
8206
|
-
context
|
|
8207
|
-
};
|
|
8208
|
-
while (context.position < source.length) {
|
|
8209
|
-
const {
|
|
8227
|
+
for (let position = 0; position < source.length;) {
|
|
8228
|
+
const context = {
|
|
8229
|
+
source,
|
|
8210
8230
|
position
|
|
8211
|
-
}
|
|
8212
|
-
const result = parser(
|
|
8213
|
-
|
|
8231
|
+
};
|
|
8232
|
+
const result = parser({
|
|
8233
|
+
context
|
|
8234
|
+
});
|
|
8235
|
+
const segs = result.length > 0 ? result.foldl((acc, {
|
|
8214
8236
|
value
|
|
8215
8237
|
}) => void acc.push(value) || acc, []) : [source.slice(position, context.position)];
|
|
8216
8238
|
for (let i = 0; i < segs.length; ++i) {
|
|
8217
8239
|
const seg = segs[i];
|
|
8218
8240
|
validate(seg, exports.MAX_SEGMENT_SIZE) ? yield seg : yield `${"\u0007" /* Command.Error */}Too large segment over ${exports.MAX_SEGMENT_SIZE.toLocaleString('en')} bytes.\n${seg}`;
|
|
8219
8241
|
}
|
|
8220
|
-
|
|
8242
|
+
position = context.position;
|
|
8221
8243
|
}
|
|
8222
8244
|
}
|
|
8223
8245
|
exports.segment = segment;
|
|
@@ -8386,6 +8408,7 @@ const anyline = input => {
|
|
|
8386
8408
|
source,
|
|
8387
8409
|
position
|
|
8388
8410
|
} = context;
|
|
8411
|
+
if (position === source.length) return;
|
|
8389
8412
|
context.position = source.indexOf('\n', position) + 1 || source.length;
|
|
8390
8413
|
return new parser_1.List();
|
|
8391
8414
|
};
|
|
@@ -8399,6 +8422,8 @@ const emptyline = input => {
|
|
|
8399
8422
|
source,
|
|
8400
8423
|
position
|
|
8401
8424
|
} = context;
|
|
8425
|
+
if (position === source.length) return;
|
|
8426
|
+
if (source[position] === '\n') return ++context.position, new parser_1.List();
|
|
8402
8427
|
regEmptyline.lastIndex = position;
|
|
8403
8428
|
regEmptyline.test(source);
|
|
8404
8429
|
const i = regEmptyline.lastIndex;
|
|
@@ -8416,6 +8441,8 @@ const contentline = input => {
|
|
|
8416
8441
|
source,
|
|
8417
8442
|
position
|
|
8418
8443
|
} = context;
|
|
8444
|
+
if (position === source.length) return;
|
|
8445
|
+
if (source[position] === '\n') return;
|
|
8419
8446
|
regContentline.lastIndex = position;
|
|
8420
8447
|
regContentline.test(source);
|
|
8421
8448
|
const i = regContentline.lastIndex;
|
|
@@ -8451,7 +8478,7 @@ function strs(pattern) {
|
|
|
8451
8478
|
source
|
|
8452
8479
|
} = context;
|
|
8453
8480
|
let acc = '';
|
|
8454
|
-
|
|
8481
|
+
for (; context.position < source.length && source.startsWith(pattern, context.position);) {
|
|
8455
8482
|
acc += pattern;
|
|
8456
8483
|
context.position += pattern.length;
|
|
8457
8484
|
}
|
|
@@ -8809,6 +8836,7 @@ const alias_1 = __webpack_require__(5413);
|
|
|
8809
8836
|
const parser_1 = __webpack_require__(605);
|
|
8810
8837
|
const dom_1 = __webpack_require__(394);
|
|
8811
8838
|
function* unwrap(nodes) {
|
|
8839
|
+
if (nodes === undefined) return;
|
|
8812
8840
|
for (const node of nodes) {
|
|
8813
8841
|
yield node.value;
|
|
8814
8842
|
}
|
|
@@ -8840,7 +8868,7 @@ function repeat(symbol, parser, cons, termination = (nodes, context, prefix, pos
|
|
|
8840
8868
|
} = context;
|
|
8841
8869
|
let nodes = new parser_1.List();
|
|
8842
8870
|
let i = symbol.length;
|
|
8843
|
-
|
|
8871
|
+
for (; source[context.position + i] === source[context.position];) ++i;
|
|
8844
8872
|
context.position += i;
|
|
8845
8873
|
let state = false;
|
|
8846
8874
|
for (; i >= symbol.length; i -= symbol.length) {
|
|
@@ -8854,7 +8882,7 @@ function repeat(symbol, parser, cons, termination = (nodes, context, prefix, pos
|
|
|
8854
8882
|
const result = parser(input);
|
|
8855
8883
|
context.buffer = buf;
|
|
8856
8884
|
if (result === undefined) break;
|
|
8857
|
-
nodes =
|
|
8885
|
+
nodes = result;
|
|
8858
8886
|
switch (nodes.last?.value) {
|
|
8859
8887
|
case "\u0018" /* Command.Cancel */:
|
|
8860
8888
|
nodes.pop();
|
|
@@ -8983,7 +9011,7 @@ function isTightStart(input, except) {
|
|
|
8983
9011
|
return source[position + 1]?.trimStart() !== '';
|
|
8984
9012
|
case '&':
|
|
8985
9013
|
switch (true) {
|
|
8986
|
-
case source.length - position > 2 && source[position + 1] !== ' ' && (0,
|
|
9014
|
+
case source.length - position > 2 && source[position + 1] !== ' ' && (0, htmlentity_1.unsafehtmlentity)(input)?.head?.value.trimStart() === '':
|
|
8987
9015
|
context.position = position;
|
|
8988
9016
|
return false;
|
|
8989
9017
|
}
|