securemark 0.226.3 → 0.226.4
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/securemark.js +97 -54
- package/markdown.d.ts +12 -2
- package/package-lock.json +114 -114
- package/package.json +1 -1
- package/src/debug.test.ts +1 -0
- package/src/parser/api/normalize.ts +4 -3
- package/src/parser/inline/comment.test.ts +5 -7
- package/src/parser/inline/comment.ts +23 -16
- package/src/parser/inline/htmlentity.ts +19 -16
- package/src/parser/inline/link.ts +2 -2
- package/src/parser/inline/media.test.ts +3 -0
- package/src/parser/inline/media.ts +23 -12
- package/src/parser/inline/ruby.test.ts +4 -1
- package/src/parser/inline/ruby.ts +21 -4
- package/src/parser/util.test.ts +1 -0
- package/src/parser/util.ts +2 -2
package/CHANGELOG.md
CHANGED
package/dist/securemark.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.226.
|
|
1
|
+
/*! securemark v0.226.4 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED */
|
|
2
2
|
require = function () {
|
|
3
3
|
function r(e, n, t) {
|
|
4
4
|
function o(i, f) {
|
|
@@ -4715,8 +4715,9 @@ require = function () {
|
|
|
4715
4715
|
'use strict';
|
|
4716
4716
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4717
4717
|
exports.escape = exports.normalize = void 0;
|
|
4718
|
-
const htmlentity_1 = _dereq_('../inline/htmlentity');
|
|
4719
4718
|
const parser_1 = _dereq_('../../combinator/data/parser');
|
|
4719
|
+
const htmlentity_1 = _dereq_('../inline/htmlentity');
|
|
4720
|
+
const util_1 = _dereq_('../util');
|
|
4720
4721
|
const UNICODE_REPLACEMENT_CHARACTER = '\uFFFD';
|
|
4721
4722
|
function normalize(source) {
|
|
4722
4723
|
return sanitize(format(source));
|
|
@@ -4760,7 +4761,7 @@ require = function () {
|
|
|
4760
4761
|
'InvisibleComma',
|
|
4761
4762
|
'ic'
|
|
4762
4763
|
];
|
|
4763
|
-
const unreadableEscapableCharacters = unreadableHTMLEntityNames.
|
|
4764
|
+
const unreadableEscapableCharacters = unreadableHTMLEntityNames.map(name => (0, util_1.stringify)((0, parser_1.eval)((0, htmlentity_1.htmlentity)(`&${ name };`, {}))));
|
|
4764
4765
|
const unreadableEscapableCharacter = new RegExp(`[${ [...new Set(unreadableEscapableCharacters)].join('') }]`, 'g');
|
|
4765
4766
|
const unreadableSpecialCharacters = [
|
|
4766
4767
|
'\u2006',
|
|
@@ -4785,7 +4786,8 @@ require = function () {
|
|
|
4785
4786
|
},
|
|
4786
4787
|
{
|
|
4787
4788
|
'../../combinator/data/parser': 50,
|
|
4788
|
-
'../inline/htmlentity': 115
|
|
4789
|
+
'../inline/htmlentity': 115,
|
|
4790
|
+
'../util': 137
|
|
4789
4791
|
}
|
|
4790
4792
|
],
|
|
4791
4793
|
64: [
|
|
@@ -6916,35 +6918,51 @@ require = function () {
|
|
|
6916
6918
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
6917
6919
|
exports.comment = void 0;
|
|
6918
6920
|
const combinator_1 = _dereq_('../../combinator');
|
|
6921
|
+
const parser_1 = _dereq_('../../combinator/data/parser');
|
|
6922
|
+
const htmlentity_1 = _dereq_('./htmlentity');
|
|
6923
|
+
const source_1 = _dereq_('../source');
|
|
6919
6924
|
const typed_dom_1 = _dereq_('typed-dom');
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
-
if (title)
|
|
6925
|
+
exports.comment = (0, combinator_1.creator)((0, combinator_1.validate)('[#', (0, combinator_1.match)(/^\[(#+)\s+(?!\s|\1\])((?:\S+\s+)+?)(\1\]|(?=\[\1\s))/, ([whole, , body, closer]) => (rest, context) => {
|
|
6926
|
+
[whole, body] = `${ whole }\0${ body.trimEnd() }`.replace(/\x7F.?/gs, '').split('\0', 2);
|
|
6927
|
+
if (!closer)
|
|
6924
6928
|
return [
|
|
6925
6929
|
[(0, typed_dom_1.html)('sup', {
|
|
6926
|
-
class: 'comment',
|
|
6927
|
-
|
|
6928
|
-
|
|
6930
|
+
class: 'comment invalid',
|
|
6931
|
+
'data-invalid-syntax': 'comment',
|
|
6932
|
+
'data-invalid-type': 'content',
|
|
6933
|
+
'data-invalid-description': 'Comment syntax using the same level cannot start in another comment syntax.'
|
|
6934
|
+
}, whole)],
|
|
6929
6935
|
rest
|
|
6930
6936
|
];
|
|
6931
|
-
const
|
|
6932
|
-
if (
|
|
6937
|
+
const title = (0, parser_1.eval)((0, combinator_1.some)(text)(body, context), []).join('').trim();
|
|
6938
|
+
if (title.includes('\0'))
|
|
6933
6939
|
return [
|
|
6934
6940
|
[(0, typed_dom_1.html)('sup', {
|
|
6935
6941
|
class: 'comment invalid',
|
|
6936
6942
|
'data-invalid-syntax': 'comment',
|
|
6937
6943
|
'data-invalid-type': 'content',
|
|
6938
|
-
'data-invalid-description':
|
|
6939
|
-
},
|
|
6940
|
-
rest
|
|
6944
|
+
'data-invalid-description': `Invalid HTML entitiy "${ title.match(/\0&[0-9A-Za-z]+;/)[0].slice(1) }".`
|
|
6945
|
+
}, whole)],
|
|
6946
|
+
rest
|
|
6941
6947
|
];
|
|
6942
|
-
|
|
6948
|
+
return [
|
|
6949
|
+
[(0, typed_dom_1.html)('sup', {
|
|
6950
|
+
class: 'comment',
|
|
6951
|
+
title
|
|
6952
|
+
})],
|
|
6953
|
+
rest
|
|
6954
|
+
];
|
|
6943
6955
|
})));
|
|
6956
|
+
const text = (0, combinator_1.union)([
|
|
6957
|
+
htmlentity_1.unsafehtmlentity,
|
|
6958
|
+
source_1.unescsource
|
|
6959
|
+
]);
|
|
6944
6960
|
},
|
|
6945
6961
|
{
|
|
6946
6962
|
'../../combinator': 30,
|
|
6947
|
-
'
|
|
6963
|
+
'../../combinator/data/parser': 50,
|
|
6964
|
+
'../source': 131,
|
|
6965
|
+
'./htmlentity': 115,
|
|
6948
6966
|
'typed-dom': 29
|
|
6949
6967
|
}
|
|
6950
6968
|
],
|
|
@@ -7533,22 +7551,16 @@ require = function () {
|
|
|
7533
7551
|
const combinator_1 = _dereq_('../../combinator');
|
|
7534
7552
|
const typed_dom_1 = _dereq_('typed-dom');
|
|
7535
7553
|
const parser = (0, typed_dom_1.html)('textarea');
|
|
7536
|
-
exports.unsafehtmlentity = (0, combinator_1.creator)((0, combinator_1.validate)('&', (0, combinator_1.
|
|
7554
|
+
exports.unsafehtmlentity = (0, combinator_1.creator)((0, combinator_1.validate)('&', (0, combinator_1.fmap)((0, combinator_1.focus)(/^&[0-9A-Za-z]+;/, entity => [
|
|
7537
7555
|
[(parser.innerHTML = entity, parser.value)],
|
|
7538
7556
|
''
|
|
7539
|
-
]), ([str]) => str[0] !== '&' || str.length < 3)));
|
|
7540
|
-
exports.htmlentity = (0, combinator_1.creator)((0, combinator_1.validate)('&', (0, combinator_1.
|
|
7541
|
-
|
|
7542
|
-
|
|
7543
|
-
|
|
7544
|
-
|
|
7545
|
-
|
|
7546
|
-
'data-invalid-type': 'syntax',
|
|
7547
|
-
'data-invalid-description': 'Invalid HTML entity.'
|
|
7548
|
-
}, str)],
|
|
7549
|
-
''
|
|
7550
|
-
]
|
|
7551
|
-
]))));
|
|
7557
|
+
]), ([str]) => [str[0] !== '&' || str.length < 3 ? str : `\0${ str }`])));
|
|
7558
|
+
exports.htmlentity = (0, combinator_1.creator)((0, combinator_1.validate)('&', (0, combinator_1.fmap)((0, combinator_1.union)([exports.unsafehtmlentity]), ([str]) => [str[0] === '\0' ? (0, typed_dom_1.html)('span', {
|
|
7559
|
+
class: 'invalid',
|
|
7560
|
+
'data-invalid-syntax': 'htmlentity',
|
|
7561
|
+
'data-invalid-type': 'syntax',
|
|
7562
|
+
'data-invalid-description': 'Invalid HTML entity.'
|
|
7563
|
+
}, str.slice(1)) : str])));
|
|
7552
7564
|
},
|
|
7553
7565
|
{
|
|
7554
7566
|
'../../combinator': 30,
|
|
@@ -7629,11 +7641,11 @@ require = function () {
|
|
|
7629
7641
|
(0, combinator_1.some)(exports.option)
|
|
7630
7642
|
]), /^[^\S\n]?}/))
|
|
7631
7643
|
])))), ([params, content = []], rest, context) => {
|
|
7632
|
-
var _a, _b, _c, _d, _e;
|
|
7633
|
-
if ((0, parser_1.eval)((0, combinator_1.some)(autolink_1.autolink)((0, util_1.stringify)(content), context)
|
|
7644
|
+
var _a, _b, _c, _d, _e, _f;
|
|
7645
|
+
if ((_a = (0, parser_1.eval)((0, combinator_1.some)(autolink_1.autolink)((0, util_1.stringify)(content), context))) === null || _a === void 0 ? void 0 : _a.some(node => typeof node === 'object'))
|
|
7634
7646
|
return;
|
|
7635
7647
|
const INSECURE_URI = params.shift();
|
|
7636
|
-
const el = create(INSECURE_URI, (0, util_1.trimNode)((0, typed_dom_1.defrag)(content)), new url_1.ReadonlyURL(resolve(INSECURE_URI, (
|
|
7648
|
+
const el = create(INSECURE_URI, (0, util_1.trimNode)((0, typed_dom_1.defrag)(content)), new url_1.ReadonlyURL(resolve(INSECURE_URI, (_b = context.host) !== null && _b !== void 0 ? _b : global_1.location, (_d = (_c = context.url) !== null && _c !== void 0 ? _c : context.host) !== null && _d !== void 0 ? _d : global_1.location), ((_e = context.host) === null || _e === void 0 ? void 0 : _e.href) || global_1.location.href), ((_f = context.host) === null || _f === void 0 ? void 0 : _f.origin) || global_1.location.origin);
|
|
7637
7649
|
if (el.classList.contains('invalid'))
|
|
7638
7650
|
return [
|
|
7639
7651
|
[el],
|
|
@@ -7704,7 +7716,7 @@ require = function () {
|
|
|
7704
7716
|
}, content.length === 0 ? INSECURE_URI : content);
|
|
7705
7717
|
}
|
|
7706
7718
|
function decode(uri) {
|
|
7707
|
-
if (uri.
|
|
7719
|
+
if (!uri.includes('%'))
|
|
7708
7720
|
return uri;
|
|
7709
7721
|
try {
|
|
7710
7722
|
uri = (0, global_1.decodeURI)(uri);
|
|
@@ -7856,12 +7868,12 @@ require = function () {
|
|
|
7856
7868
|
'data-src': url.source,
|
|
7857
7869
|
alt: text
|
|
7858
7870
|
});
|
|
7859
|
-
|
|
7871
|
+
(cache === null || cache === void 0 ? void 0 : cache.hasAttribute('alt')) && (cache === null || cache === void 0 ? void 0 : cache.setAttribute('alt', text));
|
|
7872
|
+
if (!sanitize(el, url, text))
|
|
7860
7873
|
return [
|
|
7861
7874
|
[el],
|
|
7862
7875
|
rest
|
|
7863
7876
|
];
|
|
7864
|
-
(cache === null || cache === void 0 ? void 0 : cache.hasAttribute('alt')) && (cache === null || cache === void 0 ? void 0 : cache.setAttribute('alt', text));
|
|
7865
7877
|
(0, typed_dom_1.define)(el, (0, html_1.attributes)('media', (0, array_1.push)([], el.classList), optspec, params));
|
|
7866
7878
|
if (((_j = (_h = context.syntax) === null || _h === void 0 ? void 0 : _h.inline) === null || _j === void 0 ? void 0 : _j.link) === false || cache && cache.tagName !== 'IMG')
|
|
7867
7879
|
return [
|
|
@@ -7908,7 +7920,21 @@ require = function () {
|
|
|
7908
7920
|
(0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+[1-9][0-9]*:[1-9][0-9]*(?=[^\S\n]|})/), ([opt]) => [` aspect-ratio="${ opt.slice(1).split(':').join('/') }"`]),
|
|
7909
7921
|
link_1.option
|
|
7910
7922
|
]);
|
|
7911
|
-
function sanitize(uri,
|
|
7923
|
+
function sanitize(target, uri, alt) {
|
|
7924
|
+
var _a;
|
|
7925
|
+
switch (uri.protocol) {
|
|
7926
|
+
case 'http:':
|
|
7927
|
+
case 'https:':
|
|
7928
|
+
break;
|
|
7929
|
+
default:
|
|
7930
|
+
(0, typed_dom_1.define)(target, {
|
|
7931
|
+
class: void target.classList.add('invalid'),
|
|
7932
|
+
'data-invalid-syntax': 'media',
|
|
7933
|
+
'data-invalid-type': 'argument',
|
|
7934
|
+
'data-invalid-description': 'Invalid protocol.'
|
|
7935
|
+
});
|
|
7936
|
+
return false;
|
|
7937
|
+
}
|
|
7912
7938
|
if (/\/\.\.?(?:\/|$)/.test('/' + uri.source.slice(0, uri.source.search(/[?#]|$/)))) {
|
|
7913
7939
|
(0, typed_dom_1.define)(target, {
|
|
7914
7940
|
class: void target.classList.add('invalid'),
|
|
@@ -7918,16 +7944,13 @@ require = function () {
|
|
|
7918
7944
|
});
|
|
7919
7945
|
return false;
|
|
7920
7946
|
}
|
|
7921
|
-
|
|
7922
|
-
case 'http:':
|
|
7923
|
-
case 'https:':
|
|
7924
|
-
break;
|
|
7925
|
-
default:
|
|
7947
|
+
if (alt.includes('\0')) {
|
|
7926
7948
|
(0, typed_dom_1.define)(target, {
|
|
7927
7949
|
class: void target.classList.add('invalid'),
|
|
7928
7950
|
'data-invalid-syntax': 'media',
|
|
7929
|
-
'data-invalid-type': '
|
|
7930
|
-
'data-invalid-description':
|
|
7951
|
+
'data-invalid-type': 'content',
|
|
7952
|
+
'data-invalid-description': `Cannot use invalid HTML entitiy "${ alt.match(/&[0-9A-Za-z]+;/)[0] }".`,
|
|
7953
|
+
alt: (_a = target.getAttribute('alt')) === null || _a === void 0 ? void 0 : _a.replace(/\0/g, '')
|
|
7931
7954
|
});
|
|
7932
7955
|
return false;
|
|
7933
7956
|
}
|
|
@@ -8025,7 +8048,7 @@ require = function () {
|
|
|
8025
8048
|
switch (true) {
|
|
8026
8049
|
case rubies.length <= texts.length:
|
|
8027
8050
|
return [
|
|
8028
|
-
[(0, typed_dom_1.html)('ruby', (0, typed_dom_1.defrag)((0, array_1.push)(texts.reduce((acc, _, i) => (0, array_1.push)(acc, (0, array_1.unshift)([texts[i]], i < rubies.length && rubies[i] ? [
|
|
8051
|
+
[(0, typed_dom_1.html)('ruby', attributes(texts, rubies), (0, typed_dom_1.defrag)((0, array_1.push)(texts.reduce((acc, _, i) => (0, array_1.push)(acc, (0, array_1.unshift)([texts[i]], i < rubies.length && rubies[i] ? [
|
|
8029
8052
|
(0, typed_dom_1.html)('rp', '('),
|
|
8030
8053
|
(0, typed_dom_1.html)('rt', rubies[i]),
|
|
8031
8054
|
(0, typed_dom_1.html)('rp', ')')
|
|
@@ -8034,7 +8057,7 @@ require = function () {
|
|
|
8034
8057
|
];
|
|
8035
8058
|
case texts.length === 1 && [...texts[0]].length >= rubies.length:
|
|
8036
8059
|
return [
|
|
8037
|
-
[(0, typed_dom_1.html)('ruby', (0, typed_dom_1.defrag)((0, array_1.push)([...texts[0]].reduce((acc, _, i, texts) => (0, array_1.push)(acc, (0, array_1.unshift)([texts[i]], i < rubies.length && rubies[i] ? [
|
|
8060
|
+
[(0, typed_dom_1.html)('ruby', attributes(texts, rubies), (0, typed_dom_1.defrag)((0, array_1.push)([...texts[0]].reduce((acc, _, i, texts) => (0, array_1.push)(acc, (0, array_1.unshift)([texts[i]], i < rubies.length && rubies[i] ? [
|
|
8038
8061
|
(0, typed_dom_1.html)('rp', '('),
|
|
8039
8062
|
(0, typed_dom_1.html)('rt', rubies[i]),
|
|
8040
8063
|
(0, typed_dom_1.html)('rp', ')')
|
|
@@ -8043,7 +8066,7 @@ require = function () {
|
|
|
8043
8066
|
];
|
|
8044
8067
|
default:
|
|
8045
8068
|
return [
|
|
8046
|
-
[(0, typed_dom_1.html)('ruby', (0, typed_dom_1.defrag)((0, array_1.push)((0, array_1.unshift)([(0, array_1.join)(texts, ' ')], [
|
|
8069
|
+
[(0, typed_dom_1.html)('ruby', attributes(texts, rubies), (0, typed_dom_1.defrag)((0, array_1.push)((0, array_1.unshift)([(0, array_1.join)(texts, ' ')], [
|
|
8047
8070
|
(0, typed_dom_1.html)('rp', '('),
|
|
8048
8071
|
(0, typed_dom_1.html)('rt', (0, array_1.join)(rubies, ' ').trim()),
|
|
8049
8072
|
(0, typed_dom_1.html)('rp', ')')
|
|
@@ -8060,7 +8083,7 @@ require = function () {
|
|
|
8060
8083
|
case '&': {
|
|
8061
8084
|
const result = (0, htmlentity_1.unsafehtmlentity)(source, context);
|
|
8062
8085
|
if (result) {
|
|
8063
|
-
acc[acc.length - 1] += (0, parser_1.eval)(result
|
|
8086
|
+
acc[acc.length - 1] += (0, parser_1.eval)(result)[0];
|
|
8064
8087
|
source = (0, parser_1.exec)(result, source.slice(1));
|
|
8065
8088
|
continue;
|
|
8066
8089
|
}
|
|
@@ -8083,6 +8106,26 @@ require = function () {
|
|
|
8083
8106
|
''
|
|
8084
8107
|
] : global_1.undefined;
|
|
8085
8108
|
});
|
|
8109
|
+
function attributes(texts, rubies) {
|
|
8110
|
+
let attrs;
|
|
8111
|
+
for (const ss of [
|
|
8112
|
+
texts,
|
|
8113
|
+
rubies
|
|
8114
|
+
]) {
|
|
8115
|
+
for (let i = 0; i < ss.length; ++i) {
|
|
8116
|
+
if (!ss[i].includes('\0'))
|
|
8117
|
+
continue;
|
|
8118
|
+
ss[i] = ss[i].replace(/\0/g, '');
|
|
8119
|
+
attrs !== null && attrs !== void 0 ? attrs : attrs = {
|
|
8120
|
+
class: 'invalid',
|
|
8121
|
+
'data-invalid-syntax': 'ruby',
|
|
8122
|
+
'data-invalid-type': ss === texts ? 'content' : 'argument',
|
|
8123
|
+
'data-invalid-description': 'Invalid HTML entity.'
|
|
8124
|
+
};
|
|
8125
|
+
}
|
|
8126
|
+
}
|
|
8127
|
+
return attrs !== null && attrs !== void 0 ? attrs : {};
|
|
8128
|
+
}
|
|
8086
8129
|
},
|
|
8087
8130
|
{
|
|
8088
8131
|
'../../combinator': 30,
|
|
@@ -8962,7 +9005,7 @@ require = function () {
|
|
|
8962
9005
|
'InvisibleComma',
|
|
8963
9006
|
'ic'
|
|
8964
9007
|
];
|
|
8965
|
-
const blankline = new RegExp(String.raw`^(?!$|\n)(?:\\?\s|&(?:${ invisibleHTMLEntityNames.join('|') });|<wbr>|\[(#+)\s+(?!\s|\1\])
|
|
9008
|
+
const blankline = new RegExp(String.raw`^(?!$|\n)(?:\\?\s|&(?:${ invisibleHTMLEntityNames.join('|') });|<wbr>|\[(#+)\s+(?!\s|\1\])(?:\S+\s+)+?(?:\1\]|(?=\[\1\s)))*\\?(?:$|\n)`, 'gm');
|
|
8966
9009
|
function visualize(parser) {
|
|
8967
9010
|
return (0, combinator_1.convert)(source => source.replace(blankline, line => line.replace(/[\\&<\[]/g, '\x7F\\$&')), (0, combinator_1.union)([
|
|
8968
9011
|
(0, combinator_1.verify)(parser, (ns, rest, context) => !rest && hasVisible(ns, context)),
|
|
@@ -9012,7 +9055,7 @@ require = function () {
|
|
|
9012
9055
|
}
|
|
9013
9056
|
exports.startTight = startTight;
|
|
9014
9057
|
function isStartTight(source, context) {
|
|
9015
|
-
var _a, _b, _c, _d;
|
|
9058
|
+
var _a, _b, _c, _d, _e;
|
|
9016
9059
|
if (source === '')
|
|
9017
9060
|
return true;
|
|
9018
9061
|
switch (source[0]) {
|
|
@@ -9025,7 +9068,7 @@ require = function () {
|
|
|
9025
9068
|
return ((_a = source[1]) === null || _a === void 0 ? void 0 : _a.trimStart()) !== '';
|
|
9026
9069
|
case '&':
|
|
9027
9070
|
switch (true) {
|
|
9028
|
-
case source.length > 2 && source[1] !== ' ' && ((_b = (0, parser_1.eval)((0, htmlentity_1.unsafehtmlentity)(source, context))) === null || _b === void 0 ? void 0 : _b[0].trimStart()) === '':
|
|
9071
|
+
case source.length > 2 && source[1] !== ' ' && ((_c = (_b = (0, parser_1.eval)((0, htmlentity_1.unsafehtmlentity)(source, context))) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.trimStart()) === '':
|
|
9029
9072
|
return false;
|
|
9030
9073
|
}
|
|
9031
9074
|
return true;
|
|
@@ -9037,7 +9080,7 @@ require = function () {
|
|
|
9037
9080
|
return true;
|
|
9038
9081
|
case '[':
|
|
9039
9082
|
switch (true) {
|
|
9040
|
-
case source.length >= 7 && source[1] === '#' && ((
|
|
9083
|
+
case source.length >= 7 && source[1] === '#' && ((_d = (0, parser_1.eval)((0, comment_1.comment)(source, context))) === null || _d === void 0 ? void 0 : _d[0].className) === 'comment':
|
|
9041
9084
|
return false;
|
|
9042
9085
|
}
|
|
9043
9086
|
return true;
|
package/markdown.d.ts
CHANGED
|
@@ -928,7 +928,18 @@ export namespace MarkdownParser {
|
|
|
928
928
|
export interface CommentParser extends
|
|
929
929
|
// [# comment #]
|
|
930
930
|
Inline<'comment'>,
|
|
931
|
-
Parser<HTMLElement, Context, [
|
|
931
|
+
Parser<HTMLElement, Context, [
|
|
932
|
+
CommentParser.TextParser,
|
|
933
|
+
]> {
|
|
934
|
+
}
|
|
935
|
+
export namespace CommentParser {
|
|
936
|
+
export interface TextParser extends
|
|
937
|
+
Inline<'comment/text'>,
|
|
938
|
+
Parser<string, Context, [
|
|
939
|
+
UnsafeHTMLEntityParser,
|
|
940
|
+
SourceParser.UnescapableSourceParser,
|
|
941
|
+
]> {
|
|
942
|
+
}
|
|
932
943
|
}
|
|
933
944
|
export interface InsertionParser extends
|
|
934
945
|
// ++abc++
|
|
@@ -1005,7 +1016,6 @@ export namespace MarkdownParser {
|
|
|
1005
1016
|
Inline<'htmlentity'>,
|
|
1006
1017
|
Parser<HTMLSpanElement | string, Context, [
|
|
1007
1018
|
UnsafeHTMLEntityParser,
|
|
1008
|
-
Parser<HTMLSpanElement, Context, []>,
|
|
1009
1019
|
]> {
|
|
1010
1020
|
}
|
|
1011
1021
|
export interface UnsafeHTMLEntityParser extends
|
package/package-lock.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "securemark",
|
|
3
|
-
"version": "0.226.
|
|
3
|
+
"version": "0.226.4",
|
|
4
4
|
"lockfileVersion": 1,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@babel/code-frame": {
|
|
8
|
-
"version": "7.16.
|
|
9
|
-
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.
|
|
10
|
-
"integrity": "sha512-
|
|
8
|
+
"version": "7.16.7",
|
|
9
|
+
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.7.tgz",
|
|
10
|
+
"integrity": "sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg==",
|
|
11
11
|
"dev": true,
|
|
12
12
|
"requires": {
|
|
13
|
-
"@babel/highlight": "^7.16.
|
|
13
|
+
"@babel/highlight": "^7.16.7"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"@babel/compat-data": {
|
|
@@ -20,20 +20,20 @@
|
|
|
20
20
|
"dev": true
|
|
21
21
|
},
|
|
22
22
|
"@babel/core": {
|
|
23
|
-
"version": "7.16.
|
|
24
|
-
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.16.
|
|
25
|
-
"integrity": "sha512-
|
|
26
|
-
"dev": true,
|
|
27
|
-
"requires": {
|
|
28
|
-
"@babel/code-frame": "^7.16.
|
|
29
|
-
"@babel/generator": "^7.16.
|
|
30
|
-
"@babel/helper-compilation-targets": "^7.16.
|
|
31
|
-
"@babel/helper-module-transforms": "^7.16.
|
|
32
|
-
"@babel/helpers": "^7.16.
|
|
33
|
-
"@babel/parser": "^7.16.
|
|
34
|
-
"@babel/template": "^7.16.
|
|
35
|
-
"@babel/traverse": "^7.16.
|
|
36
|
-
"@babel/types": "^7.16.
|
|
23
|
+
"version": "7.16.7",
|
|
24
|
+
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.16.7.tgz",
|
|
25
|
+
"integrity": "sha512-aeLaqcqThRNZYmbMqtulsetOQZ/5gbR/dWruUCJcpas4Qoyy+QeagfDsPdMrqwsPRDNxJvBlRiZxxX7THO7qtA==",
|
|
26
|
+
"dev": true,
|
|
27
|
+
"requires": {
|
|
28
|
+
"@babel/code-frame": "^7.16.7",
|
|
29
|
+
"@babel/generator": "^7.16.7",
|
|
30
|
+
"@babel/helper-compilation-targets": "^7.16.7",
|
|
31
|
+
"@babel/helper-module-transforms": "^7.16.7",
|
|
32
|
+
"@babel/helpers": "^7.16.7",
|
|
33
|
+
"@babel/parser": "^7.16.7",
|
|
34
|
+
"@babel/template": "^7.16.7",
|
|
35
|
+
"@babel/traverse": "^7.16.7",
|
|
36
|
+
"@babel/types": "^7.16.7",
|
|
37
37
|
"convert-source-map": "^1.7.0",
|
|
38
38
|
"debug": "^4.1.0",
|
|
39
39
|
"gensync": "^1.0.0-beta.2",
|
|
@@ -81,24 +81,24 @@
|
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
"@babel/generator": {
|
|
84
|
-
"version": "7.16.
|
|
85
|
-
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.16.
|
|
86
|
-
"integrity": "sha512
|
|
84
|
+
"version": "7.16.7",
|
|
85
|
+
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.16.7.tgz",
|
|
86
|
+
"integrity": "sha512-/ST3Sg8MLGY5HVYmrjOgL60ENux/HfO/CsUh7y4MalThufhE/Ff/6EibFDHi4jiDCaWfJKoqbE6oTh21c5hrRg==",
|
|
87
87
|
"dev": true,
|
|
88
88
|
"requires": {
|
|
89
|
-
"@babel/types": "^7.16.
|
|
89
|
+
"@babel/types": "^7.16.7",
|
|
90
90
|
"jsesc": "^2.5.1",
|
|
91
91
|
"source-map": "^0.5.0"
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
94
|
"@babel/helper-compilation-targets": {
|
|
95
|
-
"version": "7.16.
|
|
96
|
-
"resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.16.
|
|
97
|
-
"integrity": "sha512-
|
|
95
|
+
"version": "7.16.7",
|
|
96
|
+
"resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.16.7.tgz",
|
|
97
|
+
"integrity": "sha512-mGojBwIWcwGD6rfqgRXVlVYmPAv7eOpIemUG3dGnDdCY4Pae70ROij3XmfrH6Fa1h1aiDylpglbZyktfzyo/hA==",
|
|
98
98
|
"dev": true,
|
|
99
99
|
"requires": {
|
|
100
|
-
"@babel/compat-data": "^7.16.
|
|
101
|
-
"@babel/helper-validator-option": "^7.
|
|
100
|
+
"@babel/compat-data": "^7.16.4",
|
|
101
|
+
"@babel/helper-validator-option": "^7.16.7",
|
|
102
102
|
"browserslist": "^4.17.5",
|
|
103
103
|
"semver": "^6.3.0"
|
|
104
104
|
},
|
|
@@ -112,116 +112,116 @@
|
|
|
112
112
|
}
|
|
113
113
|
},
|
|
114
114
|
"@babel/helper-environment-visitor": {
|
|
115
|
-
"version": "7.16.
|
|
116
|
-
"resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.16.
|
|
117
|
-
"integrity": "sha512-
|
|
115
|
+
"version": "7.16.7",
|
|
116
|
+
"resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.16.7.tgz",
|
|
117
|
+
"integrity": "sha512-SLLb0AAn6PkUeAfKJCCOl9e1R53pQlGAfc4y4XuMRZfqeMYLE0dM1LMhqbGAlGQY0lfw5/ohoYWAe9V1yibRag==",
|
|
118
118
|
"dev": true,
|
|
119
119
|
"requires": {
|
|
120
|
-
"@babel/types": "^7.16.
|
|
120
|
+
"@babel/types": "^7.16.7"
|
|
121
121
|
}
|
|
122
122
|
},
|
|
123
123
|
"@babel/helper-function-name": {
|
|
124
|
-
"version": "7.16.
|
|
125
|
-
"resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.16.
|
|
126
|
-
"integrity": "sha512-
|
|
124
|
+
"version": "7.16.7",
|
|
125
|
+
"resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.16.7.tgz",
|
|
126
|
+
"integrity": "sha512-QfDfEnIUyyBSR3HtrtGECuZ6DAyCkYFp7GHl75vFtTnn6pjKeK0T1DB5lLkFvBea8MdaiUABx3osbgLyInoejA==",
|
|
127
127
|
"dev": true,
|
|
128
128
|
"requires": {
|
|
129
|
-
"@babel/helper-get-function-arity": "^7.16.
|
|
130
|
-
"@babel/template": "^7.16.
|
|
131
|
-
"@babel/types": "^7.16.
|
|
129
|
+
"@babel/helper-get-function-arity": "^7.16.7",
|
|
130
|
+
"@babel/template": "^7.16.7",
|
|
131
|
+
"@babel/types": "^7.16.7"
|
|
132
132
|
}
|
|
133
133
|
},
|
|
134
134
|
"@babel/helper-get-function-arity": {
|
|
135
|
-
"version": "7.16.
|
|
136
|
-
"resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.16.
|
|
137
|
-
"integrity": "sha512-
|
|
135
|
+
"version": "7.16.7",
|
|
136
|
+
"resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.16.7.tgz",
|
|
137
|
+
"integrity": "sha512-flc+RLSOBXzNzVhcLu6ujeHUrD6tANAOU5ojrRx/as+tbzf8+stUCj7+IfRRoAbEZqj/ahXEMsjhOhgeZsrnTw==",
|
|
138
138
|
"dev": true,
|
|
139
139
|
"requires": {
|
|
140
|
-
"@babel/types": "^7.16.
|
|
140
|
+
"@babel/types": "^7.16.7"
|
|
141
141
|
}
|
|
142
142
|
},
|
|
143
143
|
"@babel/helper-hoist-variables": {
|
|
144
|
-
"version": "7.16.
|
|
145
|
-
"resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.16.
|
|
146
|
-
"integrity": "sha512-
|
|
144
|
+
"version": "7.16.7",
|
|
145
|
+
"resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.16.7.tgz",
|
|
146
|
+
"integrity": "sha512-m04d/0Op34H5v7pbZw6pSKP7weA6lsMvfiIAMeIvkY/R4xQtBSMFEigu9QTZ2qB/9l22vsxtM8a+Q8CzD255fg==",
|
|
147
147
|
"dev": true,
|
|
148
148
|
"requires": {
|
|
149
|
-
"@babel/types": "^7.16.
|
|
149
|
+
"@babel/types": "^7.16.7"
|
|
150
150
|
}
|
|
151
151
|
},
|
|
152
152
|
"@babel/helper-module-imports": {
|
|
153
|
-
"version": "7.16.
|
|
154
|
-
"resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.16.
|
|
155
|
-
"integrity": "sha512-
|
|
153
|
+
"version": "7.16.7",
|
|
154
|
+
"resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.16.7.tgz",
|
|
155
|
+
"integrity": "sha512-LVtS6TqjJHFc+nYeITRo6VLXve70xmq7wPhWTqDJusJEgGmkAACWwMiTNrvfoQo6hEhFwAIixNkvB0jPXDL8Wg==",
|
|
156
156
|
"dev": true,
|
|
157
157
|
"requires": {
|
|
158
|
-
"@babel/types": "^7.16.
|
|
158
|
+
"@babel/types": "^7.16.7"
|
|
159
159
|
}
|
|
160
160
|
},
|
|
161
161
|
"@babel/helper-module-transforms": {
|
|
162
|
-
"version": "7.16.
|
|
163
|
-
"resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.16.
|
|
164
|
-
"integrity": "sha512-
|
|
162
|
+
"version": "7.16.7",
|
|
163
|
+
"resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.16.7.tgz",
|
|
164
|
+
"integrity": "sha512-gaqtLDxJEFCeQbYp9aLAefjhkKdjKcdh6DB7jniIGU3Pz52WAmP268zK0VgPz9hUNkMSYeH976K2/Y6yPadpng==",
|
|
165
165
|
"dev": true,
|
|
166
166
|
"requires": {
|
|
167
|
-
"@babel/helper-environment-visitor": "^7.16.
|
|
168
|
-
"@babel/helper-module-imports": "^7.16.
|
|
169
|
-
"@babel/helper-simple-access": "^7.16.
|
|
170
|
-
"@babel/helper-split-export-declaration": "^7.16.
|
|
171
|
-
"@babel/helper-validator-identifier": "^7.
|
|
172
|
-
"@babel/template": "^7.16.
|
|
173
|
-
"@babel/traverse": "^7.16.
|
|
174
|
-
"@babel/types": "^7.16.
|
|
167
|
+
"@babel/helper-environment-visitor": "^7.16.7",
|
|
168
|
+
"@babel/helper-module-imports": "^7.16.7",
|
|
169
|
+
"@babel/helper-simple-access": "^7.16.7",
|
|
170
|
+
"@babel/helper-split-export-declaration": "^7.16.7",
|
|
171
|
+
"@babel/helper-validator-identifier": "^7.16.7",
|
|
172
|
+
"@babel/template": "^7.16.7",
|
|
173
|
+
"@babel/traverse": "^7.16.7",
|
|
174
|
+
"@babel/types": "^7.16.7"
|
|
175
175
|
}
|
|
176
176
|
},
|
|
177
177
|
"@babel/helper-simple-access": {
|
|
178
|
-
"version": "7.16.
|
|
179
|
-
"resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.16.
|
|
180
|
-
"integrity": "sha512-
|
|
178
|
+
"version": "7.16.7",
|
|
179
|
+
"resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.16.7.tgz",
|
|
180
|
+
"integrity": "sha512-ZIzHVyoeLMvXMN/vok/a4LWRy8G2v205mNP0XOuf9XRLyX5/u9CnVulUtDgUTama3lT+bf/UqucuZjqiGuTS1g==",
|
|
181
181
|
"dev": true,
|
|
182
182
|
"requires": {
|
|
183
|
-
"@babel/types": "^7.16.
|
|
183
|
+
"@babel/types": "^7.16.7"
|
|
184
184
|
}
|
|
185
185
|
},
|
|
186
186
|
"@babel/helper-split-export-declaration": {
|
|
187
|
-
"version": "7.16.
|
|
188
|
-
"resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.16.
|
|
189
|
-
"integrity": "sha512-
|
|
187
|
+
"version": "7.16.7",
|
|
188
|
+
"resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.16.7.tgz",
|
|
189
|
+
"integrity": "sha512-xbWoy/PFoxSWazIToT9Sif+jJTlrMcndIsaOKvTA6u7QEo7ilkRZpjew18/W3c7nm8fXdUDXh02VXTbZ0pGDNw==",
|
|
190
190
|
"dev": true,
|
|
191
191
|
"requires": {
|
|
192
|
-
"@babel/types": "^7.16.
|
|
192
|
+
"@babel/types": "^7.16.7"
|
|
193
193
|
}
|
|
194
194
|
},
|
|
195
195
|
"@babel/helper-validator-identifier": {
|
|
196
|
-
"version": "7.
|
|
197
|
-
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.
|
|
198
|
-
"integrity": "sha512-
|
|
196
|
+
"version": "7.16.7",
|
|
197
|
+
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz",
|
|
198
|
+
"integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==",
|
|
199
199
|
"dev": true
|
|
200
200
|
},
|
|
201
201
|
"@babel/helper-validator-option": {
|
|
202
|
-
"version": "7.
|
|
203
|
-
"resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.
|
|
204
|
-
"integrity": "sha512-
|
|
202
|
+
"version": "7.16.7",
|
|
203
|
+
"resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.16.7.tgz",
|
|
204
|
+
"integrity": "sha512-TRtenOuRUVo9oIQGPC5G9DgK4743cdxvtOw0weQNpZXaS16SCBi5MNjZF8vba3ETURjZpTbVn7Vvcf2eAwFozQ==",
|
|
205
205
|
"dev": true
|
|
206
206
|
},
|
|
207
207
|
"@babel/helpers": {
|
|
208
|
-
"version": "7.16.
|
|
209
|
-
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.16.
|
|
210
|
-
"integrity": "sha512-
|
|
208
|
+
"version": "7.16.7",
|
|
209
|
+
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.16.7.tgz",
|
|
210
|
+
"integrity": "sha512-9ZDoqtfY7AuEOt3cxchfii6C7GDyyMBffktR5B2jvWv8u2+efwvpnVKXMWzNehqy68tKgAfSwfdw/lWpthS2bw==",
|
|
211
211
|
"dev": true,
|
|
212
212
|
"requires": {
|
|
213
|
-
"@babel/template": "^7.16.
|
|
214
|
-
"@babel/traverse": "^7.16.
|
|
215
|
-
"@babel/types": "^7.16.
|
|
213
|
+
"@babel/template": "^7.16.7",
|
|
214
|
+
"@babel/traverse": "^7.16.7",
|
|
215
|
+
"@babel/types": "^7.16.7"
|
|
216
216
|
}
|
|
217
217
|
},
|
|
218
218
|
"@babel/highlight": {
|
|
219
|
-
"version": "7.16.
|
|
220
|
-
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.16.
|
|
221
|
-
"integrity": "sha512-
|
|
219
|
+
"version": "7.16.7",
|
|
220
|
+
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.16.7.tgz",
|
|
221
|
+
"integrity": "sha512-aKpPMfLvGO3Q97V0qhw/V2SWNWlwfJknuwAunU7wZLSfrM4xTBvg7E5opUVi1kJTBKihE38CPg4nBiqX83PWYw==",
|
|
222
222
|
"dev": true,
|
|
223
223
|
"requires": {
|
|
224
|
-
"@babel/helper-validator-identifier": "^7.
|
|
224
|
+
"@babel/helper-validator-identifier": "^7.16.7",
|
|
225
225
|
"chalk": "^2.0.0",
|
|
226
226
|
"js-tokens": "^4.0.0"
|
|
227
227
|
},
|
|
@@ -279,36 +279,36 @@
|
|
|
279
279
|
}
|
|
280
280
|
},
|
|
281
281
|
"@babel/parser": {
|
|
282
|
-
"version": "7.16.
|
|
283
|
-
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.16.
|
|
284
|
-
"integrity": "sha512-
|
|
282
|
+
"version": "7.16.7",
|
|
283
|
+
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.16.7.tgz",
|
|
284
|
+
"integrity": "sha512-sR4eaSrnM7BV7QPzGfEX5paG/6wrZM3I0HDzfIAK06ESvo9oy3xBuVBxE3MbQaKNhvg8g/ixjMWo2CGpzpHsDA==",
|
|
285
285
|
"dev": true
|
|
286
286
|
},
|
|
287
287
|
"@babel/template": {
|
|
288
|
-
"version": "7.16.
|
|
289
|
-
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.16.
|
|
290
|
-
"integrity": "sha512-
|
|
288
|
+
"version": "7.16.7",
|
|
289
|
+
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.16.7.tgz",
|
|
290
|
+
"integrity": "sha512-I8j/x8kHUrbYRTUxXrrMbfCa7jxkE7tZre39x3kjr9hvI82cK1FfqLygotcWN5kdPGWcLdWMHpSBavse5tWw3w==",
|
|
291
291
|
"dev": true,
|
|
292
292
|
"requires": {
|
|
293
|
-
"@babel/code-frame": "^7.16.
|
|
294
|
-
"@babel/parser": "^7.16.
|
|
295
|
-
"@babel/types": "^7.16.
|
|
293
|
+
"@babel/code-frame": "^7.16.7",
|
|
294
|
+
"@babel/parser": "^7.16.7",
|
|
295
|
+
"@babel/types": "^7.16.7"
|
|
296
296
|
}
|
|
297
297
|
},
|
|
298
298
|
"@babel/traverse": {
|
|
299
|
-
"version": "7.16.
|
|
300
|
-
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.16.
|
|
301
|
-
"integrity": "sha512-
|
|
302
|
-
"dev": true,
|
|
303
|
-
"requires": {
|
|
304
|
-
"@babel/code-frame": "^7.16.
|
|
305
|
-
"@babel/generator": "^7.16.
|
|
306
|
-
"@babel/helper-environment-visitor": "^7.16.
|
|
307
|
-
"@babel/helper-function-name": "^7.16.
|
|
308
|
-
"@babel/helper-hoist-variables": "^7.16.
|
|
309
|
-
"@babel/helper-split-export-declaration": "^7.16.
|
|
310
|
-
"@babel/parser": "^7.16.
|
|
311
|
-
"@babel/types": "^7.16.
|
|
299
|
+
"version": "7.16.7",
|
|
300
|
+
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.16.7.tgz",
|
|
301
|
+
"integrity": "sha512-8KWJPIb8c2VvY8AJrydh6+fVRo2ODx1wYBU2398xJVq0JomuLBZmVQzLPBblJgHIGYG4znCpUZUZ0Pt2vdmVYQ==",
|
|
302
|
+
"dev": true,
|
|
303
|
+
"requires": {
|
|
304
|
+
"@babel/code-frame": "^7.16.7",
|
|
305
|
+
"@babel/generator": "^7.16.7",
|
|
306
|
+
"@babel/helper-environment-visitor": "^7.16.7",
|
|
307
|
+
"@babel/helper-function-name": "^7.16.7",
|
|
308
|
+
"@babel/helper-hoist-variables": "^7.16.7",
|
|
309
|
+
"@babel/helper-split-export-declaration": "^7.16.7",
|
|
310
|
+
"@babel/parser": "^7.16.7",
|
|
311
|
+
"@babel/types": "^7.16.7",
|
|
312
312
|
"debug": "^4.1.0",
|
|
313
313
|
"globals": "^11.1.0"
|
|
314
314
|
},
|
|
@@ -331,12 +331,12 @@
|
|
|
331
331
|
}
|
|
332
332
|
},
|
|
333
333
|
"@babel/types": {
|
|
334
|
-
"version": "7.16.
|
|
335
|
-
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.16.
|
|
336
|
-
"integrity": "sha512-
|
|
334
|
+
"version": "7.16.7",
|
|
335
|
+
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.16.7.tgz",
|
|
336
|
+
"integrity": "sha512-E8HuV7FO9qLpx6OtoGfUQ2cjIYnbFwvZWYBS+87EwtdMvmUPJSwykpovFB+8insbpF0uJcpr8KMUi64XZntZcg==",
|
|
337
337
|
"dev": true,
|
|
338
338
|
"requires": {
|
|
339
|
-
"@babel/helper-validator-identifier": "^7.
|
|
339
|
+
"@babel/helper-validator-identifier": "^7.16.7",
|
|
340
340
|
"to-fast-properties": "^2.0.0"
|
|
341
341
|
}
|
|
342
342
|
},
|
|
@@ -694,9 +694,9 @@
|
|
|
694
694
|
}
|
|
695
695
|
},
|
|
696
696
|
"agentkeepalive": {
|
|
697
|
-
"version": "4.
|
|
698
|
-
"resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.
|
|
699
|
-
"integrity": "sha512
|
|
697
|
+
"version": "4.2.0",
|
|
698
|
+
"resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.2.0.tgz",
|
|
699
|
+
"integrity": "sha512-0PhAp58jZNw13UJv7NVdTGb0ZcghHUb3DrZ046JiiJY/BOaTTpbwdHq2VObPCBV8M2GPh7sgrJ3AQ8Ey468LJw==",
|
|
700
700
|
"dev": true,
|
|
701
701
|
"requires": {
|
|
702
702
|
"debug": "^4.1.0",
|
package/package.json
CHANGED
package/src/debug.test.ts
CHANGED
|
@@ -17,6 +17,7 @@ export function inspect(result: Result<HTMLElement | string>, until: number | st
|
|
|
17
17
|
? until
|
|
18
18
|
: ~(~node.outerHTML.indexOf(until) || -Infinity) + until.length;
|
|
19
19
|
const el = html('div');
|
|
20
|
+
assert(!node.outerHTML.match(/[\0\x7F]/));
|
|
20
21
|
el.innerHTML = node.outerHTML.slice(0, until);
|
|
21
22
|
if (node.outerHTML.length <= until) {
|
|
22
23
|
assert(node.outerHTML === el.innerHTML);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { unsafehtmlentity } from '../inline/htmlentity';
|
|
2
1
|
import { eval } from '../../combinator/data/parser';
|
|
2
|
+
import { htmlentity } from '../inline/htmlentity';
|
|
3
|
+
import { stringify } from '../util';
|
|
3
4
|
|
|
4
5
|
const UNICODE_REPLACEMENT_CHARACTER = '\uFFFD';
|
|
5
6
|
assert(UNICODE_REPLACEMENT_CHARACTER.trim());
|
|
@@ -59,8 +60,8 @@ const unreadableHTMLEntityNames = [
|
|
|
59
60
|
'ic',
|
|
60
61
|
] as const;
|
|
61
62
|
const unreadableEscapableCharacters = unreadableHTMLEntityNames
|
|
62
|
-
.
|
|
63
|
-
assert(unreadableEscapableCharacters.length ===
|
|
63
|
+
.map(name => stringify(eval(htmlentity(`&${name};`, {}))!));
|
|
64
|
+
assert(unreadableEscapableCharacters.every(c => c.length === 1));
|
|
64
65
|
const unreadableEscapableCharacter = new RegExp(`[${
|
|
65
66
|
[...new Set<string>(unreadableEscapableCharacters)].join('')
|
|
66
67
|
}]`, 'g');
|
|
@@ -16,7 +16,8 @@ describe('Unit: parser/inline/comment', () => {
|
|
|
16
16
|
assert.deepStrictEqual(inspect(parser('[# #]')), undefined);
|
|
17
17
|
assert.deepStrictEqual(inspect(parser('[# #] #]')), undefined);
|
|
18
18
|
assert.deepStrictEqual(inspect(parser('[# #] #]')), undefined);
|
|
19
|
-
assert.deepStrictEqual(inspect(parser(
|
|
19
|
+
assert.deepStrictEqual(inspect(parser('[# [# ')), undefined);
|
|
20
|
+
assert.deepStrictEqual(inspect(parser('[# a [# ')), [['<sup class="comment invalid">[# a </sup>'], '[# ']);
|
|
20
21
|
assert.deepStrictEqual(inspect(parser('[#a#]')), undefined);
|
|
21
22
|
assert.deepStrictEqual(inspect(parser('[#a b#]')), undefined);
|
|
22
23
|
assert.deepStrictEqual(inspect(parser('[#\\ a #]')), undefined);
|
|
@@ -24,8 +25,8 @@ describe('Unit: parser/inline/comment', () => {
|
|
|
24
25
|
assert.deepStrictEqual(inspect(parser('[# a##]')), undefined);
|
|
25
26
|
assert.deepStrictEqual(inspect(parser('[# a ##]')), undefined);
|
|
26
27
|
assert.deepStrictEqual(inspect(parser('[## a #]')), undefined);
|
|
28
|
+
assert.deepStrictEqual(inspect(parser('[# &a; #]')), [['<sup class="comment invalid">[# &a; #]</sup>'], '']);
|
|
27
29
|
assert.deepStrictEqual(inspect(parser(' [# a #]')), undefined);
|
|
28
|
-
assert.deepStrictEqual(inspect(parser(`[#\na${' '.repeat(100000 - 6)}\n#`)), undefined);
|
|
29
30
|
});
|
|
30
31
|
|
|
31
32
|
it('basic', () => {
|
|
@@ -34,15 +35,12 @@ describe('Unit: parser/inline/comment', () => {
|
|
|
34
35
|
assert.deepStrictEqual(inspect(parser('[# a\nb #]')), [['<sup class="comment" title="a\nb"></sup>'], '']);
|
|
35
36
|
assert.deepStrictEqual(inspect(parser('[# a\\ #]')), [['<sup class="comment" title="a\\"></sup>'], '']);
|
|
36
37
|
assert.deepStrictEqual(inspect(parser('[# a #] #]')), [['<sup class="comment" title="a"></sup>'], ' #]']);
|
|
37
|
-
assert.deepStrictEqual(inspect(parser('[# [# #]')), [['<sup class="comment" title="[#"></sup>'], '']);
|
|
38
38
|
assert.deepStrictEqual(inspect(parser('[## a ##]')), [['<sup class="comment" title="a"></sup>'], '']);
|
|
39
39
|
assert.deepStrictEqual(inspect(parser('[## #] ##]')), [['<sup class="comment" title="#]"></sup>'], '']);
|
|
40
40
|
assert.deepStrictEqual(inspect(parser('[# a #]b')), [['<sup class="comment" title="a"></sup>'], 'b']);
|
|
41
41
|
assert.deepStrictEqual(inspect(parser('[#\na\n#]')), [['<sup class="comment" title="a"></sup>'], '']);
|
|
42
|
-
assert.deepStrictEqual(inspect(parser(
|
|
43
|
-
assert.deepStrictEqual(inspect(parser(
|
|
44
|
-
assert.deepStrictEqual(inspect(parser(`[#\n${'a\n'.repeat(101)}#]b`)), [[`<sup class="comment invalid">${'a\n'.repeat(101).trim()}</sup>`], 'b']);
|
|
45
|
-
assert.deepStrictEqual(inspect(parser(`[#\n${'a\n'.repeat(100000 / 2 - 6 / 2)}#]b`)), [[`<sup class="comment invalid">${'a\n'.repeat(100000 / 2 - 6 / 2).trim()}</sup>`], 'b']);
|
|
42
|
+
assert.deepStrictEqual(inspect(parser('[# © #]')), [['<sup class="comment" title="©"></sup>'], '']);
|
|
43
|
+
assert.deepStrictEqual(inspect(parser('[# &copy; #]')), [['<sup class="comment" title="&copy;"></sup>'], '']);
|
|
46
44
|
});
|
|
47
45
|
|
|
48
46
|
});
|
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
import { CommentParser } from '../inline';
|
|
2
|
-
import { validate, creator, match } from '../../combinator';
|
|
2
|
+
import { union, some, validate, creator, match } from '../../combinator';
|
|
3
|
+
import { eval } from '../../combinator/data/parser';
|
|
4
|
+
import { unsafehtmlentity } from './htmlentity';
|
|
5
|
+
import { unescsource } from '../source';
|
|
3
6
|
import { html } from 'typed-dom';
|
|
4
|
-
import { memoize } from 'spica/memoize';
|
|
5
|
-
|
|
6
|
-
const closer = memoize<string, RegExp>(sharps => new RegExp(String.raw`\s${sharps}]`));
|
|
7
7
|
|
|
8
8
|
export const comment: CommentParser = creator(validate('[#', match(
|
|
9
|
-
/^\[(#+)\s+(?!\s|\1\])(
|
|
10
|
-
([,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
title: title.trimEnd().replace(/\x7F.?/gs, ''),
|
|
14
|
-
})], rest];
|
|
15
|
-
assert(rest.trimStart() === rest);
|
|
16
|
-
const i = rest.search(closer(sharps));
|
|
17
|
-
if (i !== -1) return [[html('sup', {
|
|
9
|
+
/^\[(#+)\s+(?!\s|\1\])((?:\S+\s+)+?)(\1\]|(?=\[\1\s))/,
|
|
10
|
+
([whole, , body, closer]) => (rest, context) => {
|
|
11
|
+
[whole, body] = `${whole}\0${body.trimEnd()}`.replace(/\x7F.?/gs, '').split('\0', 2);
|
|
12
|
+
if (!closer) return [[html('sup', {
|
|
18
13
|
class: 'comment invalid',
|
|
19
14
|
'data-invalid-syntax': 'comment',
|
|
20
15
|
'data-invalid-type': 'content',
|
|
21
|
-
'data-invalid-description': '
|
|
22
|
-
},
|
|
23
|
-
|
|
16
|
+
'data-invalid-description': 'Comment syntax using the same level cannot start in another comment syntax.',
|
|
17
|
+
}, whole)], rest];
|
|
18
|
+
const title = eval(some(text)(body, context), []).join('').trim();
|
|
19
|
+
if (title.includes('\0')) return [[html('sup', {
|
|
20
|
+
class: 'comment invalid',
|
|
21
|
+
'data-invalid-syntax': 'comment',
|
|
22
|
+
'data-invalid-type': 'content',
|
|
23
|
+
'data-invalid-description': `Invalid HTML entitiy "${title.match(/\0&[0-9A-Za-z]+;/)![0].slice(1)}".`,
|
|
24
|
+
}, whole)], rest];
|
|
25
|
+
return [[html('sup', { class: 'comment', title })], rest];
|
|
24
26
|
})));
|
|
27
|
+
|
|
28
|
+
const text: CommentParser.TextParser = union([
|
|
29
|
+
unsafehtmlentity,
|
|
30
|
+
unescsource,
|
|
31
|
+
]);
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
import { HTMLEntityParser, UnsafeHTMLEntityParser } from '../inline';
|
|
2
|
-
import { union, validate,
|
|
2
|
+
import { union, validate, focus, creator, fmap } from '../../combinator';
|
|
3
3
|
import { html } from 'typed-dom';
|
|
4
4
|
|
|
5
5
|
const parser = html('textarea');
|
|
6
6
|
|
|
7
|
-
export const unsafehtmlentity: UnsafeHTMLEntityParser = creator(validate('&',
|
|
7
|
+
export const unsafehtmlentity: UnsafeHTMLEntityParser = creator(validate('&', fmap(focus(
|
|
8
8
|
/^&[0-9A-Za-z]+;/,
|
|
9
9
|
entity => [[(parser.innerHTML = entity, parser.value)], '']),
|
|
10
|
-
([str]) =>
|
|
10
|
+
([str]) => [
|
|
11
|
+
str[0] !== '&' || str.length < 3
|
|
12
|
+
? str
|
|
13
|
+
: `\0${str}`,
|
|
14
|
+
])));
|
|
11
15
|
|
|
12
|
-
export const htmlentity: HTMLEntityParser = creator(validate('&',
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
]))));
|
|
16
|
+
export const htmlentity: HTMLEntityParser = creator(validate('&', fmap(
|
|
17
|
+
union([unsafehtmlentity]),
|
|
18
|
+
([str]) => [
|
|
19
|
+
str[0] === '\0'
|
|
20
|
+
? html('span', {
|
|
21
|
+
class: 'invalid',
|
|
22
|
+
'data-invalid-syntax': 'htmlentity',
|
|
23
|
+
'data-invalid-type': 'syntax',
|
|
24
|
+
'data-invalid-description': 'Invalid HTML entity.',
|
|
25
|
+
}, str.slice(1))
|
|
26
|
+
: str,
|
|
27
|
+
])));
|
|
@@ -47,7 +47,7 @@ export const link: LinkParser = lazy(() => creator(10, bind(reverse(
|
|
|
47
47
|
])))),
|
|
48
48
|
([params, content = []]: [string[], (HTMLElement | string)[]], rest, context) => {
|
|
49
49
|
assert(params.every(p => typeof p === 'string'));
|
|
50
|
-
if (eval(some(autolink)(stringify(content), context)
|
|
50
|
+
if (eval(some(autolink)(stringify(content), context))?.some(node => typeof node === 'object')) return;
|
|
51
51
|
assert(!html('div', content).querySelector('a, .media, .annotation, .reference') || (content[0] as HTMLElement).matches('.media'));
|
|
52
52
|
const INSECURE_URI = params.shift()!;
|
|
53
53
|
assert(INSECURE_URI === INSECURE_URI.trim());
|
|
@@ -158,7 +158,7 @@ function create(
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
function decode(uri: string): string {
|
|
161
|
-
if (uri.
|
|
161
|
+
if (!uri.includes('%')) return uri;
|
|
162
162
|
try {
|
|
163
163
|
uri = decodeURI(uri);
|
|
164
164
|
}
|
|
@@ -41,6 +41,7 @@ describe('Unit: parser/inline/media', () => {
|
|
|
41
41
|
assert.deepStrictEqual(inspect(parser('![\\ ]{b}')), undefined);
|
|
42
42
|
assert.deepStrictEqual(inspect(parser('![\\\n]{b}')), undefined);
|
|
43
43
|
assert.deepStrictEqual(inspect(parser('![	]{b}')), undefined);
|
|
44
|
+
assert.deepStrictEqual(inspect(parser('![&a;]{b}')), [['<img class="media invalid" data-src="b" alt="&a;">'], '']);
|
|
44
45
|
assert.deepStrictEqual(inspect(parser('![[]{b}')), undefined);
|
|
45
46
|
assert.deepStrictEqual(inspect(parser('![]]{b}')), undefined);
|
|
46
47
|
assert.deepStrictEqual(inspect(parser('![a]{}')), undefined);
|
|
@@ -77,6 +78,8 @@ describe('Unit: parser/inline/media', () => {
|
|
|
77
78
|
assert.deepStrictEqual(inspect(parser('![a ]{b}')), [['<a href="b" target="_blank"><img class="media" data-src="b" alt="a"></a>'], '']);
|
|
78
79
|
assert.deepStrictEqual(inspect(parser('![a ]{b}')), [['<a href="b" target="_blank"><img class="media" data-src="b" alt="a"></a>'], '']);
|
|
79
80
|
assert.deepStrictEqual(inspect(parser('![a b]{c}')), [['<a href="c" target="_blank"><img class="media" data-src="c" alt="a b"></a>'], '']);
|
|
81
|
+
assert.deepStrictEqual(inspect(parser('![©]{b}')), [['<a href="b" target="_blank"><img class="media" data-src="b" alt="©"></a>'], '']);
|
|
82
|
+
assert.deepStrictEqual(inspect(parser('![&copy;]{b}')), [['<a href="b" target="_blank"><img class="media" data-src="b" alt="&copy;"></a>'], '']);
|
|
80
83
|
assert.deepStrictEqual(inspect(parser('!{b}')), [['<a href="b" target="_blank"><img class="media" data-src="b" alt=""></a>'], '']);
|
|
81
84
|
assert.deepStrictEqual(inspect(parser('!{ ][ }')), [['<a href="][" target="_blank"><img class="media" data-src="][" alt=""></a>'], '']);
|
|
82
85
|
assert.deepStrictEqual(inspect(parser('!{ }{ }')), [['<a href="}{" target="_blank"><img class="media" data-src="}{" alt=""></a>'], '']);
|
|
@@ -29,6 +29,7 @@ export const media: MediaParser = lazy(() => creator(10, bind(verify(fmap(open(
|
|
|
29
29
|
([as, bs]) => bs ? [[join(as).trim() || join(as)], bs] : [[''], as]),
|
|
30
30
|
([[text]]) => text === '' || text.trim() !== ''),
|
|
31
31
|
([[text], params], rest, context) => {
|
|
32
|
+
assert(text === text.trim());
|
|
32
33
|
const INSECURE_URI = params.shift()!;
|
|
33
34
|
assert(INSECURE_URI === INSECURE_URI.trim());
|
|
34
35
|
assert(!INSECURE_URI.match(/\s/));
|
|
@@ -40,9 +41,9 @@ export const media: MediaParser = lazy(() => creator(10, bind(verify(fmap(open(
|
|
|
40
41
|
|| (cache = context.caches?.media?.get(url.href)?.cloneNode(true))
|
|
41
42
|
|| html('img', { class: 'media', 'data-src': url.source, alt: text });
|
|
42
43
|
assert(!el.matches('.invalid'));
|
|
43
|
-
if (!cache && !sanitize(url, el)) return [[el], rest];
|
|
44
|
-
assert(!el.matches('.invalid'));
|
|
45
44
|
cache?.hasAttribute('alt') && cache?.setAttribute('alt', text);
|
|
45
|
+
if (!sanitize(el, url, text)) return [[el], rest];
|
|
46
|
+
assert(!el.matches('.invalid'));
|
|
46
47
|
define(el, attributes('media', push([], el.classList), optspec, params));
|
|
47
48
|
assert(el.matches('img') || !el.matches('.invalid'));
|
|
48
49
|
if (context.syntax?.inline?.link === false || cache && cache.tagName !== 'IMG') return [[el], rest];
|
|
@@ -65,18 +66,9 @@ const option: MediaParser.ParameterParser.OptionParser = union([
|
|
|
65
66
|
linkoption,
|
|
66
67
|
]);
|
|
67
68
|
|
|
68
|
-
function sanitize(uri: ReadonlyURL,
|
|
69
|
+
function sanitize(target: HTMLElement, uri: ReadonlyURL, alt: string): boolean {
|
|
69
70
|
assert(target.tagName === 'IMG');
|
|
70
71
|
assert(!target.matches('.invalid'));
|
|
71
|
-
if (/\/\.\.?(?:\/|$)/.test('/' + uri.source.slice(0, uri.source.search(/[?#]|$/)))) {
|
|
72
|
-
define(target, {
|
|
73
|
-
class: void target.classList.add('invalid'),
|
|
74
|
-
'data-invalid-syntax': 'media',
|
|
75
|
-
'data-invalid-type': 'argument',
|
|
76
|
-
'data-invalid-description': 'Dot-segments cannot be used in media paths; use subresource paths instead.',
|
|
77
|
-
});
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
72
|
switch (uri.protocol) {
|
|
81
73
|
case 'http:':
|
|
82
74
|
case 'https:':
|
|
@@ -91,5 +83,24 @@ function sanitize(uri: ReadonlyURL, target: HTMLElement): boolean {
|
|
|
91
83
|
});
|
|
92
84
|
return false;
|
|
93
85
|
}
|
|
86
|
+
if (/\/\.\.?(?:\/|$)/.test('/' + uri.source.slice(0, uri.source.search(/[?#]|$/)))) {
|
|
87
|
+
define(target, {
|
|
88
|
+
class: void target.classList.add('invalid'),
|
|
89
|
+
'data-invalid-syntax': 'media',
|
|
90
|
+
'data-invalid-type': 'argument',
|
|
91
|
+
'data-invalid-description': 'Dot-segments cannot be used in media paths; use subresource paths instead.',
|
|
92
|
+
});
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
if (alt.includes('\0')) {
|
|
96
|
+
define(target, {
|
|
97
|
+
class: void target.classList.add('invalid'),
|
|
98
|
+
'data-invalid-syntax': 'media',
|
|
99
|
+
'data-invalid-type': 'content',
|
|
100
|
+
'data-invalid-description': `Cannot use invalid HTML entitiy "${alt.match(/&[0-9A-Za-z]+;/)![0]}".`,
|
|
101
|
+
alt: target.getAttribute('alt')?.replace(/\0/g, ''),
|
|
102
|
+
});
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
94
105
|
return true;
|
|
95
106
|
}
|
|
@@ -14,6 +14,8 @@ describe('Unit: parser/inline/ruby', () => {
|
|
|
14
14
|
assert.deepStrictEqual(inspect(parser('[ a](b)')), undefined);
|
|
15
15
|
assert.deepStrictEqual(inspect(parser('[	a](b)')), undefined);
|
|
16
16
|
assert.deepStrictEqual(inspect(parser('[	 a](b)')), undefined);
|
|
17
|
+
assert.deepStrictEqual(inspect(parser('[&a;](b)')), [['<ruby class="invalid">&a;<rp>(</rp><rt>b</rt><rp>)</rp></ruby>'], '']);
|
|
18
|
+
assert.deepStrictEqual(inspect(parser('[a](&a;)')), [['<ruby class="invalid">a<rp>(</rp><rt>&a;</rt><rp>)</rp></ruby>'], '']);
|
|
17
19
|
assert.deepStrictEqual(inspect(parser('[a]()')), undefined);
|
|
18
20
|
assert.deepStrictEqual(inspect(parser('[a]( )')), undefined);
|
|
19
21
|
assert.deepStrictEqual(inspect(parser('[a\nb](c)')), undefined);
|
|
@@ -45,7 +47,8 @@ describe('Unit: parser/inline/ruby', () => {
|
|
|
45
47
|
assert.deepStrictEqual(inspect(parser('[秦 \\ こころ](はた の こころ)')), [['<ruby>秦<rp>(</rp><rt>はた</rt><rp>)</rp> <rp>(</rp><rt>の</rt><rp>)</rp>こころ<rp>(</rp><rt>こころ</rt><rp>)</rp></ruby>'], '']);
|
|
46
48
|
assert.deepStrictEqual(inspect(parser('[秦 こころ](はた の こころ)')), [['<ruby>秦<rp>(</rp><rt>はた</rt><rp>)</rp> <rp>(</rp><rt>の</rt><rp>)</rp>こころ<rp>(</rp><rt>こころ</rt><rp>)</rp></ruby>'], '']);
|
|
47
49
|
assert.deepStrictEqual(inspect(parser('[&&](&&)')), [['<ruby>&&<rp>(</rp><rt>&&</rt><rp>)</rp></ruby>'], '']);
|
|
48
|
-
assert.deepStrictEqual(inspect(parser('[&
|
|
50
|
+
assert.deepStrictEqual(inspect(parser('[©](©)')), [['<ruby>©<rp>(</rp><rt>©</rt><rp>)</rp></ruby>'], '']);
|
|
51
|
+
assert.deepStrictEqual(inspect(parser('[&copy;](&copy;)')), [['<ruby>&copy;<rp>(</rp><rt>&copy;</rt><rp>)</rp></ruby>'], '']);
|
|
49
52
|
assert.deepStrictEqual(inspect(parser('[*A*](*a*)')), [['<ruby>*A*<rp>(</rp><rt>*a*</rt><rp>)</rp></ruby>'], '']);
|
|
50
53
|
assert.deepStrictEqual(inspect(parser('[<wbr>](<wbr>)')), [['<ruby><wbr><rp>(</rp><rt><wbr></rt><rp>)</rp></ruby>'], '']);
|
|
51
54
|
});
|
|
@@ -22,7 +22,7 @@ export const ruby: RubyParser = lazy(() => creator(bind(verify(
|
|
|
22
22
|
tail.length === 0 && texts[texts.length - 1] === '' && texts.pop();
|
|
23
23
|
switch (true) {
|
|
24
24
|
case rubies.length <= texts.length:
|
|
25
|
-
return [[html('ruby', defrag(push(texts
|
|
25
|
+
return [[html('ruby', attributes(texts, rubies), defrag(push(texts
|
|
26
26
|
.reduce((acc, _, i) =>
|
|
27
27
|
push(acc, unshift([texts[i]],
|
|
28
28
|
i < rubies.length && rubies[i]
|
|
@@ -30,7 +30,7 @@ export const ruby: RubyParser = lazy(() => creator(bind(verify(
|
|
|
30
30
|
: [html('rt')]))
|
|
31
31
|
, []), tail)))], rest];
|
|
32
32
|
case texts.length === 1 && [...texts[0]].length >= rubies.length:
|
|
33
|
-
return [[html('ruby', defrag(push([...texts[0]]
|
|
33
|
+
return [[html('ruby', attributes(texts, rubies), defrag(push([...texts[0]]
|
|
34
34
|
.reduce((acc, _, i, texts) =>
|
|
35
35
|
push(acc, unshift([texts[i]],
|
|
36
36
|
i < rubies.length && rubies[i]
|
|
@@ -39,7 +39,7 @@ export const ruby: RubyParser = lazy(() => creator(bind(verify(
|
|
|
39
39
|
, []), tail)))], rest];
|
|
40
40
|
default:
|
|
41
41
|
assert(rubies.length > 0);
|
|
42
|
-
return [[html('ruby', defrag(push(unshift(
|
|
42
|
+
return [[html('ruby', attributes(texts, rubies), defrag(push(unshift(
|
|
43
43
|
[join(texts, ' ')],
|
|
44
44
|
[html('rp', '('), html('rt', join(rubies, ' ').trim()), html('rp', ')')]), tail)))
|
|
45
45
|
], rest];
|
|
@@ -55,7 +55,7 @@ const text: RubyParser.TextParser = creator((source, context) => {
|
|
|
55
55
|
case '&': {
|
|
56
56
|
const result = unsafehtmlentity(source, context);
|
|
57
57
|
if (result) {
|
|
58
|
-
acc[acc.length - 1] += eval(result
|
|
58
|
+
acc[acc.length - 1] += eval(result)[0];
|
|
59
59
|
source = exec(result, source.slice(1));
|
|
60
60
|
continue;
|
|
61
61
|
}
|
|
@@ -79,3 +79,20 @@ const text: RubyParser.TextParser = creator((source, context) => {
|
|
|
79
79
|
? [[acc], '']
|
|
80
80
|
: undefined;
|
|
81
81
|
});
|
|
82
|
+
|
|
83
|
+
function attributes(texts: string[], rubies: string[]): Record<string, string> {
|
|
84
|
+
let attrs: Record<string, string> | undefined;
|
|
85
|
+
for (const ss of [texts, rubies]) {
|
|
86
|
+
for (let i = 0; i < ss.length; ++i) {
|
|
87
|
+
if (!ss[i].includes('\0')) continue;
|
|
88
|
+
ss[i] = ss[i].replace(/\0/g, '');
|
|
89
|
+
attrs ??= {
|
|
90
|
+
class: 'invalid',
|
|
91
|
+
'data-invalid-syntax': 'ruby',
|
|
92
|
+
'data-invalid-type': ss === texts ? 'content' : 'argument',
|
|
93
|
+
'data-invalid-description': 'Invalid HTML entity.',
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return attrs ?? {};
|
|
98
|
+
}
|
package/src/parser/util.test.ts
CHANGED
|
@@ -6,6 +6,7 @@ describe('Unit: parser/util', () => {
|
|
|
6
6
|
visualize(s => [[s], ''])(`[# ${'a'.repeat(100000 - 6)} #]`);
|
|
7
7
|
visualize(s => [[s], ''])(`[# ${'a\n'.repeat(100000 / 2 - 6 / 2)} #]`);
|
|
8
8
|
visualize(s => [[s], ''])(`[# a${' '.repeat(100000 - 6)} #`);
|
|
9
|
+
visualize(s => [[s], ''])(`${'[# '.repeat(100000 - 2)}a #]`);
|
|
9
10
|
});
|
|
10
11
|
|
|
11
12
|
});
|
package/src/parser/util.ts
CHANGED
|
@@ -42,7 +42,7 @@ const invisibleHTMLEntityNames = [
|
|
|
42
42
|
'InvisibleComma',
|
|
43
43
|
'ic',
|
|
44
44
|
];
|
|
45
|
-
const blankline = new RegExp(String.raw`^(?!$|\n)(?:\\?\s|&(?:${invisibleHTMLEntityNames.join('|')});|<wbr>|\[(#+)\s+(?!\s|\1\])
|
|
45
|
+
const blankline = new RegExp(String.raw`^(?!$|\n)(?:\\?\s|&(?:${invisibleHTMLEntityNames.join('|')});|<wbr>|\[(#+)\s+(?!\s|\1\])(?:\S+\s+)+?(?:\1\]|(?=\[\1\s)))*\\?(?:$|\n)`, 'gm');
|
|
46
46
|
|
|
47
47
|
export function visualize<P extends Parser<HTMLElement | string>>(parser: P): P;
|
|
48
48
|
export function visualize<T extends HTMLElement | string>(parser: Parser<T>): Parser<T> {
|
|
@@ -104,7 +104,7 @@ function isStartTight(source: string, context: MarkdownParser.Context): boolean
|
|
|
104
104
|
switch (true) {
|
|
105
105
|
case source.length > 2
|
|
106
106
|
&& source[1] !== ' '
|
|
107
|
-
&& eval(unsafehtmlentity(source, context))?.[0]
|
|
107
|
+
&& eval(unsafehtmlentity(source, context))?.[0]?.trimStart() === '':
|
|
108
108
|
return false;
|
|
109
109
|
}
|
|
110
110
|
return true;
|