securemark 0.258.4 → 0.258.5
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.258.
|
|
1
|
+
/*! securemark v0.258.5 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
|
|
2
2
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
3
3
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
4
4
|
module.exports = factory(require("DOMPurify"), require("Prism"));
|
|
@@ -2856,42 +2856,28 @@ function apply(parser, source, context, changes, values) {
|
|
|
2856
2856
|
}
|
|
2857
2857
|
|
|
2858
2858
|
function syntax(syntax, precedence, cost, parser) {
|
|
2859
|
-
return (source, context) => {
|
|
2859
|
+
return creation(cost, (source, context) => {
|
|
2860
2860
|
if (source === '') return;
|
|
2861
2861
|
const memo = context.memo ??= new memo_1.Memo();
|
|
2862
2862
|
context.memorable ??= ~0;
|
|
2863
2863
|
const p = context.precedence;
|
|
2864
2864
|
context.precedence = precedence;
|
|
2865
|
-
const {
|
|
2866
|
-
resources = {
|
|
2867
|
-
clock: 1,
|
|
2868
|
-
recursion: 1
|
|
2869
|
-
}
|
|
2870
|
-
} = context;
|
|
2871
|
-
if (resources.clock <= 0) throw new Error('Too many creations');
|
|
2872
|
-
if (resources.recursion <= 0) throw new Error('Too much recursion');
|
|
2873
|
-
--resources.recursion;
|
|
2874
2865
|
const position = source.length;
|
|
2875
2866
|
const state = context.state ?? 0;
|
|
2876
2867
|
const cache = syntax && memo.get(position, syntax, state);
|
|
2877
2868
|
const result = cache ? cache.length === 0 ? global_1.undefined : [cache[0], source.slice(cache[1])] : parser(source, context);
|
|
2878
|
-
++resources.recursion;
|
|
2879
2869
|
|
|
2880
|
-
if (
|
|
2881
|
-
|
|
2870
|
+
if (syntax && state & context.memorable) {
|
|
2871
|
+
cache ?? memo.set(position, syntax, state, (0, parser_1.eval)(result), source.length - (0, parser_1.exec)(result, '').length);
|
|
2882
2872
|
}
|
|
2883
2873
|
|
|
2884
|
-
if (
|
|
2885
|
-
|
|
2886
|
-
cache ?? memo.set(position, syntax, state, (0, parser_1.eval)(result), source.length - (0, parser_1.exec)(result, '').length);
|
|
2887
|
-
} else if (result && memo.length >= position) {
|
|
2888
|
-
memo.clear(position);
|
|
2889
|
-
}
|
|
2874
|
+
if (result && !state && memo.length >= position) {
|
|
2875
|
+
memo.clear(position);
|
|
2890
2876
|
}
|
|
2891
2877
|
|
|
2892
2878
|
context.precedence = p;
|
|
2893
2879
|
return result;
|
|
2894
|
-
};
|
|
2880
|
+
});
|
|
2895
2881
|
}
|
|
2896
2882
|
|
|
2897
2883
|
exports.syntax = syntax;
|
|
@@ -3108,7 +3094,7 @@ class Memo {
|
|
|
3108
3094
|
|
|
3109
3095
|
for (let i = position + this.offset, len = memory.length; i < len; ++i) {
|
|
3110
3096
|
memory.pop();
|
|
3111
|
-
} //console.log('clear', position);
|
|
3097
|
+
} //console.log('clear', position + 1);
|
|
3112
3098
|
|
|
3113
3099
|
}
|
|
3114
3100
|
|
|
@@ -8014,7 +8000,9 @@ exports.delimiter = /[\s\x00-\x7F]|\S[#>]|[()、。!?][^\S\n]*(?=\\\n)/;
|
|
|
8014
8000
|
exports.nonWhitespace = /[\S\n]|$/;
|
|
8015
8001
|
exports.nonAlphanumeric = /[^0-9A-Za-z]|\S[#>]|$/;
|
|
8016
8002
|
const repeat = (0, str_1.str)(/^(.)\1*/);
|
|
8017
|
-
exports.text = (0, combinator_1.
|
|
8003
|
+
exports.text = (0, combinator_1.syntax)(0
|
|
8004
|
+
/* Syntax.none */
|
|
8005
|
+
, 1, 1, (source, context) => {
|
|
8018
8006
|
if (source === '') return;
|
|
8019
8007
|
const i = source.search(exports.delimiter);
|
|
8020
8008
|
|
package/package.json
CHANGED
|
@@ -58,16 +58,12 @@ function apply<T>(parser: Parser<T>, source: string, context: Ctx, changes: [str
|
|
|
58
58
|
|
|
59
59
|
export function syntax<P extends Parser<unknown>>(syntax: number, precedence: number, cost: number, parser: P): P;
|
|
60
60
|
export function syntax<T>(syntax: number, precedence: number, cost: number, parser?: Parser<T>): Parser<T> {
|
|
61
|
-
return (source, context) => {
|
|
61
|
+
return creation(cost, (source, context) => {
|
|
62
62
|
if (source === '') return;
|
|
63
63
|
const memo = context.memo ??= new Memo();
|
|
64
64
|
context.memorable ??= ~0;
|
|
65
65
|
const p = context.precedence;
|
|
66
66
|
context.precedence = precedence;
|
|
67
|
-
const { resources = { clock: 1, recursion: 1 } } = context;
|
|
68
|
-
if (resources.clock <= 0) throw new Error('Too many creations');
|
|
69
|
-
if (resources.recursion <= 0) throw new Error('Too much recursion');
|
|
70
|
-
--resources.recursion;
|
|
71
67
|
const position = source.length;
|
|
72
68
|
const state = context.state ?? 0;
|
|
73
69
|
const cache = syntax && memo.get(position, syntax, state);
|
|
@@ -76,23 +72,17 @@ export function syntax<T>(syntax: number, precedence: number, cost: number, pars
|
|
|
76
72
|
? undefined
|
|
77
73
|
: [cache[0], source.slice(cache[1])]
|
|
78
74
|
: parser!(source, context);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
75
|
+
if (syntax && state & context.memorable!) {
|
|
76
|
+
cache ?? memo.set(position, syntax, state, eval(result), source.length - exec(result, '').length);
|
|
77
|
+
assert.deepStrictEqual(cache && cache, cache && memo.get(position, syntax, state));
|
|
82
78
|
}
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
assert.deepStrictEqual(cache && cache, cache && memo.get(position, syntax, state));
|
|
87
|
-
}
|
|
88
|
-
else if (result && memo.length! >= position) {
|
|
89
|
-
assert(!(state & context.memorable!));
|
|
90
|
-
memo.clear(position);
|
|
91
|
-
}
|
|
79
|
+
if (result && !state && memo.length! >= position) {
|
|
80
|
+
assert(!(state & context.memorable!));
|
|
81
|
+
memo.clear(position);
|
|
92
82
|
}
|
|
93
83
|
context.precedence = p;
|
|
94
84
|
return result;
|
|
95
|
-
};
|
|
85
|
+
});
|
|
96
86
|
}
|
|
97
87
|
|
|
98
88
|
export function creation<P extends Parser<unknown>>(parser: P): P;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { undefined } from 'spica/global';
|
|
2
2
|
import { TextParser, TxtParser, LinebreakParser } from '../source';
|
|
3
|
-
import { union,
|
|
3
|
+
import { union, syntax, focus } from '../../combinator';
|
|
4
4
|
import { str } from './str';
|
|
5
|
+
import { Syntax } from '../context';
|
|
5
6
|
import { html } from 'typed-dom/dom';
|
|
6
7
|
|
|
7
8
|
export const delimiter = /[\s\x00-\x7F]|\S[#>]|[()、。!?][^\S\n]*(?=\\\n)/;
|
|
@@ -9,7 +10,7 @@ export const nonWhitespace = /[\S\n]|$/;
|
|
|
9
10
|
export const nonAlphanumeric = /[^0-9A-Za-z]|\S[#>]|$/;
|
|
10
11
|
const repeat = str(/^(.)\1*/);
|
|
11
12
|
|
|
12
|
-
export const text: TextParser =
|
|
13
|
+
export const text: TextParser = syntax(Syntax.none, 1, 1, (source, context) => {
|
|
13
14
|
if (source === '') return;
|
|
14
15
|
const i = source.search(delimiter);
|
|
15
16
|
switch (i) {
|