securemark 0.255.0 → 0.255.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.255.
|
|
1
|
+
/*! securemark v0.255.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("DOMPurify"), require("Prism"));
|
|
@@ -2127,14 +2127,12 @@ function guard(f, parser) {
|
|
|
2127
2127
|
exports.guard = guard;
|
|
2128
2128
|
|
|
2129
2129
|
function reset(base, parser) {
|
|
2130
|
-
if (isEmpty(base)) return parser;
|
|
2131
2130
|
return (source, context) => parser(source, inherit((0, alias_1.ObjectCreate)(context), base));
|
|
2132
2131
|
}
|
|
2133
2132
|
|
|
2134
2133
|
exports.reset = reset;
|
|
2135
2134
|
|
|
2136
2135
|
function context(base, parser) {
|
|
2137
|
-
if (isEmpty(base)) return parser;
|
|
2138
2136
|
const override = (0, memoize_1.memoize)(context => inherit((0, alias_1.ObjectCreate)(context), base), new global_1.WeakMap());
|
|
2139
2137
|
return (source, context) => parser(source, override(context));
|
|
2140
2138
|
}
|
|
@@ -2166,12 +2164,6 @@ const inherit = (0, assign_1.template)((prop, target, source) => {
|
|
|
2166
2164
|
}
|
|
2167
2165
|
});
|
|
2168
2166
|
|
|
2169
|
-
function isEmpty(context) {
|
|
2170
|
-
for (const _ in context) return false;
|
|
2171
|
-
|
|
2172
|
-
return true;
|
|
2173
|
-
}
|
|
2174
|
-
|
|
2175
2167
|
/***/ }),
|
|
2176
2168
|
|
|
2177
2169
|
/***/ 7957:
|
|
@@ -3550,12 +3542,13 @@ function parse(source, opts = {}, context) {
|
|
|
3550
3542
|
const url = (0, header_2.headers)(source).find(field => field.toLowerCase().startsWith('url:'))?.slice(4).trim() ?? '';
|
|
3551
3543
|
source = !context ? (0, normalize_1.normalize)(source) : source;
|
|
3552
3544
|
context = {
|
|
3553
|
-
url: url ? new url_1.ReadonlyURL(url) : context?.url,
|
|
3554
3545
|
host: opts.host ?? context?.host ?? new url_1.ReadonlyURL(global_1.location.pathname, global_1.location.origin),
|
|
3546
|
+
url: url ? new url_1.ReadonlyURL(url) : context?.url,
|
|
3547
|
+
id: opts.id ?? context?.id,
|
|
3555
3548
|
caches: context?.caches,
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3549
|
+
...(context?.resources && {
|
|
3550
|
+
resources: context.resources
|
|
3551
|
+
})
|
|
3559
3552
|
};
|
|
3560
3553
|
if (context.host?.origin === 'null') throw new Error(`Invalid host: ${context.host.href}`);
|
|
3561
3554
|
const node = (0, dom_1.frag)();
|
|
@@ -3888,7 +3881,7 @@ const parse_1 = __webpack_require__(5013);
|
|
|
3888
3881
|
|
|
3889
3882
|
const dom_1 = __webpack_require__(3252);
|
|
3890
3883
|
|
|
3891
|
-
exports.aside = (0, combinator_1.
|
|
3884
|
+
exports.aside = (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0, combinator_1.fmap)((0, combinator_1.fence)(/^(~{3,})aside(?!\S)([^\n]*)(?:$|\n)/, 300), // Bug: Type mismatch between outer and inner.
|
|
3892
3885
|
([body, overflow, closer, opener, delim, param], _, context) => {
|
|
3893
3886
|
if (!closer || overflow || param.trimStart()) return [(0, dom_1.html)('pre', {
|
|
3894
3887
|
class: 'invalid',
|
|
@@ -3920,7 +3913,7 @@ exports.aside = (0, combinator_1.creator)(100, (0, combinator_1.block)((0, combi
|
|
|
3920
3913
|
id: (0, indexee_1.identity)((0, indexee_1.text)(heading)),
|
|
3921
3914
|
class: 'aside'
|
|
3922
3915
|
}, [document, references])];
|
|
3923
|
-
})))
|
|
3916
|
+
})));
|
|
3924
3917
|
|
|
3925
3918
|
/***/ }),
|
|
3926
3919
|
|
|
@@ -3946,7 +3939,7 @@ const mathblock_1 = __webpack_require__(3754);
|
|
|
3946
3939
|
const dom_1 = __webpack_require__(3252);
|
|
3947
3940
|
|
|
3948
3941
|
const opener = /^(~{3,})(?:example\/(\S+))?(?!\S)([^\n]*)(?:$|\n)/;
|
|
3949
|
-
exports.example = (0, combinator_1.
|
|
3942
|
+
exports.example = (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0, combinator_1.fmap)((0, combinator_1.fence)(opener, 300), // Bug: Type mismatch between outer and inner.
|
|
3950
3943
|
([body, overflow, closer, opener, delim, type = 'markdown', param], _, context) => {
|
|
3951
3944
|
if (!closer || overflow || param.trimStart()) return [(0, dom_1.html)('pre', {
|
|
3952
3945
|
class: 'invalid',
|
|
@@ -3993,7 +3986,7 @@ exports.example = (0, combinator_1.creator)(100, (0, combinator_1.block)((0, com
|
|
|
3993
3986
|
'data-invalid-message': 'Invalid example type'
|
|
3994
3987
|
}, `${opener}${body}${closer}`)];
|
|
3995
3988
|
}
|
|
3996
|
-
})))
|
|
3989
|
+
})));
|
|
3997
3990
|
|
|
3998
3991
|
/***/ }),
|
|
3999
3992
|
|
package/package.json
CHANGED
|
@@ -17,7 +17,6 @@ export function reset<P extends Parser<unknown>>(context: Context<P>, parser: P)
|
|
|
17
17
|
export function reset<T>(base: Ctx, parser: Parser<T>): Parser<T> {
|
|
18
18
|
assert(Object.getPrototypeOf(base) === Object.prototype);
|
|
19
19
|
assert(Object.freeze(base));
|
|
20
|
-
if (isEmpty(base)) return parser;
|
|
21
20
|
return (source, context) =>
|
|
22
21
|
parser(source, inherit(ObjectCreate(context), base));
|
|
23
22
|
}
|
|
@@ -26,7 +25,6 @@ export function context<P extends Parser<unknown>>(context: Context<P>, parser:
|
|
|
26
25
|
export function context<T>(base: Ctx, parser: Parser<T>): Parser<T> {
|
|
27
26
|
assert(Object.getPrototypeOf(base) === Object.prototype);
|
|
28
27
|
assert(Object.freeze(base));
|
|
29
|
-
if (isEmpty(base)) return parser;
|
|
30
28
|
const override = memoize<Ctx, Ctx>(context => inherit(ObjectCreate(context), base), new WeakMap());
|
|
31
29
|
return (source, context) =>
|
|
32
30
|
parser(source, override(context));
|
|
@@ -40,6 +38,7 @@ const inherit = template((prop, target, source) => {
|
|
|
40
38
|
switch (prop) {
|
|
41
39
|
case 'resources':
|
|
42
40
|
assert(typeof source[prop] === 'object');
|
|
41
|
+
assert(target[prop] || !(prop in target));
|
|
43
42
|
if (prop in target && !hasOwnProperty(target, prop)) return;
|
|
44
43
|
return target[prop] = ObjectCreate(source[prop]);
|
|
45
44
|
}
|
|
@@ -58,8 +57,3 @@ const inherit = template((prop, target, source) => {
|
|
|
58
57
|
return target[prop] = source[prop];
|
|
59
58
|
}
|
|
60
59
|
});
|
|
61
|
-
|
|
62
|
-
function isEmpty(context: Ctx): boolean {
|
|
63
|
-
for (const _ in context) return false;
|
|
64
|
-
return true;
|
|
65
|
-
}
|
package/src/parser/api/parse.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { location } from 'spica/global';
|
|
2
2
|
import { ParserOptions } from '../../..';
|
|
3
3
|
import { MarkdownParser } from '../../../markdown';
|
|
4
4
|
import { eval } from '../../combinator/data/parser';
|
|
@@ -22,12 +22,13 @@ export function parse(source: string, opts: Options = {}, context?: MarkdownPars
|
|
|
22
22
|
source = !context ? normalize(source) : source;
|
|
23
23
|
assert(!context?.delimiters);
|
|
24
24
|
context = {
|
|
25
|
-
url: url ? new ReadonlyURL(url as ':') : context?.url,
|
|
26
25
|
host: opts.host ?? context?.host ?? new ReadonlyURL(location.pathname, location.origin),
|
|
26
|
+
url: url ? new ReadonlyURL(url as ':') : context?.url,
|
|
27
|
+
id: opts.id ?? context?.id,
|
|
27
28
|
caches: context?.caches,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
...context?.resources && {
|
|
30
|
+
resources: context.resources,
|
|
31
|
+
},
|
|
31
32
|
};
|
|
32
33
|
if (context.host?.origin === 'null') throw new Error(`Invalid host: ${context.host.href}`);
|
|
33
34
|
const node = frag();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ExtensionParser } from '../../block';
|
|
2
|
-
import { block, validate, fence,
|
|
2
|
+
import { block, validate, fence, fmap } from '../../../combinator';
|
|
3
3
|
import { identity, text } from '../../inline/extension/indexee';
|
|
4
4
|
import { parse } from '../../api/parse';
|
|
5
5
|
import { html } from 'typed-dom/dom';
|
|
6
6
|
|
|
7
|
-
export const aside: ExtensionParser.AsideParser =
|
|
7
|
+
export const aside: ExtensionParser.AsideParser = block(validate('~~~', fmap(
|
|
8
8
|
fence(/^(~{3,})aside(?!\S)([^\n]*)(?:$|\n)/, 300),
|
|
9
9
|
// Bug: Type mismatch between outer and inner.
|
|
10
10
|
([body, overflow, closer, opener, delim, param]: string[], _, context) => {
|
|
@@ -43,4 +43,4 @@ export const aside: ExtensionParser.AsideParser = creator(100, block(validate('~
|
|
|
43
43
|
references,
|
|
44
44
|
]),
|
|
45
45
|
];
|
|
46
|
-
})))
|
|
46
|
+
})));
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ExtensionParser } from '../../block';
|
|
2
2
|
import { eval } from '../../../combinator/data/parser';
|
|
3
|
-
import { block, validate, fence,
|
|
3
|
+
import { block, validate, fence, fmap } from '../../../combinator';
|
|
4
4
|
import { parse } from '../../api/parse';
|
|
5
5
|
import { mathblock } from '../mathblock';
|
|
6
6
|
import { html } from 'typed-dom/dom';
|
|
7
7
|
|
|
8
8
|
const opener = /^(~{3,})(?:example\/(\S+))?(?!\S)([^\n]*)(?:$|\n)/;
|
|
9
9
|
|
|
10
|
-
export const example: ExtensionParser.ExampleParser =
|
|
10
|
+
export const example: ExtensionParser.ExampleParser = block(validate('~~~', fmap(
|
|
11
11
|
fence(opener, 300),
|
|
12
12
|
// Bug: Type mismatch between outer and inner.
|
|
13
13
|
([body, overflow, closer, opener, delim, type = 'markdown', param]: string[], _, context) => {
|
|
@@ -58,4 +58,4 @@ export const example: ExtensionParser.ExampleParser = creator(100, block(validat
|
|
|
58
58
|
}, `${opener}${body}${closer}`),
|
|
59
59
|
];
|
|
60
60
|
}
|
|
61
|
-
})))
|
|
61
|
+
})));
|