securemark 0.295.0 → 0.295.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
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.295.
|
|
1
|
+
/*! securemark v0.295.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"));
|
|
@@ -3111,7 +3111,7 @@ function surround(opener, parser, closer, optional = false, backtracks = [], f,
|
|
|
3111
3111
|
case 'object':
|
|
3112
3112
|
closer = (0, combinator_1.clear)((0, combinator_1.matcher)(closer, true));
|
|
3113
3113
|
}
|
|
3114
|
-
const [rbs, wbs] = reduce(backtracks);
|
|
3114
|
+
const [blen, rbs, wbs] = reduce(backtracks);
|
|
3115
3115
|
return (0, parser_1.failsafe)(input => {
|
|
3116
3116
|
const {
|
|
3117
3117
|
context
|
|
@@ -3129,7 +3129,7 @@ function surround(opener, parser, closer, optional = false, backtracks = [], f,
|
|
|
3129
3129
|
if (!nodesO) {
|
|
3130
3130
|
return void revert(context, linebreak);
|
|
3131
3131
|
}
|
|
3132
|
-
if (rbs && isBacktrack(context, rbs, position,
|
|
3132
|
+
if (rbs && isBacktrack(context, rbs, position, blen)) {
|
|
3133
3133
|
return void revert(context, linebreak);
|
|
3134
3134
|
}
|
|
3135
3135
|
const nodesM = context.position < source.length ? parser(input) : undefined;
|
|
@@ -3158,30 +3158,22 @@ function surround(opener, parser, closer, optional = false, backtracks = [], f,
|
|
|
3158
3158
|
});
|
|
3159
3159
|
}
|
|
3160
3160
|
exports.surround = surround;
|
|
3161
|
-
function open(opener, parser, optional, backtracks) {
|
|
3161
|
+
function open(opener, parser, optional, backtracks = []) {
|
|
3162
3162
|
return surround(opener, parser, '', optional, backtracks);
|
|
3163
3163
|
}
|
|
3164
3164
|
exports.open = open;
|
|
3165
|
-
function close(parser, closer, optional, backtracks) {
|
|
3165
|
+
function close(parser, closer, optional, backtracks = []) {
|
|
3166
3166
|
return surround('', parser, closer, optional, backtracks);
|
|
3167
3167
|
}
|
|
3168
3168
|
exports.close = close;
|
|
3169
3169
|
const commandsize = 2;
|
|
3170
3170
|
function isBacktrack(context, backtrack, position = context.position, length = 1) {
|
|
3171
|
-
if (length === 0) return false;
|
|
3172
|
-
const {
|
|
3173
|
-
source
|
|
3174
|
-
} = context;
|
|
3175
|
-
if (position === source.length) return false;
|
|
3176
3171
|
const {
|
|
3177
3172
|
backtracks = {},
|
|
3178
3173
|
offset = 0
|
|
3179
3174
|
} = context;
|
|
3180
3175
|
for (let i = 0; i < length; ++i) {
|
|
3181
|
-
if (position + i
|
|
3182
|
-
if (i > 0 && source[position + i] !== source[position]) break;
|
|
3183
|
-
const pos = position + i + offset;
|
|
3184
|
-
if (backtracks[pos] & backtrack >>> commandsize) return true;
|
|
3176
|
+
if (backtracks[position + i + offset] & backtrack >>> commandsize) return true;
|
|
3185
3177
|
}
|
|
3186
3178
|
return false;
|
|
3187
3179
|
}
|
|
@@ -3189,34 +3181,32 @@ exports.isBacktrack = isBacktrack;
|
|
|
3189
3181
|
function setBacktrack(context, backtrack, position, length = 1) {
|
|
3190
3182
|
// バックトラックの可能性がなく記録不要の場合もあるが判別が面倒なので省略
|
|
3191
3183
|
|
|
3192
|
-
if (length === 0) return;
|
|
3193
|
-
const {
|
|
3194
|
-
source
|
|
3195
|
-
} = context;
|
|
3196
|
-
if (position === source.length) return;
|
|
3197
3184
|
const {
|
|
3198
3185
|
backtracks = {},
|
|
3199
3186
|
offset = 0
|
|
3200
3187
|
} = context;
|
|
3201
3188
|
for (let i = 0; i < length; ++i) {
|
|
3202
|
-
|
|
3203
|
-
const pos = position + i + offset;
|
|
3204
|
-
backtracks[pos] |= backtrack >>> commandsize;
|
|
3189
|
+
backtracks[position + i + offset] |= backtrack >>> commandsize;
|
|
3205
3190
|
}
|
|
3206
3191
|
}
|
|
3207
3192
|
exports.setBacktrack = setBacktrack;
|
|
3208
3193
|
function reduce(backtracks) {
|
|
3194
|
+
let len = 1;
|
|
3209
3195
|
let rbs = 0;
|
|
3210
3196
|
let wbs = 0;
|
|
3211
3197
|
for (const backtrack of backtracks) {
|
|
3212
|
-
if (backtrack
|
|
3198
|
+
if (backtrack >>> commandsize === 0) {
|
|
3199
|
+
len = backtrack;
|
|
3200
|
+
continue;
|
|
3201
|
+
}
|
|
3202
|
+
if (1 & backtrack) {
|
|
3213
3203
|
rbs |= backtrack;
|
|
3214
3204
|
}
|
|
3215
|
-
if (
|
|
3205
|
+
if (2 & backtrack) {
|
|
3216
3206
|
wbs |= backtrack;
|
|
3217
3207
|
}
|
|
3218
3208
|
}
|
|
3219
|
-
return [rbs, wbs];
|
|
3209
|
+
return [len, rbs, wbs];
|
|
3220
3210
|
}
|
|
3221
3211
|
function revert(context, linebreak) {
|
|
3222
3212
|
context.linebreak = linebreak;
|
|
@@ -6195,7 +6185,7 @@ const inline_1 = __webpack_require__(7973);
|
|
|
6195
6185
|
const visibility_1 = __webpack_require__(6364);
|
|
6196
6186
|
const util_1 = __webpack_require__(4992);
|
|
6197
6187
|
const dom_1 = __webpack_require__(394);
|
|
6198
|
-
exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(128 /* State.annotation */, (0, combinator_1.surround)('((', (0, combinator_1.precedence)(1, (0, combinator_1.state)(128 /* State.annotation */, (0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ')', [[')', 1]])))), '))', false, [1 | 4 /* Backtrack.common */, 3 | 128 /* Backtrack.doublebracket */], ([, ns], context) => context.linebreak === 0 ? new parser_1.List([new parser_1.Data((0, dom_1.html)('sup', {
|
|
6188
|
+
exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(128 /* State.annotation */, (0, combinator_1.surround)('((', (0, combinator_1.precedence)(1, (0, combinator_1.state)(128 /* State.annotation */, (0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ')', [[')', 1]])))), '))', false, [2, 1 | 4 /* Backtrack.common */, 3 | 128 /* Backtrack.doublebracket */], ([, ns], context) => context.linebreak === 0 ? new parser_1.List([new parser_1.Data((0, dom_1.html)('sup', {
|
|
6199
6189
|
class: 'annotation'
|
|
6200
6190
|
}, [(0, dom_1.html)('span', (0, dom_1.defrag)((0, util_1.unwrap)((0, visibility_1.trimBlankNodeEnd)(ns))))]))]) : undefined)));
|
|
6201
6191
|
|
|
@@ -7625,7 +7615,7 @@ const source_1 = __webpack_require__(8745);
|
|
|
7625
7615
|
const visibility_1 = __webpack_require__(6364);
|
|
7626
7616
|
const util_1 = __webpack_require__(4992);
|
|
7627
7617
|
const dom_1 = __webpack_require__(394);
|
|
7628
|
-
exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(64 /* State.reference */, (0, combinator_1.surround)((0, source_1.str)('[['), (0, combinator_1.precedence)(1, (0, combinator_1.state)(128 /* State.annotation */ | 64 /* State.reference */, (0, combinator_1.subsequence)([abbr, (0, visibility_1.trimBlankStart)((0, combinator_1.some)(inline_1.inline, ']', [[']', 1]]))]))), ']]', false, [1 | 4 /* Backtrack.common */, 3 | 128 /* Backtrack.doublebracket */], ([, ns], context) => {
|
|
7618
|
+
exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(64 /* State.reference */, (0, combinator_1.surround)((0, source_1.str)('[['), (0, combinator_1.precedence)(1, (0, combinator_1.state)(128 /* State.annotation */ | 64 /* State.reference */, (0, combinator_1.subsequence)([abbr, (0, visibility_1.trimBlankStart)((0, combinator_1.some)(inline_1.inline, ']', [[']', 1]]))]))), ']]', false, [2, 1 | 4 /* Backtrack.common */, 3 | 128 /* Backtrack.doublebracket */], ([, ns], context) => {
|
|
7629
7619
|
const {
|
|
7630
7620
|
position,
|
|
7631
7621
|
range = 0,
|
package/package.json
CHANGED
|
@@ -4,49 +4,49 @@ import { matcher, clear } from '../../../combinator';
|
|
|
4
4
|
export function surround<P extends Parser, S = string>(
|
|
5
5
|
opener: string | RegExp | Parser<S, Context<P>>, parser: IntermediateParser<P>, closer: string | RegExp | Parser<S, Context<P>>,
|
|
6
6
|
optional?: false,
|
|
7
|
-
backtracks?: readonly
|
|
7
|
+
backtracks?: readonly number[],
|
|
8
8
|
f?: (rss: [List<Data<S>>, List<Data<SubNode<P>>>, List<Data<S>>], context: Context<P>) => Result<Node<P>, Context<P>, SubParsers<P>>,
|
|
9
9
|
g?: (rss: [List<Data<S>>, List<Data<SubNode<P>>> | undefined], context: Context<P>) => Result<Node<P>, Context<P>, SubParsers<P>>,
|
|
10
10
|
): P;
|
|
11
11
|
export function surround<P extends Parser, S = string>(
|
|
12
12
|
opener: string | RegExp | Parser<S, Context<P>>, parser: IntermediateParser<P>, closer: string | RegExp | Parser<S, Context<P>>,
|
|
13
13
|
optional?: boolean,
|
|
14
|
-
backtracks?: readonly
|
|
14
|
+
backtracks?: readonly number[],
|
|
15
15
|
f?: (rss: [List<Data<S>>, List<Data<SubNode<P>>> | undefined, List<Data<S>>], context: Context<P>) => Result<Node<P>, Context<P>, SubParsers<P>>,
|
|
16
16
|
g?: (rss: [List<Data<S>>, List<Data<SubNode<P>>> | undefined], context: Context<P>) => Result<Node<P>, Context<P>, SubParsers<P>>,
|
|
17
17
|
): P;
|
|
18
18
|
export function surround<P extends Parser, S = string>(
|
|
19
19
|
opener: string | RegExp | Parser<S, Context<P>>, parser: P, closer: string | RegExp | Parser<S, Context<P>>,
|
|
20
20
|
optional?: false,
|
|
21
|
-
backtracks?: readonly
|
|
21
|
+
backtracks?: readonly number[],
|
|
22
22
|
f?: (rss: [List<Data<S>>, List<Data<Node<P>>>, List<Data<S>>], context: Context<P>) => Result<Node<P>, Context<P>, SubParsers<P>>,
|
|
23
23
|
g?: (rss: [List<Data<S>>, List<Data<Node<P>>> | undefined], context: Context<P>) => Result<Node<P>, Context<P>, SubParsers<P>>,
|
|
24
24
|
): P;
|
|
25
25
|
export function surround<P extends Parser, S = string>(
|
|
26
26
|
opener: string | RegExp | Parser<S, Context<P>>, parser: P, closer: string | RegExp | Parser<S, Context<P>>,
|
|
27
27
|
optional?: boolean,
|
|
28
|
-
backtracks?: readonly
|
|
28
|
+
backtracks?: readonly number[],
|
|
29
29
|
f?: (rss: [List<Data<S>>, List<Data<Node<P>>> | undefined, List<Data<S>>], context: Context<P>) => Result<Node<P>, Context<P>, SubParsers<P>>,
|
|
30
30
|
g?: (rss: [List<Data<S>>, List<Data<Node<P>>> | undefined], context: Context<P>) => Result<Node<P>, Context<P>, SubParsers<P>>,
|
|
31
31
|
): P;
|
|
32
32
|
export function surround<P extends Parser<string>, S = string>(
|
|
33
33
|
opener: string | RegExp | Parser<S, Context<P>>, parser: string | RegExp | P, closer: string | RegExp | Parser<S, Context<P>>,
|
|
34
34
|
optional?: false,
|
|
35
|
-
backtracks?: readonly
|
|
35
|
+
backtracks?: readonly number[],
|
|
36
36
|
f?: (rss: [List<Data<S>>, List<Data<Node<P>>>, List<Data<S>>], context: Context<P>) => Result<Node<P>, Context<P>, SubParsers<P>>,
|
|
37
37
|
g?: (rss: [List<Data<S>>, List<Data<Node<P>>> | undefined], context: Context<P>) => Result<Node<P>, Context<P>, SubParsers<P>>,
|
|
38
38
|
): P;
|
|
39
39
|
export function surround<P extends Parser<string>, S = string>(
|
|
40
40
|
opener: string | RegExp | Parser<S, Context<P>>, parser: string | RegExp | P, closer: string | RegExp | Parser<S, Context<P>>,
|
|
41
41
|
optional?: boolean,
|
|
42
|
-
backtracks?: readonly
|
|
42
|
+
backtracks?: readonly number[],
|
|
43
43
|
f?: (rss: [List<Data<S>>, List<Data<Node<P>>> | undefined, List<Data<S>>], context: Context<P>) => Result<Node<P>, Context<P>, SubParsers<P>>,
|
|
44
44
|
g?: (rss: [List<Data<S>>, List<Data<Node<P>>> | undefined], context: Context<P>) => Result<Node<P>, Context<P>, SubParsers<P>>,
|
|
45
45
|
): P;
|
|
46
46
|
export function surround<N>(
|
|
47
47
|
opener: string | RegExp | Parser<N>, parser: string | RegExp | Parser<N>, closer: string | RegExp | Parser<N>,
|
|
48
48
|
optional: boolean = false,
|
|
49
|
-
backtracks: readonly
|
|
49
|
+
backtracks: readonly number[] = [],
|
|
50
50
|
f?: (rss: [List<Data<N>>, List<Data<N>>, List<Data<N>>], context: Ctx) => Result<N>,
|
|
51
51
|
g?: (rss: [List<Data<N>>, List<Data<N>> | undefined], context: Ctx) => Result<N>,
|
|
52
52
|
): Parser<N> {
|
|
@@ -68,7 +68,7 @@ export function surround<N>(
|
|
|
68
68
|
closer = clear(matcher(closer, true));
|
|
69
69
|
}
|
|
70
70
|
assert(closer);
|
|
71
|
-
const [rbs, wbs] = reduce(backtracks);
|
|
71
|
+
const [blen, rbs, wbs] = reduce(backtracks);
|
|
72
72
|
return failsafe(input => {
|
|
73
73
|
const { context } = input;
|
|
74
74
|
const { source, position } = context;
|
|
@@ -79,7 +79,7 @@ export function surround<N>(
|
|
|
79
79
|
if (!nodesO) {
|
|
80
80
|
return void revert(context, linebreak);
|
|
81
81
|
}
|
|
82
|
-
if (rbs && isBacktrack(context, rbs, position,
|
|
82
|
+
if (rbs && isBacktrack(context, rbs, position, blen)) {
|
|
83
83
|
return void revert(context, linebreak);
|
|
84
84
|
}
|
|
85
85
|
const nodesM = context.position < source.length ? parser(input) : undefined;
|
|
@@ -113,19 +113,19 @@ export function open<P extends Parser>(
|
|
|
113
113
|
opener: string | RegExp | Parser<Node<P>, Context<P>>,
|
|
114
114
|
parser: P,
|
|
115
115
|
optional?: boolean,
|
|
116
|
-
backtracks?: readonly
|
|
116
|
+
backtracks?: readonly number[],
|
|
117
117
|
): P;
|
|
118
118
|
export function open<P extends Parser<string>>(
|
|
119
119
|
opener: string | RegExp | Parser<Node<P>, Context<P>>,
|
|
120
120
|
parser: string | RegExp | P,
|
|
121
121
|
optional?: boolean,
|
|
122
|
-
backtracks?: readonly
|
|
122
|
+
backtracks?: readonly number[],
|
|
123
123
|
): P;
|
|
124
124
|
export function open<N>(
|
|
125
125
|
opener: string | RegExp | Parser<N, Ctx>,
|
|
126
126
|
parser: string | RegExp | Parser<N>,
|
|
127
127
|
optional?: boolean,
|
|
128
|
-
backtracks
|
|
128
|
+
backtracks: readonly number[] = [],
|
|
129
129
|
): Parser<N> {
|
|
130
130
|
return surround(opener, parser as Parser<N>, '', optional, backtracks);
|
|
131
131
|
}
|
|
@@ -133,19 +133,19 @@ export function close<P extends Parser>(
|
|
|
133
133
|
parser: P,
|
|
134
134
|
closer: string | RegExp | Parser<Node<P>, Context<P>>,
|
|
135
135
|
optional?: boolean,
|
|
136
|
-
backtracks?: readonly
|
|
136
|
+
backtracks?: readonly number[],
|
|
137
137
|
): P;
|
|
138
138
|
export function close<P extends Parser<string>>(
|
|
139
139
|
parser: string | RegExp | P,
|
|
140
140
|
closer: string | RegExp | Parser<Node<P>, Context<P>>,
|
|
141
141
|
optional?: boolean,
|
|
142
|
-
backtracks?: readonly
|
|
142
|
+
backtracks?: readonly number[],
|
|
143
143
|
): P;
|
|
144
144
|
export function close<N>(
|
|
145
145
|
parser: string | RegExp | Parser<N>,
|
|
146
146
|
closer: string | RegExp | Parser<N, Ctx>,
|
|
147
147
|
optional?: boolean,
|
|
148
|
-
backtracks
|
|
148
|
+
backtracks: readonly number[] = [],
|
|
149
149
|
): Parser<N> {
|
|
150
150
|
return surround('', parser as Parser<N>, closer, optional, backtracks);
|
|
151
151
|
}
|
|
@@ -157,16 +157,12 @@ export function isBacktrack(
|
|
|
157
157
|
position: number = context.position,
|
|
158
158
|
length: number = 1,
|
|
159
159
|
): boolean {
|
|
160
|
-
assert(
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if (position === source.length) return false;
|
|
160
|
+
assert(1 & backtrack);
|
|
161
|
+
assert(backtrack >>> commandsize);
|
|
162
|
+
assert(0 < length && length < 3);
|
|
164
163
|
const { backtracks = {}, offset = 0 } = context;
|
|
165
164
|
for (let i = 0; i < length; ++i) {
|
|
166
|
-
if (position + i
|
|
167
|
-
if (i > 0 && source[position + i] !== source[position]) break;
|
|
168
|
-
const pos = position + i + offset;
|
|
169
|
-
if (backtracks[pos] & backtrack >>> commandsize) return true;
|
|
165
|
+
if (backtracks[position + i + offset] & backtrack >>> commandsize) return true;
|
|
170
166
|
}
|
|
171
167
|
return false;
|
|
172
168
|
}
|
|
@@ -177,29 +173,33 @@ export function setBacktrack(
|
|
|
177
173
|
length: number = 1,
|
|
178
174
|
): void {
|
|
179
175
|
// バックトラックの可能性がなく記録不要の場合もあるが判別が面倒なので省略
|
|
180
|
-
assert(
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
if (position === source.length) return;
|
|
176
|
+
assert(2 & backtrack);
|
|
177
|
+
assert(backtrack >>> commandsize);
|
|
178
|
+
assert(0 < length && length < 3);
|
|
184
179
|
const { backtracks = {}, offset = 0 } = context;
|
|
185
180
|
for (let i = 0; i < length; ++i) {
|
|
186
|
-
|
|
187
|
-
const pos = position + i + offset;
|
|
188
|
-
backtracks[pos] |= backtrack >>> commandsize;
|
|
181
|
+
backtracks[position + i + offset] |= backtrack >>> commandsize;
|
|
189
182
|
}
|
|
190
183
|
}
|
|
191
|
-
function reduce(backtracks: readonly number[]): readonly [number, number] {
|
|
184
|
+
function reduce(backtracks: readonly number[]): readonly [number, number, number] {
|
|
185
|
+
let len = 1;
|
|
192
186
|
let rbs = 0;
|
|
193
187
|
let wbs = 0;
|
|
194
188
|
for (const backtrack of backtracks) {
|
|
195
|
-
if (backtrack
|
|
189
|
+
if (backtrack >>> commandsize === 0) {
|
|
190
|
+
len = backtrack;
|
|
191
|
+
assert(len > 0);
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
assert(backtrack >>> commandsize);
|
|
195
|
+
if (1 & backtrack) {
|
|
196
196
|
rbs |= backtrack;
|
|
197
197
|
}
|
|
198
|
-
if (
|
|
198
|
+
if (2 & backtrack) {
|
|
199
199
|
wbs |= backtrack;
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
|
-
return [rbs, wbs];
|
|
202
|
+
return [len, rbs, wbs];
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
function revert(context: Ctx, linebreak: number | undefined): void {
|
|
@@ -13,7 +13,7 @@ export const annotation: AnnotationParser = lazy(() => constraint(State.annotati
|
|
|
13
13
|
trimBlankStart(some(union([inline]), ')', [[')', 1]])))),
|
|
14
14
|
'))',
|
|
15
15
|
false,
|
|
16
|
-
[1 | Backtrack.common, 3 | Backtrack.doublebracket],
|
|
16
|
+
[2, 1 | Backtrack.common, 3 | Backtrack.doublebracket],
|
|
17
17
|
([, ns], context) =>
|
|
18
18
|
context.linebreak === 0
|
|
19
19
|
? new List([new Data(html('sup', { class: 'annotation' }, [html('span', defrag(unwrap(trimBlankNodeEnd(ns))))]))])
|
|
@@ -18,7 +18,7 @@ export const reference: ReferenceParser = lazy(() => constraint(State.reference,
|
|
|
18
18
|
]))),
|
|
19
19
|
']]',
|
|
20
20
|
false,
|
|
21
|
-
[1 | Backtrack.common, 3 | Backtrack.doublebracket],
|
|
21
|
+
[2, 1 | Backtrack.common, 3 | Backtrack.doublebracket],
|
|
22
22
|
([, ns], context) => {
|
|
23
23
|
const { position, range = 0, linebreak = 0 } = context;
|
|
24
24
|
if (linebreak === 0) {
|