securemark 0.294.0 → 0.294.1
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/dist/index.js +164 -119
- 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/indent.ts +3 -7
- 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 +2 -2
- package/src/combinator/data/parser/context.test.ts +4 -4
- package/src/combinator/data/parser/inits.ts +4 -6
- package/src/combinator/data/parser/sequence.ts +4 -6
- package/src/combinator/data/parser/some.ts +5 -7
- package/src/combinator/data/parser.ts +3 -21
- package/src/debug.test.ts +2 -2
- package/src/parser/api/bind.ts +5 -5
- package/src/parser/api/header.ts +2 -2
- package/src/parser/api/normalize.ts +2 -2
- package/src/parser/api/parse.ts +2 -2
- 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 +4 -0
- 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 +4 -4
- package/src/parser/source/line.ts +5 -0
- package/src/parser/source/str.ts +1 -1
- package/src/parser/util.ts +5 -5
- package/src/parser/visibility.ts +2 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.294.
|
|
1
|
+
/*! securemark v0.294.1 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
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
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;
|
|
881
|
+
if (node === this.head) break;
|
|
882
|
+
}
|
|
883
|
+
return acc;
|
|
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;
|
|
870
890
|
if (node === this.head) break;
|
|
871
891
|
}
|
|
872
892
|
return acc;
|
|
873
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;
|
|
@@ -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
|
}));
|
|
@@ -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.clean = 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,
|
|
@@ -3372,25 +3427,10 @@ function clean(context) {
|
|
|
3372
3427
|
return context;
|
|
3373
3428
|
}
|
|
3374
3429
|
exports.clean = clean;
|
|
3375
|
-
function eval_(result, default_) {
|
|
3376
|
-
return result ? result : default_;
|
|
3377
|
-
}
|
|
3378
|
-
exports.eval = eval_;
|
|
3379
3430
|
function failsafe(parser) {
|
|
3380
3431
|
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;
|
|
3432
|
+
const position = input.context.position;
|
|
3433
|
+
return parser(input) ?? (input.context.position = position, undefined);
|
|
3394
3434
|
};
|
|
3395
3435
|
}
|
|
3396
3436
|
exports.failsafe = failsafe;
|
|
@@ -3763,7 +3803,7 @@ exports.Delimiters = Delimiters;
|
|
|
3763
3803
|
/***/ },
|
|
3764
3804
|
|
|
3765
3805
|
/***/ 2861
|
|
3766
|
-
(__unused_webpack_module, exports
|
|
3806
|
+
(__unused_webpack_module, exports) {
|
|
3767
3807
|
|
|
3768
3808
|
"use strict";
|
|
3769
3809
|
|
|
@@ -3772,7 +3812,6 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
3772
3812
|
value: true
|
|
3773
3813
|
}));
|
|
3774
3814
|
exports.inits = void 0;
|
|
3775
|
-
const parser_1 = __webpack_require__(605);
|
|
3776
3815
|
function inits(parsers, resume) {
|
|
3777
3816
|
if (parsers.length === 1) return parsers[0];
|
|
3778
3817
|
return input => {
|
|
@@ -3789,10 +3828,10 @@ function inits(parsers, resume) {
|
|
|
3789
3828
|
if (context.delimiters?.match(input)) break;
|
|
3790
3829
|
const result = parsers[i](input);
|
|
3791
3830
|
if (result === undefined) break;
|
|
3792
|
-
nodes = nodes
|
|
3793
|
-
if (resume?.(
|
|
3831
|
+
nodes = nodes?.import(result) ?? result;
|
|
3832
|
+
if (resume?.(result) === false) break;
|
|
3794
3833
|
}
|
|
3795
|
-
return
|
|
3834
|
+
return context.position > position ? nodes : undefined;
|
|
3796
3835
|
};
|
|
3797
3836
|
}
|
|
3798
3837
|
exports.inits = inits;
|
|
@@ -3800,7 +3839,7 @@ exports.inits = inits;
|
|
|
3800
3839
|
/***/ },
|
|
3801
3840
|
|
|
3802
3841
|
/***/ 3989
|
|
3803
|
-
(__unused_webpack_module, exports
|
|
3842
|
+
(__unused_webpack_module, exports) {
|
|
3804
3843
|
|
|
3805
3844
|
"use strict";
|
|
3806
3845
|
|
|
@@ -3809,7 +3848,6 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
3809
3848
|
value: true
|
|
3810
3849
|
}));
|
|
3811
3850
|
exports.sequence = void 0;
|
|
3812
|
-
const parser_1 = __webpack_require__(605);
|
|
3813
3851
|
function sequence(parsers, resume) {
|
|
3814
3852
|
if (parsers.length === 1) return parsers[0];
|
|
3815
3853
|
return input => {
|
|
@@ -3826,10 +3864,10 @@ function sequence(parsers, resume) {
|
|
|
3826
3864
|
if (context.delimiters?.match(input)) return;
|
|
3827
3865
|
const result = parsers[i](input);
|
|
3828
3866
|
if (result === undefined) return;
|
|
3829
|
-
nodes = nodes
|
|
3830
|
-
if (resume?.(
|
|
3867
|
+
nodes = nodes?.import(result) ?? result;
|
|
3868
|
+
if (resume?.(result) === false) return;
|
|
3831
3869
|
}
|
|
3832
|
-
return
|
|
3870
|
+
return context.position > position ? nodes : undefined;
|
|
3833
3871
|
};
|
|
3834
3872
|
}
|
|
3835
3873
|
exports.sequence = sequence;
|
|
@@ -3846,7 +3884,6 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
3846
3884
|
value: true
|
|
3847
3885
|
}));
|
|
3848
3886
|
exports.some = void 0;
|
|
3849
|
-
const parser_1 = __webpack_require__(605);
|
|
3850
3887
|
const delimiter_1 = __webpack_require__(5691);
|
|
3851
3888
|
function some(parser, end, delimiters = [], limit = -1) {
|
|
3852
3889
|
if (typeof end === 'number') return some(parser, undefined, delimiters, end);
|
|
@@ -3870,19 +3907,19 @@ function some(parser, end, delimiters = [], limit = -1) {
|
|
|
3870
3907
|
context.delimiters ??= new delimiter_1.Delimiters();
|
|
3871
3908
|
context.delimiters.push(delims);
|
|
3872
3909
|
}
|
|
3873
|
-
while
|
|
3874
|
-
|
|
3910
|
+
// whileは数倍遅い
|
|
3911
|
+
for (; context.position < source.length;) {
|
|
3875
3912
|
if (match(input)) break;
|
|
3876
3913
|
if (context.delimiters?.match(input)) break;
|
|
3877
3914
|
const result = parser(input);
|
|
3878
3915
|
if (result === undefined) break;
|
|
3879
|
-
nodes = nodes
|
|
3916
|
+
nodes = nodes?.import(result) ?? result;
|
|
3880
3917
|
if (limit >= 0 && context.position - position > limit) break;
|
|
3881
3918
|
}
|
|
3882
3919
|
if (delims.length > 0) {
|
|
3883
3920
|
context.delimiters.pop(delims.length);
|
|
3884
3921
|
}
|
|
3885
|
-
return
|
|
3922
|
+
return context.position > position ? nodes : undefined;
|
|
3886
3923
|
};
|
|
3887
3924
|
}
|
|
3888
3925
|
exports.some = some;
|
|
@@ -4112,7 +4149,7 @@ function bind(target, settings) {
|
|
|
4112
4149
|
let index = head;
|
|
4113
4150
|
for (; index < sourceSegments.length - last; ++index) {
|
|
4114
4151
|
const seg = sourceSegments[index];
|
|
4115
|
-
const es = (
|
|
4152
|
+
const es = ((0, header_1.header)((0, parser_1.input)(seg, {
|
|
4116
4153
|
header: index === 0
|
|
4117
4154
|
})) || (0, block_1.block)((0, parser_1.input)(seg, context)))?.foldl((acc, {
|
|
4118
4155
|
value
|
|
@@ -4123,7 +4160,7 @@ function bind(target, settings) {
|
|
|
4123
4160
|
// Therefore any `base` node will never be unavailable by deletions until all the dependent `el` nodes are added.
|
|
4124
4161
|
(0, array_1.push)(adds, es.map(el => [el, base]));
|
|
4125
4162
|
adds.reverse();
|
|
4126
|
-
|
|
4163
|
+
for (; adds.length > 0;) {
|
|
4127
4164
|
const [el, base] = adds.pop();
|
|
4128
4165
|
target.insertBefore(el, base);
|
|
4129
4166
|
yield {
|
|
@@ -4141,7 +4178,7 @@ function bind(target, settings) {
|
|
|
4141
4178
|
(0, array_1.push)(dels, es.map(el => [el]));
|
|
4142
4179
|
}
|
|
4143
4180
|
adds.reverse();
|
|
4144
|
-
|
|
4181
|
+
for (; adds.length > 0;) {
|
|
4145
4182
|
const [el, base] = adds.pop();
|
|
4146
4183
|
target.insertBefore(el, base);
|
|
4147
4184
|
yield {
|
|
@@ -4153,7 +4190,7 @@ function bind(target, settings) {
|
|
|
4153
4190
|
};
|
|
4154
4191
|
}
|
|
4155
4192
|
dels.reverse();
|
|
4156
|
-
|
|
4193
|
+
for (; dels.length > 0;) {
|
|
4157
4194
|
const [el] = dels.pop();
|
|
4158
4195
|
el.parentNode?.removeChild(el);
|
|
4159
4196
|
yield {
|
|
@@ -4297,7 +4334,7 @@ exports.headers = headers;
|
|
|
4297
4334
|
function parse(source) {
|
|
4298
4335
|
const i = (0, parser_1.input)(source, {});
|
|
4299
4336
|
const result = (0, header_1.header)(i);
|
|
4300
|
-
const el =
|
|
4337
|
+
const el = result?.head?.value;
|
|
4301
4338
|
return el?.tagName === 'ASIDE' ? [el, i.context.position] : [];
|
|
4302
4339
|
}
|
|
4303
4340
|
|
|
@@ -4330,7 +4367,7 @@ function sanitize(source) {
|
|
|
4330
4367
|
// https://en.wikipedia.org/wiki/Whitespace_character
|
|
4331
4368
|
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
4369
|
const unreadableHTMLEntityNames = exports.invisibleHTMLEntityNames.slice(2);
|
|
4333
|
-
const unreadableEscapableCharacters = unreadableHTMLEntityNames.map(name => (0,
|
|
4370
|
+
const unreadableEscapableCharacters = unreadableHTMLEntityNames.map(name => (0, htmlentity_1.unsafehtmlentity)((0, parser_1.input)(`&${name};`, {})).head.value);
|
|
4334
4371
|
const unreadableEscapableCharacter = new RegExp(`[${unreadableEscapableCharacters.join('')}]`, 'g');
|
|
4335
4372
|
// https://www.pandanoir.info/entry/2018/03/11/193000
|
|
4336
4373
|
// http://anti.rosx.net/etc/memo/002_space.html
|
|
@@ -4407,7 +4444,7 @@ function parse(source, opts = {}, context) {
|
|
|
4407
4444
|
const node = (0, dom_1.frag)();
|
|
4408
4445
|
let index = 0;
|
|
4409
4446
|
for (const seg of (0, segment_1.segment)(source)) {
|
|
4410
|
-
node.append(...((
|
|
4447
|
+
node.append(...(((0, header_1.header)((0, parser_1.input)(seg, {
|
|
4411
4448
|
header: index++ === 0
|
|
4412
4449
|
})) || (0, block_1.block)((0, parser_1.input)(seg, context)))?.foldl((acc, {
|
|
4413
4450
|
value
|
|
@@ -4487,6 +4524,9 @@ exports.block = (0, combinator_1.reset)({
|
|
|
4487
4524
|
if (position === source.length) return;
|
|
4488
4525
|
const fst = source[position];
|
|
4489
4526
|
switch (fst) {
|
|
4527
|
+
case '\n':
|
|
4528
|
+
input.context.position = source.length;
|
|
4529
|
+
return new parser_1.List();
|
|
4490
4530
|
case '=':
|
|
4491
4531
|
if (source.startsWith('===', position)) return (0, pagebreak_1.pagebreak)(input);
|
|
4492
4532
|
break;
|
|
@@ -4655,7 +4695,7 @@ exports.codeblock = (0, combinator_1.block)((0, combinator_1.fmap)((0, combinato
|
|
|
4655
4695
|
'data-lang': params.lang || undefined,
|
|
4656
4696
|
'data-line': params.line || undefined,
|
|
4657
4697
|
'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,
|
|
4698
|
+
}, 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
4699
|
return new parser_1.List([new parser_1.Data(el)]);
|
|
4660
4700
|
}));
|
|
4661
4701
|
|
|
@@ -4812,7 +4852,7 @@ exports.example = (0, combinator_1.recursion)(1 /* Recursion.block */, (0, combi
|
|
|
4812
4852
|
'data-type': 'math'
|
|
4813
4853
|
}, [(0, dom_1.html)('pre', {
|
|
4814
4854
|
translate: 'no'
|
|
4815
|
-
}, body.slice(0, -1)), (0, dom_1.html)('hr'), (0,
|
|
4855
|
+
}, body.slice(0, -1)), (0, dom_1.html)('hr'), (0, mathblock_1.mathblock)((0, parser_1.subinput)(`$$\n${body}$$`, context)).head.value]))]);
|
|
4816
4856
|
default:
|
|
4817
4857
|
return new parser_1.List([new parser_1.Data((0, dom_1.html)('pre', {
|
|
4818
4858
|
class: 'invalid',
|
|
@@ -4916,7 +4956,7 @@ const memoize_1 = __webpack_require__(6925);
|
|
|
4916
4956
|
const dom_1 = __webpack_require__(394);
|
|
4917
4957
|
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
4958
|
// 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,
|
|
4959
|
+
(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
4960
|
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
4961
|
const [label, param, content, ...caption] = (0, util_1.unwrap)(nodes);
|
|
4922
4962
|
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 +5064,7 @@ exports.message = (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_
|
|
|
5024
5064
|
return new parser_1.List([new parser_1.Data((0, dom_1.html)('section', {
|
|
5025
5065
|
class: `message`,
|
|
5026
5066
|
'data-type': type
|
|
5027
|
-
}, [...(0, segment_1.segment)(body)].reduce((acc, seg) => (0, array_1.push)(acc, (0, util_1.unwrap)(
|
|
5067
|
+
}, [...(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
5068
|
}));
|
|
5029
5069
|
function title(type) {
|
|
5030
5070
|
switch (type) {
|
|
@@ -5103,7 +5143,7 @@ exports.table = (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.
|
|
|
5103
5143
|
switch (type) {
|
|
5104
5144
|
case 'grid':
|
|
5105
5145
|
case undefined:
|
|
5106
|
-
return (
|
|
5146
|
+
return (parser((0, parser_1.subinput)(body, context)) ?? new parser_1.List([new parser_1.Data((0, dom_1.html)('table'))])).foldl((acc, {
|
|
5107
5147
|
value
|
|
5108
5148
|
}) => acc.push(new parser_1.Data((0, dom_1.define)(value, {
|
|
5109
5149
|
'data-type': type
|
|
@@ -6630,7 +6670,7 @@ nodes => new parser_1.List([new parser_1.Data((0, dom_1.html)('em', [(0, dom_1.h
|
|
|
6630
6670
|
case 0:
|
|
6631
6671
|
break;
|
|
6632
6672
|
case 1:
|
|
6633
|
-
nodes = (0,
|
|
6673
|
+
nodes = (0, combinator_1.bind)(subemphasis, ds => {
|
|
6634
6674
|
const {
|
|
6635
6675
|
source
|
|
6636
6676
|
} = context;
|
|
@@ -6642,11 +6682,11 @@ nodes => new parser_1.List([new parser_1.Data((0, dom_1.html)('em', [(0, dom_1.h
|
|
|
6642
6682
|
}
|
|
6643
6683
|
})({
|
|
6644
6684
|
context
|
|
6645
|
-
})
|
|
6685
|
+
}) ?? prepend('*', nodes);
|
|
6646
6686
|
prefix -= 1;
|
|
6647
6687
|
break;
|
|
6648
6688
|
case 2:
|
|
6649
|
-
nodes = (0,
|
|
6689
|
+
nodes = (0, combinator_1.bind)(substrong, ds => {
|
|
6650
6690
|
const {
|
|
6651
6691
|
source
|
|
6652
6692
|
} = context;
|
|
@@ -6658,7 +6698,7 @@ nodes => new parser_1.List([new parser_1.Data((0, dom_1.html)('em', [(0, dom_1.h
|
|
|
6658
6698
|
}
|
|
6659
6699
|
})({
|
|
6660
6700
|
context
|
|
6661
|
-
})
|
|
6701
|
+
}) ?? prepend('**', nodes);
|
|
6662
6702
|
prefix -= 2;
|
|
6663
6703
|
break;
|
|
6664
6704
|
}
|
|
@@ -7601,7 +7641,7 @@ exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(64
|
|
|
7601
7641
|
context
|
|
7602
7642
|
});
|
|
7603
7643
|
if (state & 128 /* State.annotation */ && next) {
|
|
7604
|
-
return as.import(bs).import(
|
|
7644
|
+
return as.import(bs).import(result).import(next);
|
|
7605
7645
|
}
|
|
7606
7646
|
}
|
|
7607
7647
|
context.position = position;
|
|
@@ -7744,7 +7784,7 @@ const text = input => {
|
|
|
7744
7784
|
case '&':
|
|
7745
7785
|
{
|
|
7746
7786
|
const result = (0, htmlentity_1.unsafehtmlentity)(input) ?? (0, source_1.txt)(input);
|
|
7747
|
-
acc.last.value +=
|
|
7787
|
+
acc.last.value += result.head.value;
|
|
7748
7788
|
continue;
|
|
7749
7789
|
}
|
|
7750
7790
|
default:
|
|
@@ -7756,7 +7796,7 @@ const text = input => {
|
|
|
7756
7796
|
continue;
|
|
7757
7797
|
}
|
|
7758
7798
|
const result = (0, source_1.txt)(input);
|
|
7759
|
-
acc.last.value +=
|
|
7799
|
+
acc.last.value += result.head?.value ?? '';
|
|
7760
7800
|
continue;
|
|
7761
7801
|
}
|
|
7762
7802
|
}
|
|
@@ -7768,7 +7808,7 @@ const text = input => {
|
|
|
7768
7808
|
function* zip(a, b) {
|
|
7769
7809
|
const ia = a[Symbol.iterator]();
|
|
7770
7810
|
const ib = b[Symbol.iterator]();
|
|
7771
|
-
|
|
7811
|
+
for (;;) {
|
|
7772
7812
|
const ra = ia.next();
|
|
7773
7813
|
const rb = ib.next();
|
|
7774
7814
|
if (ra.done) break;
|
|
@@ -8128,7 +8168,7 @@ function* proc(defs, note) {
|
|
|
8128
8168
|
I: for (const [key, def] of defs) {
|
|
8129
8169
|
defs.delete(key);
|
|
8130
8170
|
++count;
|
|
8131
|
-
|
|
8171
|
+
for (; length > size;) {
|
|
8132
8172
|
const node = children[count - 1];
|
|
8133
8173
|
if (equal(node, def)) continue I;
|
|
8134
8174
|
yield note.removeChild(node);
|
|
@@ -8139,7 +8179,7 @@ function* proc(defs, note) {
|
|
|
8139
8179
|
yield note.insertBefore(def, node);
|
|
8140
8180
|
++length;
|
|
8141
8181
|
}
|
|
8142
|
-
|
|
8182
|
+
for (; length > size;) {
|
|
8143
8183
|
yield note.removeChild(children[size]);
|
|
8144
8184
|
--length;
|
|
8145
8185
|
}
|
|
@@ -8205,12 +8245,12 @@ function* segment(source) {
|
|
|
8205
8245
|
const input = {
|
|
8206
8246
|
context
|
|
8207
8247
|
};
|
|
8208
|
-
|
|
8248
|
+
for (; context.position < source.length;) {
|
|
8209
8249
|
const {
|
|
8210
8250
|
position
|
|
8211
8251
|
} = context;
|
|
8212
8252
|
const result = parser(input);
|
|
8213
|
-
const segs =
|
|
8253
|
+
const segs = result.length > 0 ? result.foldl((acc, {
|
|
8214
8254
|
value
|
|
8215
8255
|
}) => void acc.push(value) || acc, []) : [source.slice(position, context.position)];
|
|
8216
8256
|
for (let i = 0; i < segs.length; ++i) {
|
|
@@ -8386,6 +8426,7 @@ const anyline = input => {
|
|
|
8386
8426
|
source,
|
|
8387
8427
|
position
|
|
8388
8428
|
} = context;
|
|
8429
|
+
if (position === source.length) return;
|
|
8389
8430
|
context.position = source.indexOf('\n', position) + 1 || source.length;
|
|
8390
8431
|
return new parser_1.List();
|
|
8391
8432
|
};
|
|
@@ -8399,6 +8440,8 @@ const emptyline = input => {
|
|
|
8399
8440
|
source,
|
|
8400
8441
|
position
|
|
8401
8442
|
} = context;
|
|
8443
|
+
if (position === source.length) return;
|
|
8444
|
+
if (source[position] === '\n') return ++context.position, new parser_1.List();
|
|
8402
8445
|
regEmptyline.lastIndex = position;
|
|
8403
8446
|
regEmptyline.test(source);
|
|
8404
8447
|
const i = regEmptyline.lastIndex;
|
|
@@ -8416,6 +8459,8 @@ const contentline = input => {
|
|
|
8416
8459
|
source,
|
|
8417
8460
|
position
|
|
8418
8461
|
} = context;
|
|
8462
|
+
if (position === source.length) return;
|
|
8463
|
+
if (source[position] === '\n') return;
|
|
8419
8464
|
regContentline.lastIndex = position;
|
|
8420
8465
|
regContentline.test(source);
|
|
8421
8466
|
const i = regContentline.lastIndex;
|
|
@@ -8451,7 +8496,7 @@ function strs(pattern) {
|
|
|
8451
8496
|
source
|
|
8452
8497
|
} = context;
|
|
8453
8498
|
let acc = '';
|
|
8454
|
-
|
|
8499
|
+
for (; context.position < source.length && source.startsWith(pattern, context.position);) {
|
|
8455
8500
|
acc += pattern;
|
|
8456
8501
|
context.position += pattern.length;
|
|
8457
8502
|
}
|
|
@@ -8809,7 +8854,7 @@ const alias_1 = __webpack_require__(5413);
|
|
|
8809
8854
|
const parser_1 = __webpack_require__(605);
|
|
8810
8855
|
const dom_1 = __webpack_require__(394);
|
|
8811
8856
|
function* unwrap(nodes) {
|
|
8812
|
-
for (const node of nodes) {
|
|
8857
|
+
for (const node of nodes ?? []) {
|
|
8813
8858
|
yield node.value;
|
|
8814
8859
|
}
|
|
8815
8860
|
}
|
|
@@ -8840,7 +8885,7 @@ function repeat(symbol, parser, cons, termination = (nodes, context, prefix, pos
|
|
|
8840
8885
|
} = context;
|
|
8841
8886
|
let nodes = new parser_1.List();
|
|
8842
8887
|
let i = symbol.length;
|
|
8843
|
-
|
|
8888
|
+
for (; source[context.position + i] === source[context.position];) ++i;
|
|
8844
8889
|
context.position += i;
|
|
8845
8890
|
let state = false;
|
|
8846
8891
|
for (; i >= symbol.length; i -= symbol.length) {
|
|
@@ -8854,7 +8899,7 @@ function repeat(symbol, parser, cons, termination = (nodes, context, prefix, pos
|
|
|
8854
8899
|
const result = parser(input);
|
|
8855
8900
|
context.buffer = buf;
|
|
8856
8901
|
if (result === undefined) break;
|
|
8857
|
-
nodes =
|
|
8902
|
+
nodes = result;
|
|
8858
8903
|
switch (nodes.last?.value) {
|
|
8859
8904
|
case "\u0018" /* Command.Cancel */:
|
|
8860
8905
|
nodes.pop();
|
|
@@ -8983,7 +9028,7 @@ function isTightStart(input, except) {
|
|
|
8983
9028
|
return source[position + 1]?.trimStart() !== '';
|
|
8984
9029
|
case '&':
|
|
8985
9030
|
switch (true) {
|
|
8986
|
-
case source.length - position > 2 && source[position + 1] !== ' ' && (0,
|
|
9031
|
+
case source.length - position > 2 && source[position + 1] !== ' ' && (0, htmlentity_1.unsafehtmlentity)(input)?.head?.value.trimStart() === '':
|
|
8987
9032
|
context.position = position;
|
|
8988
9033
|
return false;
|
|
8989
9034
|
}
|