securemark 0.258.5 → 0.258.6
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 +39 -20
- package/markdown.d.ts +4 -4
- package/package.json +1 -1
- package/src/combinator/data/parser/context/delimiter.ts +6 -3
- package/src/parser/block/extension/table.ts +1 -1
- package/src/parser/block/olist.ts +1 -1
- package/src/parser/block/reply/quote.ts +1 -1
- package/src/parser/block/table.ts +1 -1
- package/src/parser/block/ulist.ts +1 -1
- package/src/parser/inline/annotation.ts +1 -1
- package/src/parser/inline/html.test.ts +15 -15
- package/src/parser/inline/html.ts +8 -7
- package/src/parser/inline/link.ts +18 -5
- package/src/parser/inline/reference.ts +1 -1
- package/src/parser/inline/template.ts +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.258.
|
|
1
|
+
/*! securemark v0.258.6 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"));
|
|
@@ -3025,13 +3025,18 @@ class Delimiters {
|
|
|
3025
3025
|
} = this;
|
|
3026
3026
|
|
|
3027
3027
|
for (let i = 0; i < matchers.length; ++i) {
|
|
3028
|
-
|
|
3028
|
+
const matcher = matchers[i];
|
|
3029
|
+
if (precedence >= matcher[2]) continue;
|
|
3030
|
+
|
|
3031
|
+
switch (matcher[3](source)) {
|
|
3029
3032
|
case true:
|
|
3030
|
-
|
|
3031
|
-
continue;
|
|
3033
|
+
return true;
|
|
3032
3034
|
|
|
3033
3035
|
case false:
|
|
3034
3036
|
return false;
|
|
3037
|
+
|
|
3038
|
+
default:
|
|
3039
|
+
continue;
|
|
3035
3040
|
}
|
|
3036
3041
|
}
|
|
3037
3042
|
|
|
@@ -4811,7 +4816,7 @@ function format(rows) {
|
|
|
4811
4816
|
const cell = isVirtual ? (0, array_1.splice)(cells, j, 0, global_1.undefined) && ranges[i][j] : cells[j];
|
|
4812
4817
|
const isHeadCell = cell.tagName === 'TH';
|
|
4813
4818
|
heads |= (0, global_1.BigInt)(isHeadCell) << jn;
|
|
4814
|
-
highlights |= (0, global_1.BigInt)(cell.
|
|
4819
|
+
highlights |= (0, global_1.BigInt)(cell.className === 'highlight') << jn;
|
|
4815
4820
|
hasDataCell ||= !isHeadCell;
|
|
4816
4821
|
|
|
4817
4822
|
if (isHeadCell && !hasDataCell) {
|
|
@@ -5163,7 +5168,7 @@ function initial(type) {
|
|
|
5163
5168
|
}
|
|
5164
5169
|
|
|
5165
5170
|
function format(el, type, form) {
|
|
5166
|
-
if (el.firstElementChild?.firstElementChild?.
|
|
5171
|
+
if (el.firstElementChild?.firstElementChild?.className === 'checkbox') {
|
|
5167
5172
|
el.setAttribute('class', 'checklist');
|
|
5168
5173
|
}
|
|
5169
5174
|
|
|
@@ -5345,7 +5350,7 @@ const qblock = (source, context) => {
|
|
|
5345
5350
|
continue;
|
|
5346
5351
|
}
|
|
5347
5352
|
|
|
5348
|
-
if (child.
|
|
5353
|
+
if (child.className === 'cite' || child.classList.contains('quote')) {
|
|
5349
5354
|
context.resources && (context.resources.clock -= child.childNodes.length);
|
|
5350
5355
|
nodes.splice(i, 1, ...child.childNodes);
|
|
5351
5356
|
--i;
|
|
@@ -5434,7 +5439,7 @@ const head = (0, combinator_1.creation)((0, combinator_1.fmap)(cell, ns => [(0,
|
|
|
5434
5439
|
const data = (0, combinator_1.creation)((0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('td', (0, visibility_1.trimNode)((0, dom_1.defrag)(ns)))]));
|
|
5435
5440
|
|
|
5436
5441
|
function format(rows) {
|
|
5437
|
-
const aligns = rows[0].
|
|
5442
|
+
const aligns = rows[0].className === 'invalid' ? [] : (0, duff_1.duffReduce)(rows.shift().children, (acc, el) => (0, array_1.push)(acc, [el.textContent]), []);
|
|
5438
5443
|
|
|
5439
5444
|
for (let i = 0; i < rows.length; ++i) {
|
|
5440
5445
|
(0, duff_1.duffEach)(rows[i].children, (col, i) => {
|
|
@@ -5492,7 +5497,7 @@ function fillFirstLine(ns) {
|
|
|
5492
5497
|
exports.fillFirstLine = fillFirstLine;
|
|
5493
5498
|
|
|
5494
5499
|
function format(el) {
|
|
5495
|
-
if (el.firstElementChild?.firstElementChild?.
|
|
5500
|
+
if (el.firstElementChild?.firstElementChild?.className === 'checkbox') {
|
|
5496
5501
|
el.setAttribute('class', 'checklist');
|
|
5497
5502
|
}
|
|
5498
5503
|
|
|
@@ -5707,7 +5712,7 @@ exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.surround)('((
|
|
|
5707
5712
|
delimiters: global_1.undefined
|
|
5708
5713
|
}, (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ')', [[/^\\?\n/, 9], [')', 2], ['))', 6]])), ')')))), '))', false, ([, ns], rest) => [[(0, dom_1.html)('sup', {
|
|
5709
5714
|
class: 'annotation'
|
|
5710
|
-
}, [(0, dom_1.html)('span', (0, visibility_1.trimNode)((0, dom_1.defrag)(ns)))])], rest], ([, ns, rest], next) => next[0] === ')' ? global_1.undefined : (0, link_1.optimize)('((', ns, rest, next)));
|
|
5715
|
+
}, [(0, dom_1.html)('span', (0, visibility_1.trimNode)((0, dom_1.defrag)(ns)))])], rest], ([, ns, rest], next, context) => next[0] === ')' ? global_1.undefined : (0, link_1.optimize)('((', ns, rest, next, context)));
|
|
5711
5716
|
|
|
5712
5717
|
/***/ }),
|
|
5713
5718
|
|
|
@@ -6514,11 +6519,11 @@ const attrspecs = {
|
|
|
6514
6519
|
};
|
|
6515
6520
|
global_1.Object.setPrototypeOf(attrspecs, null);
|
|
6516
6521
|
global_1.Object.values(attrspecs).forEach(o => global_1.Object.setPrototypeOf(o, null));
|
|
6517
|
-
exports.html = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('<', (0, combinator_1.validate)(/^<[a-z]+(?=[^\S\n]|>)
|
|
6522
|
+
exports.html = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('<', (0, combinator_1.validate)(/^<[a-z]+(?=[^\S\n]|>)/i, (0, combinator_1.syntax)(0
|
|
6518
6523
|
/* Syntax.none */
|
|
6519
|
-
, 5, 1, (0, combinator_1.union)([(0, combinator_1.focus)(/^<wbr[^\S\n]
|
|
6520
|
-
/^<(?:area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)(?=[^\S\n]|>)
|
|
6521
|
-
exports.attribute = (0, combinator_1.union)([(0, source_1.str)(/^[^\S\n]+[a-z]+(?:-[a-z]+)*(?:="(?:\\[^\n]|[^\\\n"])*")?(?=[^\S\n]|>)/)]); // https://developer.mozilla.org/en-US/docs/Web/HTML/Element
|
|
6524
|
+
, 5, 1, (0, combinator_1.union)([(0, combinator_1.focus)(/^<wbr[^\S\n]*>/i, () => [[(0, dom_1.html)('wbr')], '']), (0, combinator_1.surround)( // https://html.spec.whatwg.org/multipage/syntax.html#void-elements
|
|
6525
|
+
(0, source_1.str)(/^<(?:area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)(?=[^\S\n]|>)/i), (0, combinator_1.some)((0, combinator_1.union)([exports.attribute])), (0, source_1.str)(/^[^\S\n]*>/), true, ([as, bs = [], cs], rest) => [[elem(as[0].slice(1), (0, array_1.push)((0, array_1.unshift)(as, bs), cs), [], [])], rest]), (0, combinator_1.match)(new RegExp(String.raw`^<(${TAGS.join('|')})(?=[^\S\n]|>)`), (0, memoize_1.memoize)(([, tag]) => (0, combinator_1.surround)((0, combinator_1.surround)((0, source_1.str)(`<${tag}`), (0, combinator_1.some)(exports.attribute), (0, source_1.str)(/^[^\S\n]*>/), true), (0, combinator_1.subsequence)([(0, combinator_1.focus)(/^[^\S\n]*\n/, (0, combinator_1.some)(inline_1.inline)), (0, combinator_1.some)((0, combinator_1.open)(/^\n?/, (0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('\n', `</${tag}>`), [[(0, visibility_1.blankWith)('\n', `</${tag}>`), 5]]), true))]), (0, source_1.str)(`</${tag}>`), true, ([as, bs = [], cs], rest) => [[elem(tag, as, bs, cs)], rest], ([as, bs = []], rest) => [[elem(tag, as, bs, [])], rest]), ([, tag]) => TAGS.indexOf(tag), [])), (0, combinator_1.match)(/^<([a-z]+)(?=[^\S\n]|>)/i, (0, memoize_1.memoize)(([, tag]) => (0, combinator_1.surround)((0, combinator_1.surround)((0, source_1.str)(`<${tag}`), (0, combinator_1.some)(exports.attribute), (0, source_1.str)(/^[^\S\n]*>/), true), (0, combinator_1.subsequence)([(0, combinator_1.focus)(/^[^\S\n]*\n/, (0, combinator_1.some)(inline_1.inline)), (0, combinator_1.some)(inline_1.inline, `</${tag}>`, [[`</${tag}>`, 5]])]), (0, source_1.str)(`</${tag}>`), true, ([as, bs = [], cs], rest) => [[elem(tag, as, bs, cs)], rest], ([as, bs = []], rest) => [[elem(tag, as, bs, [])], rest]), ([, tag]) => tag, new cache_1.Cache(10000)))])))));
|
|
6526
|
+
exports.attribute = (0, combinator_1.union)([(0, source_1.str)(/^[^\S\n]+[a-z]+(?:-[a-z]+)*(?:="(?:\\[^\n]|[^\\\n"])*")?(?=[^\S\n]|>)/i)]); // https://developer.mozilla.org/en-US/docs/Web/HTML/Element
|
|
6522
6527
|
// [...document.querySelectorAll('tbody > tr > td:first-child')].map(el => el.textContent.slice(1, -1))
|
|
6523
6528
|
|
|
6524
6529
|
const TAGS = global_1.Object.freeze(["html", "base", "head", "link", "meta", "style", "title", "body", "address", "article", "aside", "footer", "header", "h1", "h2", "h3", "h4", "h5", "h6", "main", "nav", "section", "blockquote", "dd", "div", "dl", "dt", "figcaption", "figure", "hr", "li", "menu", "ol", "p", "pre", "ul", "a", "abbr", "b", "bdi", "bdo", "br", "cite", "code", "data", "dfn", "em", "i", "kbd", "mark", "q", "rp", "rt", "ruby", "s", "samp", "small", "span", "strong", "sub", "sup", "time", "u", "var", "wbr", "area", "audio", "img", "map", "track", "video", "embed", "iframe", "object", "picture", "portal", "source", "svg", "math", "canvas", "noscript", "script", "del", "ins", "caption", "col", "colgroup", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "button", "datalist", "fieldset", "form", "input", "label", "legend", "meter", "optgroup", "option", "output", "progress", "select", "textarea", "details", "dialog", "summary", "slot", "template", "acronym", "applet", "basefont", "bgsound", "big", "blink", "center", "content", "dir", "font", "frame", "frameset", "hgroup", "image", "keygen", "marquee", "menuitem", "nobr", "noembed", "noframes", "param", "plaintext", "rb", "rtc", "shadow", "spacer", "strike", "tt", "xmp"]);
|
|
@@ -6660,6 +6665,8 @@ const html_1 = __webpack_require__(5994);
|
|
|
6660
6665
|
|
|
6661
6666
|
const autolink_1 = __webpack_require__(6578);
|
|
6662
6667
|
|
|
6668
|
+
const bracket_1 = __webpack_require__(5196);
|
|
6669
|
+
|
|
6663
6670
|
const source_1 = __webpack_require__(6743);
|
|
6664
6671
|
|
|
6665
6672
|
const visibility_1 = __webpack_require__(7618);
|
|
@@ -6692,7 +6699,7 @@ exports.link = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['[', '{'
|
|
|
6692
6699
|
/* State.media */
|
|
6693
6700
|
| 1
|
|
6694
6701
|
/* State.autolink */
|
|
6695
|
-
, (0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 9], [']', 2]])), ']', true, global_1.undefined, ([, ns = [], rest], next) => next[0] === ']' ? global_1.undefined : optimize('[', ns, rest, next))]))), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))], nodes => nodes[0][0] !== ''), ([as, bs = []]) => bs[0] === '\r' && bs.shift() ? [as, bs] : as[0] === '\r' && as.shift() ? [[], as] : [as, []]))), ([content, params], rest, context) => {
|
|
6702
|
+
, (0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 9], [']', 2]])), ']', true, global_1.undefined, ([, ns = [], rest], next, context) => next[0] === ']' ? global_1.undefined : optimize('[', ns, rest, next, context))]))), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))], nodes => nodes[0][0] !== ''), ([as, bs = []]) => bs[0] === '\r' && bs.shift() ? [as, bs] : as[0] === '\r' && as.shift() ? [[], as] : [as, []]))), ([content, params], rest, context) => {
|
|
6696
6703
|
if (content[0] === '') return [content, rest];
|
|
6697
6704
|
if (params.length === 0) return;
|
|
6698
6705
|
if (content.length !== 0 && (0, visibility_1.trimNode)(content).length === 0) return;
|
|
@@ -6705,7 +6712,7 @@ exports.link = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['[', '{'
|
|
|
6705
6712
|
|
|
6706
6713
|
const INSECURE_URI = params.shift();
|
|
6707
6714
|
const el = elem(INSECURE_URI, (0, dom_1.defrag)(content), new url_1.ReadonlyURL(resolve(INSECURE_URI, context.host ?? global_1.location, context.url ?? context.host ?? global_1.location), context.host?.href || global_1.location.href), context.host?.origin || global_1.location.origin);
|
|
6708
|
-
if (el.
|
|
6715
|
+
if (el.className === 'invalid') return [[el], rest];
|
|
6709
6716
|
return [[(0, dom_1.define)(el, (0, html_1.attributes)('link', [], optspec, params))], rest];
|
|
6710
6717
|
})));
|
|
6711
6718
|
exports.textlink = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['[', '{'], (0, combinator_1.bind)((0, combinator_1.creation)(10, (0, combinator_1.precedence)(2, (0, combinator_1.reverse)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.some)((0, combinator_1.union)([source_1.unescsource]), ']'), ']')), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])))), ([params, content = []], rest, context) => {
|
|
@@ -6792,8 +6799,20 @@ function decode(uri) {
|
|
|
6792
6799
|
}
|
|
6793
6800
|
}
|
|
6794
6801
|
|
|
6795
|
-
function optimize(opener, ns, rest, next) {
|
|
6796
|
-
if (next[+(next[0] === '\\')] === '\n')
|
|
6802
|
+
function optimize(opener, ns, rest, next, context) {
|
|
6803
|
+
if (next[+(next[0] === '\\')] === '\n') {
|
|
6804
|
+
if (rest[0] !== opener[0]) return;
|
|
6805
|
+
const delimiters = context.delimiters;
|
|
6806
|
+
delimiters?.push({
|
|
6807
|
+
signature: '!\n',
|
|
6808
|
+
matcher: source => !/^\\?\n/.test(source) && global_1.undefined,
|
|
6809
|
+
precedence: 9
|
|
6810
|
+
});
|
|
6811
|
+
const paired = (0, parser_1.eval)((0, combinator_1.state)(~0, bracket_1.bracket)(rest[0] + rest.slice(rest.search(`[^${rest[0]}]|$`)), context), [])[0] !== '';
|
|
6812
|
+
delimiters?.pop();
|
|
6813
|
+
if (paired) return;
|
|
6814
|
+
}
|
|
6815
|
+
|
|
6797
6816
|
let count = 0;
|
|
6798
6817
|
|
|
6799
6818
|
for (let i = 0; i < ns.length - 1; i += 2) {
|
|
@@ -7025,7 +7044,7 @@ exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.surround)('[['
|
|
|
7025
7044
|
/* State.media */
|
|
7026
7045
|
, (0, visibility_1.startLoose)((0, combinator_1.context)({
|
|
7027
7046
|
delimiters: global_1.undefined
|
|
7028
|
-
}, (0, combinator_1.subsequence)([abbr, (0, combinator_1.open)((0, source_1.stropt)(/^(?=\^)/), (0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]])), (0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]])])), ']')))), ']]', false, ([, ns], rest) => [[(0, dom_1.html)('sup', attributes(ns), [(0, dom_1.html)('span', (0, visibility_1.trimNode)((0, dom_1.defrag)(ns)))])], rest], ([, ns, rest], next) => next[0] === ']' ? global_1.undefined : (0, link_1.optimize)('[[', ns, rest, next)));
|
|
7047
|
+
}, (0, combinator_1.subsequence)([abbr, (0, combinator_1.open)((0, source_1.stropt)(/^(?=\^)/), (0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]])), (0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]])])), ']')))), ']]', false, ([, ns], rest) => [[(0, dom_1.html)('sup', attributes(ns), [(0, dom_1.html)('span', (0, visibility_1.trimNode)((0, dom_1.defrag)(ns)))])], rest], ([, ns, rest], next, context) => next[0] === ']' ? global_1.undefined : (0, link_1.optimize)('[[', ns, rest, next, context)));
|
|
7029
7048
|
const abbr = (0, combinator_1.creation)((0, combinator_1.bind)((0, combinator_1.surround)('^', (0, combinator_1.union)([(0, source_1.str)(/^(?![0-9]+\s?[|\]])[0-9A-Za-z]+(?:(?:-|(?=\W)(?!'\d)'?(?!\.\d)\.?(?!,\S),? ?)[0-9A-Za-z]+)*(?:-|'?\.?,? ?)?/)]), /^\|?(?=]])|^\|[^\S\n]*/), ([source], rest) => [[(0, dom_1.html)('abbr', source)], rest.replace(visibility_1.regBlankStart, '')]));
|
|
7030
7049
|
|
|
7031
7050
|
function attributes(ns) {
|
|
@@ -7226,7 +7245,7 @@ exports.template = (0, combinator_1.lazy)(() => (0, combinator_1.surround)('{{',
|
|
|
7226
7245
|
/* Syntax.none */
|
|
7227
7246
|
, 2, 1, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), '}')), '}}', true, ([, ns = []], rest) => [[(0, dom_1.html)('span', {
|
|
7228
7247
|
class: 'template'
|
|
7229
|
-
}, `{{${ns.join('').replace(/\x1B/g, '')}}}`)], rest], ([, ns = [], rest], next) => next[0] === '}' ? global_1.undefined : (0, link_1.optimize)('{{', ns, rest, next)));
|
|
7248
|
+
}, `{{${ns.join('').replace(/\x1B/g, '')}}}`)], rest], ([, ns = [], rest], next, context) => next[0] === '}' ? global_1.undefined : (0, link_1.optimize)('{{', ns, rest, next, context)));
|
|
7230
7249
|
const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.creation)((0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ')'), (0, source_1.str)(')'), true, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ']'), (0, source_1.str)(']'), true, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), '}'), (0, source_1.str)('}'), true, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(8, (0, combinator_1.some)(source_1.escsource, /^"|^\\?\n/)), (0, source_1.str)('"'), true)])));
|
|
7231
7250
|
|
|
7232
7251
|
/***/ }),
|
package/markdown.d.ts
CHANGED
|
@@ -963,15 +963,15 @@ export namespace MarkdownParser {
|
|
|
963
963
|
// <bdi>abc</bdi>
|
|
964
964
|
Inline<'html'>,
|
|
965
965
|
Parser<HTMLElement | string, Context, [
|
|
966
|
-
HTMLParser.
|
|
967
|
-
HTMLParser.
|
|
966
|
+
HTMLParser.VoidTagParser,
|
|
967
|
+
HTMLParser.VoidTagParser,
|
|
968
968
|
HTMLParser.TagParser,
|
|
969
969
|
HTMLParser.TagParser,
|
|
970
970
|
]> {
|
|
971
971
|
}
|
|
972
972
|
export namespace HTMLParser {
|
|
973
|
-
export interface
|
|
974
|
-
Inline<'html/
|
|
973
|
+
export interface VoidTagParser extends
|
|
974
|
+
Inline<'html/voidtag'>,
|
|
975
975
|
Parser<HTMLElement | string, Context, [
|
|
976
976
|
AttributeParser,
|
|
977
977
|
]> {
|
package/package.json
CHANGED
|
@@ -57,12 +57,15 @@ export class Delimiters {
|
|
|
57
57
|
public match(source: string, precedence = 1): boolean {
|
|
58
58
|
const { matchers } = this;
|
|
59
59
|
for (let i = 0; i < matchers.length; ++i) {
|
|
60
|
-
|
|
60
|
+
const matcher = matchers[i];
|
|
61
|
+
if (precedence >= matcher[2]) continue;
|
|
62
|
+
switch (matcher[3](source)) {
|
|
61
63
|
case true:
|
|
62
|
-
|
|
63
|
-
continue;
|
|
64
|
+
return true;
|
|
64
65
|
case false:
|
|
65
66
|
return false;
|
|
67
|
+
default:
|
|
68
|
+
continue;
|
|
66
69
|
}
|
|
67
70
|
}
|
|
68
71
|
return false;
|
|
@@ -228,7 +228,7 @@ function format(rows: Tree<RowParser>[]): HTMLTableSectionElement[] {
|
|
|
228
228
|
: cells[j];
|
|
229
229
|
const isHeadCell = cell.tagName === 'TH';
|
|
230
230
|
heads |= BigInt(isHeadCell) << jn;
|
|
231
|
-
highlights |= BigInt(cell.
|
|
231
|
+
highlights |= BigInt(cell.className === 'highlight') << jn;
|
|
232
232
|
hasDataCell ||= !isHeadCell;
|
|
233
233
|
if (isHeadCell && !hasDataCell) {
|
|
234
234
|
lHeadCellIdx = jn;
|
|
@@ -115,7 +115,7 @@ function initial(type: string): RegExp {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
function format(el: HTMLOListElement, type: string, form: string): HTMLOListElement {
|
|
118
|
-
if (el.firstElementChild?.firstElementChild?.
|
|
118
|
+
if (el.firstElementChild?.firstElementChild?.className === 'checkbox') {
|
|
119
119
|
el.setAttribute('class', 'checklist');
|
|
120
120
|
}
|
|
121
121
|
define(el, {
|
|
@@ -57,7 +57,7 @@ const qblock: ReplyParser.QuoteParser.BlockParser = (source, context) => {
|
|
|
57
57
|
++i;
|
|
58
58
|
continue;
|
|
59
59
|
}
|
|
60
|
-
if (child.
|
|
60
|
+
if (child.className === 'cite' || child.classList.contains('quote')) {
|
|
61
61
|
context.resources && (context.resources.clock -= child.childNodes.length);
|
|
62
62
|
nodes.splice(i, 1, ...child.childNodes as NodeListOf<HTMLElement>);
|
|
63
63
|
--i;
|
|
@@ -61,7 +61,7 @@ const data: CellParser.DataParser = creation(fmap(
|
|
|
61
61
|
ns => [html('td', trimNode(defrag(ns)))]));
|
|
62
62
|
|
|
63
63
|
function format(rows: HTMLTableRowElement[]): HTMLTableRowElement[] {
|
|
64
|
-
const aligns = rows[0].
|
|
64
|
+
const aligns = rows[0].className === 'invalid'
|
|
65
65
|
? []
|
|
66
66
|
: duffReduce(rows.shift()!.children, (acc, el) => push(acc, [el.textContent!]), [] as string[]);
|
|
67
67
|
for (let i = 0; i < rows.length; ++i) {
|
|
@@ -41,7 +41,7 @@ export function fillFirstLine(ns: (HTMLElement | string)[]): (HTMLElement | stri
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
function format(el: HTMLUListElement): HTMLUListElement {
|
|
44
|
-
if (el.firstElementChild?.firstElementChild?.
|
|
44
|
+
if (el.firstElementChild?.firstElementChild?.className === 'checkbox') {
|
|
45
45
|
el.setAttribute('class', 'checklist');
|
|
46
46
|
}
|
|
47
47
|
return el;
|
|
@@ -18,4 +18,4 @@ export const annotation: AnnotationParser = lazy(() => surround(
|
|
|
18
18
|
'))',
|
|
19
19
|
false,
|
|
20
20
|
([, ns], rest) => [[html('sup', { class: 'annotation' }, [html('span', trimNode(defrag(ns)))])], rest],
|
|
21
|
-
([, ns, rest], next) => next[0] === ')' ? undefined : optimize('((', ns, rest, next)));
|
|
21
|
+
([, ns, rest], next, context) => next[0] === ')' ? undefined : optimize('((', ns, rest, next, context)));
|
|
@@ -21,10 +21,10 @@ describe('Unit: parser/inline/html', () => {
|
|
|
21
21
|
it('invalid', () => {
|
|
22
22
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
23
23
|
assert.deepStrictEqual(inspect(parser('<0>')), undefined);
|
|
24
|
-
assert.deepStrictEqual(inspect(parser('<aT>')),
|
|
24
|
+
assert.deepStrictEqual(inspect(parser('<aT>')), [['<span class="invalid"><aT></span>'], '']);
|
|
25
25
|
assert.deepStrictEqual(inspect(parser('<a,b>')), undefined);
|
|
26
26
|
assert.deepStrictEqual(inspect(parser('<a, b>')), undefined);
|
|
27
|
-
assert.deepStrictEqual(inspect(parser('<T>')),
|
|
27
|
+
assert.deepStrictEqual(inspect(parser('<T>')), [['<span class="invalid"><T></span>'], '']);
|
|
28
28
|
assert.deepStrictEqual(inspect(parser('<bdi>')), [['<span class="invalid"><bdi></span>'], '']);
|
|
29
29
|
assert.deepStrictEqual(inspect(parser('<bdi>z')), [['<span class="invalid"><bdi>z</span>'], '']);
|
|
30
30
|
assert.deepStrictEqual(inspect(parser('<bdi></bdi>')), [['<span class="invalid"><bdi></bdi></span>'], '']);
|
|
@@ -39,8 +39,8 @@ describe('Unit: parser/inline/html', () => {
|
|
|
39
39
|
assert.deepStrictEqual(inspect(parser('<bdi>\\\na</bdi>')), [['<span class="invalid"><bdi><span class="linebreak"> </span>a</bdi></span>'], '']);
|
|
40
40
|
assert.deepStrictEqual(inspect(parser('<bdi>a')), [['<span class="invalid"><bdi>a</span>'], '']);
|
|
41
41
|
assert.deepStrictEqual(inspect(parser('<bdi>a</BDO>')), [['<span class="invalid"><bdi>a</BDO></span>'], '']);
|
|
42
|
-
assert.deepStrictEqual(inspect(parser('<BDI>a</BDI>')),
|
|
43
|
-
assert.deepStrictEqual(inspect(parser('<BDI>a</bdo>')),
|
|
42
|
+
assert.deepStrictEqual(inspect(parser('<BDI>a</BDI>')), [['<span class="invalid"><BDI>a</BDI></span>'], '']);
|
|
43
|
+
assert.deepStrictEqual(inspect(parser('<BDI>a</bdo>')), [['<span class="invalid"><BDI>a</bdo></span>'], '']);
|
|
44
44
|
assert.deepStrictEqual(inspect(parser('</bdi>')), undefined);
|
|
45
45
|
assert.deepStrictEqual(inspect(parser('<bdi/>')), undefined);
|
|
46
46
|
assert.deepStrictEqual(inspect(parser('<b><b><b>a</b></b></b>')), [['<span class="invalid"><b><span class="invalid"><b><span class="invalid"><b>a</b></span></b></span></b></span>'], '']);
|
|
@@ -87,9 +87,9 @@ describe('Unit: parser/inline/html', () => {
|
|
|
87
87
|
assert.deepStrictEqual(inspect(parser('<a>')), [['<span class="invalid"><a></span>'], '']);
|
|
88
88
|
assert.deepStrictEqual(inspect(parser('<bdi><a>a</a></bdi>')), [['<bdi><span class="invalid"><a>a</a></span></bdi>'], '']);
|
|
89
89
|
assert.deepStrictEqual(inspect(parser('<bdi>a<a>b</a>c</bdi>')), [['<bdi>a<span class="invalid"><a>b</a></span>c</bdi>'], '']);
|
|
90
|
-
assert.deepStrictEqual(inspect(parser('<img>')), [['<img'], '
|
|
91
|
-
assert.deepStrictEqual(inspect(parser('<bdi><img></bdi>')), [['<bdi><img></bdi>'], '']);
|
|
92
|
-
assert.deepStrictEqual(inspect(parser('<img />')),
|
|
90
|
+
assert.deepStrictEqual(inspect(parser('<img>')), [['<span class="invalid"><img></span>'], '']);
|
|
91
|
+
assert.deepStrictEqual(inspect(parser('<bdi><img></bdi>')), [['<bdi><span class="invalid"><img></span></bdi>'], '']);
|
|
92
|
+
assert.deepStrictEqual(inspect(parser('<img />')), undefined);
|
|
93
93
|
assert.deepStrictEqual(inspect(parser('<bdi><img /></bdi>')), [['<bdi><img /></bdi>'], '']);
|
|
94
94
|
});
|
|
95
95
|
|
|
@@ -100,15 +100,15 @@ describe('Unit: parser/inline/html', () => {
|
|
|
100
100
|
assert.deepStrictEqual(inspect(parser('<bdi >a</bdi>')), [['<bdi>a</bdi>'], '']);
|
|
101
101
|
assert.deepStrictEqual(inspect(parser('<bdi __proto__>a</bdi>')), undefined);
|
|
102
102
|
assert.deepStrictEqual(inspect(parser('<bdi constructor>a</bdi>')), [['<span class="invalid"><bdi constructor>a</bdi></span>'], '']);
|
|
103
|
-
assert.deepStrictEqual(inspect(parser('<bdi toString>a</bdi>')),
|
|
104
|
-
assert.deepStrictEqual(inspect(parser('<bdi X>a</bdi>')),
|
|
103
|
+
assert.deepStrictEqual(inspect(parser('<bdi toString>a</bdi>')), [['<span class="invalid"><bdi toString>a</bdi></span>'], '']);
|
|
104
|
+
assert.deepStrictEqual(inspect(parser('<bdi X>a</bdi>')), [['<span class="invalid"><bdi X>a</bdi></span>'], '']);
|
|
105
105
|
assert.deepStrictEqual(inspect(parser('<bdi x>a</bdi>')), [['<span class="invalid"><bdi x>a</bdi></span>'], '']);
|
|
106
106
|
assert.deepStrictEqual(inspect(parser('<bdo>a</bdo>')), [['<span class="invalid"><bdo>a</bdo></span>'], '']);
|
|
107
107
|
assert.deepStrictEqual(inspect(parser('<bdo >a</bdo>')), [['<span class="invalid"><bdo >a</bdo></span>'], '']);
|
|
108
108
|
assert.deepStrictEqual(inspect(parser('<bdo __proto__>a</bdo>')), undefined);
|
|
109
109
|
assert.deepStrictEqual(inspect(parser('<bdo constructor>a</bdo>')), [['<span class="invalid"><bdo constructor>a</bdo></span>'], '']);
|
|
110
|
-
assert.deepStrictEqual(inspect(parser('<bdo toString>a</bdo>')),
|
|
111
|
-
assert.deepStrictEqual(inspect(parser('<bdo X>a</bdo>')),
|
|
110
|
+
assert.deepStrictEqual(inspect(parser('<bdo toString>a</bdo>')), [['<span class="invalid"><bdo toString>a</bdo></span>'], '']);
|
|
111
|
+
assert.deepStrictEqual(inspect(parser('<bdo X>a</bdo>')), [['<span class="invalid"><bdo X>a</bdo></span>'], '']);
|
|
112
112
|
assert.deepStrictEqual(inspect(parser('<bdo x>a</bdo>')), [['<span class="invalid"><bdo x>a</bdo></span>'], '']);
|
|
113
113
|
assert.deepStrictEqual(inspect(parser('<bdo dir>a</bdo>')), [['<span class="invalid"><bdo dir>a</bdo></span>'], '']);
|
|
114
114
|
assert.deepStrictEqual(inspect(parser('<bdo dir=>a</bdo>')), undefined);
|
|
@@ -116,16 +116,16 @@ describe('Unit: parser/inline/html', () => {
|
|
|
116
116
|
assert.deepStrictEqual(inspect(parser('<bdo dir=">a</bdo>')), undefined);
|
|
117
117
|
assert.deepStrictEqual(inspect(parser('<bdo dir="">a</bdo>')), [['<span class="invalid"><bdo dir="">a</bdo></span>'], '']);
|
|
118
118
|
assert.deepStrictEqual(inspect(parser('<bdo dir="rtl" dir="rtl">a</bdo>')), [['<span class="invalid"><bdo dir="rtl" dir="rtl">a</bdo></span>'], '']);
|
|
119
|
-
assert.deepStrictEqual(inspect(parser('<bdo diR="rtl">a</bdo>')),
|
|
119
|
+
assert.deepStrictEqual(inspect(parser('<bdo diR="rtl">a</bdo>')), [['<span class="invalid"><bdo diR="rtl">a</bdo></span>'], '']);
|
|
120
120
|
assert.deepStrictEqual(inspect(parser('<bdo dir="rtl">a</bdo>')), [['<bdo dir="rtl">a</bdo>'], '']);
|
|
121
121
|
assert.deepStrictEqual(inspect(parser('<bdo dir="rtl" >a</bdo>')), [['<bdo dir="rtl">a</bdo>'], '']);
|
|
122
122
|
assert.deepStrictEqual(inspect(parser('<bdo dir="rtl" >a</bdo>')), [['<bdo dir="rtl">a</bdo>'], '']);
|
|
123
123
|
assert.deepStrictEqual(inspect(parser('<bdo dir="rtl">a</bdo>')), [['<bdo dir="rtl">a</bdo>'], '']);
|
|
124
124
|
assert.deepStrictEqual(inspect(parser('<wbr\n>')), undefined);
|
|
125
125
|
assert.deepStrictEqual(inspect(parser('<wbr >')), [['<wbr>'], '']);
|
|
126
|
-
assert.deepStrictEqual(inspect(parser('<wbr constructor>')), [['<wbr'], '
|
|
127
|
-
assert.deepStrictEqual(inspect(parser('<wbr X>')), [['<wbr'], '
|
|
128
|
-
assert.deepStrictEqual(inspect(parser('<wbr x>')), [['<wbr'], '
|
|
126
|
+
assert.deepStrictEqual(inspect(parser('<wbr constructor>')), [['<span class="invalid"><wbr constructor></span>'], '']);
|
|
127
|
+
assert.deepStrictEqual(inspect(parser('<wbr X>')), [['<span class="invalid"><wbr X></span>'], '']);
|
|
128
|
+
assert.deepStrictEqual(inspect(parser('<wbr x>')), [['<span class="invalid"><wbr x></span>'], '']);
|
|
129
129
|
});
|
|
130
130
|
|
|
131
131
|
});
|
|
@@ -19,14 +19,15 @@ const attrspecs = {
|
|
|
19
19
|
Object.setPrototypeOf(attrspecs, null);
|
|
20
20
|
Object.values(attrspecs).forEach(o => Object.setPrototypeOf(o, null));
|
|
21
21
|
|
|
22
|
-
export const html: HTMLParser = lazy(() => validate('<', validate(/^<[a-z]+(?=[^\S\n]|>)
|
|
22
|
+
export const html: HTMLParser = lazy(() => validate('<', validate(/^<[a-z]+(?=[^\S\n]|>)/i, syntax(Syntax.none, 5, 1, union([
|
|
23
23
|
focus(
|
|
24
|
-
/^<wbr[^\S\n]
|
|
24
|
+
/^<wbr[^\S\n]*>/i,
|
|
25
25
|
() => [[h('wbr')], '']),
|
|
26
|
-
|
|
26
|
+
surround(
|
|
27
27
|
// https://html.spec.whatwg.org/multipage/syntax.html#void-elements
|
|
28
|
-
/^<(?:area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)(?=[^\S\n]|>)
|
|
29
|
-
|
|
28
|
+
str(/^<(?:area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)(?=[^\S\n]|>)/i), some(union([attribute])), str(/^[^\S\n]*>/), true,
|
|
29
|
+
([as, bs = [], cs], rest) =>
|
|
30
|
+
[[elem(as[0].slice(1), push(unshift(as, bs), cs), [], [])], rest]),
|
|
30
31
|
match(
|
|
31
32
|
new RegExp(String.raw`^<(${TAGS.join('|')})(?=[^\S\n]|>)`),
|
|
32
33
|
memoize(
|
|
@@ -44,7 +45,7 @@ export const html: HTMLParser = lazy(() => validate('<', validate(/^<[a-z]+(?=[^
|
|
|
44
45
|
[[elem(tag, as, bs, [])], rest]),
|
|
45
46
|
([, tag]) => TAGS.indexOf(tag), [])),
|
|
46
47
|
match(
|
|
47
|
-
/^<([a-z]+)(?=[^\S\n]|>)
|
|
48
|
+
/^<([a-z]+)(?=[^\S\n]|>)/i,
|
|
48
49
|
memoize(
|
|
49
50
|
([, tag]) =>
|
|
50
51
|
surround<HTMLParser.TagParser, string>(surround(
|
|
@@ -63,7 +64,7 @@ export const html: HTMLParser = lazy(() => validate('<', validate(/^<[a-z]+(?=[^
|
|
|
63
64
|
])))));
|
|
64
65
|
|
|
65
66
|
export const attribute: HTMLParser.AttributeParser = union([
|
|
66
|
-
str(/^[^\S\n]+[a-z]+(?:-[a-z]+)*(?:="(?:\\[^\n]|[^\\\n"])*")?(?=[^\S\n]|>)/),
|
|
67
|
+
str(/^[^\S\n]+[a-z]+(?:-[a-z]+)*(?:="(?:\\[^\n]|[^\\\n"])*")?(?=[^\S\n]|>)/i),
|
|
67
68
|
]);
|
|
68
69
|
|
|
69
70
|
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { undefined, location, encodeURI, decodeURI, Location } from 'spica/global';
|
|
2
|
+
import { MarkdownParser } from '../../../markdown';
|
|
2
3
|
import { LinkParser, TextLinkParser } from '../inline';
|
|
3
4
|
import { Result, eval, exec } from '../../combinator/data/parser';
|
|
4
5
|
import { union, inits, tails, subsequence, some, constraint, syntax, creation, precedence, state, validate, surround, open, dup, reverse, lazy, fmap, bind } from '../../combinator';
|
|
5
6
|
import { inline, media, shortmedia } from '../inline';
|
|
6
7
|
import { attributes } from './html';
|
|
7
8
|
import { autolink } from '../autolink';
|
|
9
|
+
import { bracket } from './bracket';
|
|
8
10
|
import { unescsource, str } from '../source';
|
|
9
11
|
import { Syntax, State } from '../context';
|
|
10
12
|
import { trimNode } from '../visibility';
|
|
@@ -32,7 +34,7 @@ export const link: LinkParser = lazy(() => validate(['[', '{'], bind(
|
|
|
32
34
|
']',
|
|
33
35
|
true,
|
|
34
36
|
undefined,
|
|
35
|
-
([, ns = [], rest], next) => next[0] === ']' ? undefined : optimize('[', ns, rest, next)),
|
|
37
|
+
([, ns = [], rest], next, context) => next[0] === ']' ? undefined : optimize('[', ns, rest, next, context)),
|
|
36
38
|
]))),
|
|
37
39
|
dup(surround(/^{(?![{}])/, inits([uri, some(option)]), /^[^\S\n]*}/)),
|
|
38
40
|
], nodes => nodes[0][0] !== ''),
|
|
@@ -59,7 +61,7 @@ export const link: LinkParser = lazy(() => validate(['[', '{'], bind(
|
|
|
59
61
|
resolve(INSECURE_URI, context.host ?? location, context.url ?? context.host ?? location),
|
|
60
62
|
context.host?.href || location.href),
|
|
61
63
|
context.host?.origin || location.origin);
|
|
62
|
-
if (el.
|
|
64
|
+
if (el.className === 'invalid') return [[el], rest];
|
|
63
65
|
assert(el.classList.length === 0);
|
|
64
66
|
return [[define(el, attributes('link', [], optspec, params))], rest];
|
|
65
67
|
})));
|
|
@@ -85,7 +87,7 @@ export const textlink: TextLinkParser = lazy(() => validate(['[', '{'], bind(
|
|
|
85
87
|
resolve(INSECURE_URI, context.host ?? location, context.url ?? context.host ?? location),
|
|
86
88
|
context.host?.href || location.href),
|
|
87
89
|
context.host?.origin || location.origin);
|
|
88
|
-
assert(
|
|
90
|
+
assert(el.className !== 'invalid');
|
|
89
91
|
assert(el.classList.length === 0);
|
|
90
92
|
return [[define(el, attributes('link', [], optspec, params))], rest];
|
|
91
93
|
})));
|
|
@@ -192,8 +194,19 @@ function decode(uri: string): string {
|
|
|
192
194
|
}
|
|
193
195
|
}
|
|
194
196
|
|
|
195
|
-
export function optimize(opener: string, ns: readonly (string | HTMLElement)[], rest: string, next: string): Result<string> {
|
|
196
|
-
if (next[+(next[0] === '\\')] === '\n')
|
|
197
|
+
export function optimize(opener: string, ns: readonly (string | HTMLElement)[], rest: string, next: string, context: MarkdownParser.Context): Result<string> {
|
|
198
|
+
if (next[+(next[0] === '\\')] === '\n') {
|
|
199
|
+
if (rest[0] !== opener[0]) return;
|
|
200
|
+
const delimiters = context.delimiters;
|
|
201
|
+
delimiters?.push({
|
|
202
|
+
signature: '!\n',
|
|
203
|
+
matcher: source => !/^\\?\n/.test(source) && undefined,
|
|
204
|
+
precedence: 9,
|
|
205
|
+
});
|
|
206
|
+
const paired = eval(state(~0, bracket)(rest[0] + rest.slice(rest.search(`[^${rest[0]}]|$`)), context), [])[0] !== '';
|
|
207
|
+
delimiters?.pop();
|
|
208
|
+
if (paired) return;
|
|
209
|
+
}
|
|
197
210
|
let count = 0;
|
|
198
211
|
for (let i = 0; i < ns.length - 1; i += 2) {
|
|
199
212
|
const fst = ns[i];
|
|
@@ -24,7 +24,7 @@ export const reference: ReferenceParser = lazy(() => surround(
|
|
|
24
24
|
']]',
|
|
25
25
|
false,
|
|
26
26
|
([, ns], rest) => [[html('sup', attributes(ns), [html('span', trimNode(defrag(ns)))])], rest],
|
|
27
|
-
([, ns, rest], next) => next[0] === ']' ? undefined : optimize('[[', ns, rest, next)));
|
|
27
|
+
([, ns, rest], next, context) => next[0] === ']' ? undefined : optimize('[[', ns, rest, next, context)));
|
|
28
28
|
|
|
29
29
|
const abbr: ReferenceParser.AbbrParser = creation(bind(surround(
|
|
30
30
|
'^',
|
|
@@ -10,7 +10,7 @@ import { unshift } from 'spica/array';
|
|
|
10
10
|
export const template: TemplateParser = lazy(() => surround(
|
|
11
11
|
'{{', syntax(Syntax.none, 2, 1, some(union([bracket, escsource]), '}')), '}}', true,
|
|
12
12
|
([, ns = []], rest) => [[html('span', { class: 'template' }, `{{${ns.join('').replace(/\x1B/g, '')}}}`)], rest],
|
|
13
|
-
([, ns = [], rest], next) => next[0] === '}' ? undefined : optimize('{{', ns, rest, next)));
|
|
13
|
+
([, ns = [], rest], next, context) => next[0] === '}' ? undefined : optimize('{{', ns, rest, next, context)));
|
|
14
14
|
|
|
15
15
|
const bracket: TemplateParser.BracketParser = lazy(() => creation(union([
|
|
16
16
|
surround(str('('), some(union([bracket, escsource]), ')'), str(')'), true, undefined, ([as, bs = []], rest) => [unshift(as, bs), rest]),
|