securemark 0.260.0 → 0.260.3
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 +12 -0
- package/design.md +4 -0
- package/dist/index.js +105 -97
- package/package.json +5 -5
- package/src/combinator/data/parser/context.ts +6 -4
- package/src/parser/api/parse.test.ts +13 -13
- package/src/parser/block/blockquote.ts +3 -3
- package/src/parser/block/dlist.ts +2 -2
- package/src/parser/block/extension/table.ts +3 -3
- package/src/parser/block/ilist.ts +1 -1
- package/src/parser/block/olist.ts +1 -1
- package/src/parser/block/reply/cite.ts +1 -1
- package/src/parser/block/reply/quote.ts +1 -1
- package/src/parser/block/sidefence.ts +1 -1
- package/src/parser/block/table.ts +4 -4
- package/src/parser/block/ulist.ts +2 -2
- package/src/parser/block.ts +1 -1
- package/src/parser/inline/annotation.test.ts +1 -1
- package/src/parser/inline/autolink/account.ts +2 -4
- package/src/parser/inline/autolink/anchor.ts +1 -1
- package/src/parser/inline/autolink/email.test.ts +1 -0
- package/src/parser/inline/autolink/email.ts +2 -2
- package/src/parser/inline/autolink/hashtag.ts +1 -1
- package/src/parser/inline/autolink/url.ts +3 -5
- package/src/parser/inline/autolink.ts +3 -3
- package/src/parser/inline/link.test.ts +55 -50
- package/src/parser/inline/link.ts +67 -49
- package/src/parser/inline/reference.test.ts +1 -1
- package/src/parser/inline/ruby.ts +1 -1
- package/src/parser/inline.test.ts +11 -11
- package/src/parser/source/escapable.ts +1 -1
- package/src/parser/source/str.ts +4 -4
- package/src/parser/source/text.ts +2 -3
- package/src/parser/source/unescapable.ts +1 -1
- package/src/renderer/render/media/twitter.ts +7 -1
package/CHANGELOG.md
CHANGED
package/design.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.260.
|
|
1
|
+
/*! securemark v0.260.3 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"));
|
|
@@ -2979,8 +2979,9 @@ function syntax(syntax, prec, cost, state, parser) {
|
|
|
2979
2979
|
|
|
2980
2980
|
exports.syntax = syntax;
|
|
2981
2981
|
|
|
2982
|
-
function creation(cost, parser) {
|
|
2983
|
-
if (typeof cost === 'function') return creation(1, cost);
|
|
2982
|
+
function creation(cost, recursion, parser) {
|
|
2983
|
+
if (typeof cost === 'function') return creation(1, true, cost);
|
|
2984
|
+
if (typeof recursion === 'function') return creation(cost, true, recursion);
|
|
2984
2985
|
return ({
|
|
2985
2986
|
source,
|
|
2986
2987
|
context
|
|
@@ -2991,12 +2992,12 @@ function creation(cost, parser) {
|
|
|
2991
2992
|
};
|
|
2992
2993
|
if (resources.clock <= 0) throw new Error('Too many creations');
|
|
2993
2994
|
if (resources.recursion <= 0) throw new Error('Too much recursion');
|
|
2994
|
-
--resources.recursion;
|
|
2995
|
+
recursion && --resources.recursion;
|
|
2995
2996
|
const result = parser({
|
|
2996
2997
|
source,
|
|
2997
2998
|
context
|
|
2998
2999
|
});
|
|
2999
|
-
++resources.recursion;
|
|
3000
|
+
recursion && ++resources.recursion;
|
|
3000
3001
|
|
|
3001
3002
|
if (result) {
|
|
3002
3003
|
resources.clock -= cost;
|
|
@@ -4115,7 +4116,7 @@ const dom_1 = __webpack_require__(3252);
|
|
|
4115
4116
|
|
|
4116
4117
|
const random_1 = __webpack_require__(7325);
|
|
4117
4118
|
|
|
4118
|
-
exports.block = (0, combinator_1.creation)(error((0, combinator_1.reset)({
|
|
4119
|
+
exports.block = (0, combinator_1.creation)(1, false, error((0, combinator_1.reset)({
|
|
4119
4120
|
resources: {
|
|
4120
4121
|
clock: 50 * 1000,
|
|
4121
4122
|
recursion: 20
|
|
@@ -4171,8 +4172,8 @@ const indent = (0, combinator_1.block)((0, combinator_1.open)(opener, (0, combin
|
|
|
4171
4172
|
|
|
4172
4173
|
const unindent = source => source.replace(/(^|\n)>(?:[^\S\n]|(?=>*(?:$|\s)))|\n$/g, '$1');
|
|
4173
4174
|
|
|
4174
|
-
const source = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)((0, combinator_1.union)([(0, combinator_1.rewrite)(indent, (0, combinator_1.convert)(unindent, source)), (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, (0, combinator_1.fmap)((0, combinator_1.some)(autolink_1.autolink), ns => [(0, dom_1.html)('pre', (0, dom_1.defrag)(ns))])))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
|
|
4175
|
-
const markdown = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)((0, combinator_1.union)([(0, combinator_1.rewrite)(indent, (0, combinator_1.convert)(unindent, markdown)), (0, combinator_1.creation)(99, (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, ({
|
|
4175
|
+
const source = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, combinator_1.rewrite)(indent, (0, combinator_1.convert)(unindent, source)), (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, (0, combinator_1.fmap)((0, combinator_1.some)(autolink_1.autolink), ns => [(0, dom_1.html)('pre', (0, dom_1.defrag)(ns))])))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
|
|
4176
|
+
const markdown = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, combinator_1.rewrite)(indent, (0, combinator_1.convert)(unindent, markdown)), (0, combinator_1.creation)(99, false, (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, ({
|
|
4176
4177
|
source,
|
|
4177
4178
|
context
|
|
4178
4179
|
}) => {
|
|
@@ -4303,8 +4304,8 @@ exports.dlist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, locale_
|
|
|
4303
4304
|
| 4
|
|
4304
4305
|
/* State.media */
|
|
4305
4306
|
, (0, combinator_1.some)(term)), (0, combinator_1.some)(desc)]))), es => [(0, dom_1.html)('dl', fillTrailingDescription(es))]))));
|
|
4306
|
-
const term = (0, combinator_1.creation)((0, combinator_1.line)((0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.open)(/^~[^\S\n]+(?=\S)/, (0, visibility_1.visualize)((0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))), true), ns => [(0, dom_1.html)('dt', (0, dom_1.defrag)(ns))]))));
|
|
4307
|
-
const desc = (0, combinator_1.creation)((0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)(/^:[^\S\n]+(?=\S)|/, (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.anyline, /^[~:][^\S\n]+\S/), (0, visibility_1.visualize)((0, combinator_1.trimEnd)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))))), true), ns => [(0, dom_1.html)('dd', (0, dom_1.defrag)(ns))]), false));
|
|
4307
|
+
const term = (0, combinator_1.creation)(1, false, (0, combinator_1.line)((0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.open)(/^~[^\S\n]+(?=\S)/, (0, visibility_1.visualize)((0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))), true), ns => [(0, dom_1.html)('dt', (0, dom_1.defrag)(ns))]))));
|
|
4308
|
+
const desc = (0, combinator_1.creation)(1, false, (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)(/^:[^\S\n]+(?=\S)|/, (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.anyline, /^[~:][^\S\n]+\S/), (0, visibility_1.visualize)((0, combinator_1.trimEnd)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))))), true), ns => [(0, dom_1.html)('dd', (0, dom_1.defrag)(ns))]), false));
|
|
4308
4309
|
|
|
4309
4310
|
function fillTrailingDescription(es) {
|
|
4310
4311
|
return es.length > 0 && es[es.length - 1].tagName === 'DT' ? (0, array_1.push)(es, [(0, dom_1.html)('dd')]) : es;
|
|
@@ -4890,9 +4891,9 @@ const row = (0, combinator_1.lazy)(() => (0, combinator_1.dup)((0, combinator_1.
|
|
|
4890
4891
|
const alignment = /^[-=<>]+(?:\/[-=^v]*)?(?=[^\S\n]*\n)/;
|
|
4891
4892
|
const align = (0, combinator_1.line)((0, combinator_1.fmap)((0, combinator_1.union)([(0, source_1.str)(alignment)]), ([s]) => s.split('/').map(s => s.split(''))));
|
|
4892
4893
|
const delimiter = /^[-=<>]+(?:\/[-=^v]*)?(?=[^\S\n]*\n)|^[#:](?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=\s)/;
|
|
4893
|
-
const head = (0, combinator_1.creation)((0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)((0, source_1.str)(/^#(?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=\s)/), (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.anyline, (0, combinator_1.some)(source_1.contentline, delimiter)]), (0, combinator_1.trim)((0, visibility_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))))), true), ns => [(0, dom_1.html)('th', attributes(ns.shift()), (0, dom_1.defrag)(ns))]), false));
|
|
4894
|
-
const data = (0, combinator_1.creation)((0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)((0, source_1.str)(/^:(?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=\s)/), (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.anyline, (0, combinator_1.some)(source_1.contentline, delimiter)]), (0, combinator_1.trim)((0, visibility_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))))), true), ns => [(0, dom_1.html)('td', attributes(ns.shift()), (0, dom_1.defrag)(ns))]), false));
|
|
4895
|
-
const dataline = (0, combinator_1.creation)((0, combinator_1.line)((0, combinator_1.rewrite)(source_1.contentline, (0, combinator_1.union)([(0, combinator_1.validate)(/^!+\s/, (0, combinator_1.convert)(source => `:${source}`, data)), (0, combinator_1.convert)(source => `: ${source}`, data)]))));
|
|
4894
|
+
const head = (0, combinator_1.creation)(1, false, (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)((0, source_1.str)(/^#(?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=\s)/), (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.anyline, (0, combinator_1.some)(source_1.contentline, delimiter)]), (0, combinator_1.trim)((0, visibility_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))))), true), ns => [(0, dom_1.html)('th', attributes(ns.shift()), (0, dom_1.defrag)(ns))]), false));
|
|
4895
|
+
const data = (0, combinator_1.creation)(1, false, (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)((0, source_1.str)(/^:(?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=\s)/), (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.anyline, (0, combinator_1.some)(source_1.contentline, delimiter)]), (0, combinator_1.trim)((0, visibility_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))))), true), ns => [(0, dom_1.html)('td', attributes(ns.shift()), (0, dom_1.defrag)(ns))]), false));
|
|
4896
|
+
const dataline = (0, combinator_1.creation)(1, false, (0, combinator_1.line)((0, combinator_1.rewrite)(source_1.contentline, (0, combinator_1.union)([(0, combinator_1.validate)(/^!+\s/, (0, combinator_1.convert)(source => `:${source}`, data)), (0, combinator_1.convert)(source => `: ${source}`, data)]))));
|
|
4896
4897
|
|
|
4897
4898
|
function attributes(source) {
|
|
4898
4899
|
let [, rowspan = global_1.undefined, colspan = global_1.undefined, highlight = global_1.undefined] = source.match(/^.(?:(\d+)?:(\d+)?)?(!+)?$/) ?? [];
|
|
@@ -5195,7 +5196,7 @@ const dom_1 = __webpack_require__(3252);
|
|
|
5195
5196
|
exports.ilist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(/^[-+*](?=[^\S\n]|\n[^\S\n]*\S)/, (0, combinator_1.state)(4
|
|
5196
5197
|
/* State.media */
|
|
5197
5198
|
, exports.ilist_))));
|
|
5198
|
-
exports.ilist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^[-+*](?:$|\s)/, (0, combinator_1.some)((0, combinator_1.creation)((0, combinator_1.union)([(0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(/^[-+*](?:$|\s)/, (0, combinator_1.some)(inline_1.inline), true)), (0, combinator_1.indent)((0, combinator_1.union)([ulist_1.ulist_, olist_1.olist_, exports.ilist_]))]), olist_1.invalid), ns => [(0, dom_1.html)('li', (0, dom_1.defrag)((0, ulist_1.fillFirstLine)(ns)))])])))), es => [(0, dom_1.html)('ul', {
|
|
5199
|
+
exports.ilist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^[-+*](?:$|\s)/, (0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(/^[-+*](?:$|\s)/, (0, combinator_1.some)(inline_1.inline), true)), (0, combinator_1.indent)((0, combinator_1.union)([ulist_1.ulist_, olist_1.olist_, exports.ilist_]))]), olist_1.invalid), ns => [(0, dom_1.html)('li', (0, dom_1.defrag)((0, ulist_1.fillFirstLine)(ns)))])])))), es => [(0, dom_1.html)('ul', {
|
|
5199
5200
|
class: 'invalid',
|
|
5200
5201
|
'data-invalid-syntax': 'list',
|
|
5201
5202
|
'data-invalid-type': 'syntax',
|
|
@@ -5284,7 +5285,7 @@ exports.olist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combina
|
|
|
5284
5285
|
, exports.olist_))));
|
|
5285
5286
|
exports.olist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.union)([(0, combinator_1.match)(openers['.'], (0, memoize_1.memoize)(ms => list(type(ms[1]), '.'), ms => type(ms[1]).charCodeAt(0) || 0, [])), (0, combinator_1.match)(openers['('], (0, memoize_1.memoize)(ms => list(type(ms[1]), '('), ms => type(ms[1]).charCodeAt(0) || 0, []))])));
|
|
5286
5287
|
|
|
5287
|
-
const list = (type, form) => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)((0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(heads[form], (0, combinator_1.subsequence)([ulist_1.checkbox, (0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))]), true)), (0, combinator_1.indent)((0, combinator_1.union)([ulist_1.ulist_, exports.olist_, ilist_1.ilist_]))]), exports.invalid), ns => [(0, dom_1.html)('li', {
|
|
5288
|
+
const list = (type, form) => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(heads[form], (0, combinator_1.subsequence)([ulist_1.checkbox, (0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))]), true)), (0, combinator_1.indent)((0, combinator_1.union)([ulist_1.ulist_, exports.olist_, ilist_1.ilist_]))]), exports.invalid), ns => [(0, dom_1.html)('li', {
|
|
5288
5289
|
'data-marker': ns[0] || global_1.undefined
|
|
5289
5290
|
}, (0, dom_1.defrag)((0, ulist_1.fillFirstLine)((0, array_1.shift)(ns)[1])))]), true)]))), es => [format((0, dom_1.html)('ol', es), type, form)]);
|
|
5290
5291
|
|
|
@@ -5477,7 +5478,7 @@ const source_1 = __webpack_require__(6743);
|
|
|
5477
5478
|
|
|
5478
5479
|
const dom_1 = __webpack_require__(3252);
|
|
5479
5480
|
|
|
5480
|
-
exports.cite = (0, combinator_1.creation)((0, combinator_1.line)((0, combinator_1.fmap)((0, combinator_1.validate)('>>', (0, combinator_1.reverse)((0, combinator_1.tails)([(0, source_1.str)(/^>*(?=>>[^>\s]+[^\S\n]*(?:$|\n))/), (0, combinator_1.union)([anchor_1.anchor, // Subject page representation.
|
|
5481
|
+
exports.cite = (0, combinator_1.creation)(1, false, (0, combinator_1.line)((0, combinator_1.fmap)((0, combinator_1.validate)('>>', (0, combinator_1.reverse)((0, combinator_1.tails)([(0, source_1.str)(/^>*(?=>>[^>\s]+[^\S\n]*(?:$|\n))/), (0, combinator_1.union)([anchor_1.anchor, // Subject page representation.
|
|
5481
5482
|
// リンクの実装は後で検討
|
|
5482
5483
|
(0, combinator_1.focus)(/^>>\.[^\S\n]*(?:$|\n)/, () => [[(0, dom_1.html)('a', {
|
|
5483
5484
|
class: 'anchor'
|
|
@@ -5523,7 +5524,7 @@ const autolink_1 = __webpack_require__(6578);
|
|
|
5523
5524
|
const dom_1 = __webpack_require__(3252);
|
|
5524
5525
|
|
|
5525
5526
|
exports.syntax = /^>+(?=[^\S\n])|^>(?=[^\s>])|^>+(?=[^\s>])(?![0-9a-z]+(?:-[0-9a-z]+)*(?![0-9A-Za-z@#:]))/;
|
|
5526
|
-
exports.quote = (0, combinator_1.lazy)(() => (0, combinator_1.creation)((0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)('>', (0, combinator_1.union)([(0, combinator_1.rewrite)((0, combinator_1.some)((0, combinator_1.validate)(new RegExp(exports.syntax.source.split('|')[0]), source_1.anyline)), qblock), (0, combinator_1.rewrite)((0, combinator_1.validate)(new RegExp(exports.syntax.source.split('|').slice(1).join('|')), source_1.anyline), (0, combinator_1.line)((0, combinator_1.union)([(0, source_1.str)(/^.+/)])))])), ns => [(0, dom_1.html)('span', ns.length > 1 ? {
|
|
5527
|
+
exports.quote = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(1, false, (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)('>', (0, combinator_1.union)([(0, combinator_1.rewrite)((0, combinator_1.some)((0, combinator_1.validate)(new RegExp(exports.syntax.source.split('|')[0]), source_1.anyline)), qblock), (0, combinator_1.rewrite)((0, combinator_1.validate)(new RegExp(exports.syntax.source.split('|').slice(1).join('|')), source_1.anyline), (0, combinator_1.line)((0, combinator_1.union)([(0, source_1.str)(/^.+/)])))])), ns => [(0, dom_1.html)('span', ns.length > 1 ? {
|
|
5527
5528
|
class: 'quote'
|
|
5528
5529
|
} : {
|
|
5529
5530
|
class: 'quote invalid',
|
|
@@ -5606,7 +5607,7 @@ const opener = /^(?=\|\|+(?:$|\s))/;
|
|
|
5606
5607
|
|
|
5607
5608
|
const unindent = source => source.replace(/(^|\n)\|(?:[^\S\n]|(?=\|*(?:$|\s)))|\n$/g, '$1');
|
|
5608
5609
|
|
|
5609
|
-
const source = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)((0, combinator_1.union)([(0, combinator_1.focus)(/^(?:\|\|+(?:[^\S\n][^\n]*)?(?:$|\n))+/, (0, combinator_1.convert)(unindent, source)), (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, (0, combinator_1.fmap)((0, combinator_1.some)(autolink_1.autolink), ns => [(0, dom_1.html)('pre', (0, dom_1.defrag)(ns))])))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
|
|
5610
|
+
const source = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, combinator_1.focus)(/^(?:\|\|+(?:[^\S\n][^\n]*)?(?:$|\n))+/, (0, combinator_1.convert)(unindent, source)), (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, (0, combinator_1.fmap)((0, combinator_1.some)(autolink_1.autolink), ns => [(0, dom_1.html)('pre', (0, dom_1.defrag)(ns))])))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
|
|
5610
5611
|
|
|
5611
5612
|
/***/ }),
|
|
5612
5613
|
|
|
@@ -5637,7 +5638,7 @@ const array_1 = __webpack_require__(8112);
|
|
|
5637
5638
|
|
|
5638
5639
|
exports.table = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^\|[^\n]*(?:\n\|[^\n]*){2}/, (0, combinator_1.sequence)([row((0, combinator_1.some)(head), true), row((0, combinator_1.some)(align), false), (0, combinator_1.some)(row((0, combinator_1.some)(data), true))])), rows => [(0, dom_1.html)('table', [(0, dom_1.html)('thead', [rows.shift()]), (0, dom_1.html)('tbody', format(rows))])])));
|
|
5639
5640
|
|
|
5640
|
-
const row = (parser, optional) => (0, combinator_1.creation)((0, combinator_1.fallback)((0, combinator_1.fmap)((0, combinator_1.line)((0, combinator_1.surround)(/^(?=\|)/, (0, combinator_1.some)((0, combinator_1.union)([parser])), /^[|\\]?\s*$/, optional)), es => [(0, dom_1.html)('tr', es)]), (0, combinator_1.rewrite)(source_1.contentline, ({
|
|
5641
|
+
const row = (parser, optional) => (0, combinator_1.creation)(1, false, (0, combinator_1.fallback)((0, combinator_1.fmap)((0, combinator_1.line)((0, combinator_1.surround)(/^(?=\|)/, (0, combinator_1.some)((0, combinator_1.union)([parser])), /^[|\\]?\s*$/, optional)), es => [(0, dom_1.html)('tr', es)]), (0, combinator_1.rewrite)(source_1.contentline, ({
|
|
5641
5642
|
source
|
|
5642
5643
|
}) => [[(0, dom_1.html)('tr', {
|
|
5643
5644
|
class: 'invalid',
|
|
@@ -5646,10 +5647,10 @@ const row = (parser, optional) => (0, combinator_1.creation)((0, combinator_1.fa
|
|
|
5646
5647
|
'data-invalid-message': 'Missing the start symbol of the table row'
|
|
5647
5648
|
}, [(0, dom_1.html)('td', source.replace('\n', ''))])], ''])));
|
|
5648
5649
|
|
|
5649
|
-
const align = (0, combinator_1.creation)((0, combinator_1.fmap)((0, combinator_1.open)('|', (0, combinator_1.union)([(0, combinator_1.focus)(/^:-+:/, () => [['center'], '']), (0, combinator_1.focus)(/^:-+/, () => [['start'], '']), (0, combinator_1.focus)(/^-+:/, () => [['end'], '']), (0, combinator_1.focus)(/^-+/, () => [[''], ''])])), ns => [(0, dom_1.html)('td', (0, dom_1.defrag)(ns))]));
|
|
5650
|
+
const align = (0, combinator_1.creation)(1, false, (0, combinator_1.fmap)((0, combinator_1.open)('|', (0, combinator_1.union)([(0, combinator_1.focus)(/^:-+:/, () => [['center'], '']), (0, combinator_1.focus)(/^:-+/, () => [['start'], '']), (0, combinator_1.focus)(/^-+:/, () => [['end'], '']), (0, combinator_1.focus)(/^-+/, () => [[''], ''])])), ns => [(0, dom_1.html)('td', (0, dom_1.defrag)(ns))]));
|
|
5650
5651
|
const cell = (0, combinator_1.surround)(/^\|\s*(?=\S)/, (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), /^\|/, [[/^[|\\]?\s*$/, 9]]), /^[^|]*/, true);
|
|
5651
|
-
const head = (0, combinator_1.creation)((0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('th', (0, visibility_1.trimNode)((0, dom_1.defrag)(ns)))]));
|
|
5652
|
-
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)))]));
|
|
5652
|
+
const head = (0, combinator_1.creation)(1, false, (0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('th', (0, visibility_1.trimNode)((0, dom_1.defrag)(ns)))]));
|
|
5653
|
+
const data = (0, combinator_1.creation)(1, false, (0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('td', (0, visibility_1.trimNode)((0, dom_1.defrag)(ns)))]));
|
|
5653
5654
|
|
|
5654
5655
|
function format(rows) {
|
|
5655
5656
|
const aligns = rows[0].className === 'invalid' ? [] : (0, duff_1.duffReduce)(rows.shift().children, (acc, el) => (0, array_1.push)(acc, [el.textContent]), []);
|
|
@@ -5698,8 +5699,8 @@ const array_1 = __webpack_require__(8112);
|
|
|
5698
5699
|
exports.ulist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(/^-(?=[^\S\n]|\n[^\S\n]*\S)/, (0, combinator_1.state)(4
|
|
5699
5700
|
/* State.media */
|
|
5700
5701
|
, exports.ulist_))));
|
|
5701
|
-
exports.ulist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^-(?=$|\s)/, (0, combinator_1.some)((0, combinator_1.creation)((0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(/^-(?:$|\s)/, (0, combinator_1.subsequence)([exports.checkbox, (0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))]), true)), (0, combinator_1.indent)((0, combinator_1.union)([exports.ulist_, olist_1.olist_, ilist_1.ilist_]))]), olist_1.invalid), ns => [(0, dom_1.html)('li', (0, dom_1.defrag)(fillFirstLine(ns)))]), true)])))), es => [format((0, dom_1.html)('ul', es))])));
|
|
5702
|
-
exports.checkbox = (0, combinator_1.creation)((0, combinator_1.focus)(/^\[[xX ]\](?=$|\s)/, ({
|
|
5702
|
+
exports.ulist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^-(?=$|\s)/, (0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(/^-(?:$|\s)/, (0, combinator_1.subsequence)([exports.checkbox, (0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))]), true)), (0, combinator_1.indent)((0, combinator_1.union)([exports.ulist_, olist_1.olist_, ilist_1.ilist_]))]), olist_1.invalid), ns => [(0, dom_1.html)('li', (0, dom_1.defrag)(fillFirstLine(ns)))]), true)])))), es => [format((0, dom_1.html)('ul', es))])));
|
|
5703
|
+
exports.checkbox = (0, combinator_1.creation)(1, false, (0, combinator_1.focus)(/^\[[xX ]\](?=$|\s)/, ({
|
|
5703
5704
|
source
|
|
5704
5705
|
}) => [[(0, dom_1.html)('span', {
|
|
5705
5706
|
class: 'checkbox'
|
|
@@ -5943,15 +5944,15 @@ const source_1 = __webpack_require__(6743);
|
|
|
5943
5944
|
|
|
5944
5945
|
const util_1 = __webpack_require__(9437);
|
|
5945
5946
|
|
|
5946
|
-
exports.autolink = (0, combinator_1.fmap)((0, combinator_1.validate)(/^(?:[@#>0-
|
|
5947
|
+
exports.autolink = (0, combinator_1.fmap)((0, combinator_1.validate)(/^(?:[@#>0-9a-z]|\S[#>])/i, (0, combinator_1.constraint)(2
|
|
5947
5948
|
/* State.autolink */
|
|
5948
5949
|
, false, (0, combinator_1.syntax)(2
|
|
5949
5950
|
/* Syntax.autolink */
|
|
5950
5951
|
, 1, 1, 0
|
|
5951
5952
|
/* State.none */
|
|
5952
5953
|
, (0, combinator_1.some)((0, combinator_1.union)([url_1.url, email_1.email, // Escape unmatched email-like strings.
|
|
5953
|
-
(0, source_1.str)(/^[0-
|
|
5954
|
-
(0, source_1.str)(/^@+[0-
|
|
5954
|
+
(0, source_1.str)(/^[0-9a-z]+(?:[.+_-][0-9a-z]+)*(?:@(?:[0-9a-z]+(?:[.-][0-9a-z]+)*)?)*/i), channel_1.channel, account_1.account, // Escape unmatched account-like strings.
|
|
5955
|
+
(0, source_1.str)(/^@+[0-9a-z]*(?:-[0-9a-z]+)*/i), // Escape invalid leading characters.
|
|
5955
5956
|
(0, source_1.str)(new RegExp(/^(?:[^\p{C}\p{S}\p{P}\s]|emoji|['_])(?=#)/u.source.replace('emoji', hashtag_1.emoji), 'u')), hashtag_1.hashtag, hashnum_1.hashnum, // Escape unmatched hashtag-like strings.
|
|
5956
5957
|
(0, source_1.str)(new RegExp(/^#+(?:[^\p{C}\p{S}\p{P}\s]|emoji|['_])*/u.source.replace('emoji', hashtag_1.emoji), 'u')), anchor_1.anchor]))))), ns => ns.length === 1 ? ns : [(0, util_1.stringify)(ns)]);
|
|
5957
5958
|
|
|
@@ -5979,7 +5980,7 @@ const dom_1 = __webpack_require__(3252); // https://example/@user must be a user
|
|
|
5979
5980
|
|
|
5980
5981
|
exports.account = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.rewrite)((0, combinator_1.constraint)(1
|
|
5981
5982
|
/* State.shortcut */
|
|
5982
|
-
, false, (0, combinator_1.open)('@', (0, combinator_1.tails)([(0, combinator_1.verify)((0, source_1.str)(/^[0-
|
|
5983
|
+
, false, (0, combinator_1.open)('@', (0, combinator_1.tails)([(0, combinator_1.verify)((0, source_1.str)(/^[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?(?:\.[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?)*\//i), ([source]) => source.length <= 253 + 1), (0, source_1.str)(/^[a-z](?:-(?=[0-9a-z])|[0-9a-z]){0,63}/i)]))), (0, combinator_1.convert)(source => `[${source}]{ ${source.includes('/') ? `https://${source.slice(1).replace('/', '/@')}` : `/${source}`} }`, (0, combinator_1.union)([link_1.unsafelink]))), ([el]) => [(0, dom_1.define)(el, {
|
|
5983
5984
|
class: 'account'
|
|
5984
5985
|
})]));
|
|
5985
5986
|
|
|
@@ -6010,7 +6011,7 @@ const dom_1 = __webpack_require__(3252); // Timeline(pseudonym): user/tid
|
|
|
6010
6011
|
|
|
6011
6012
|
exports.anchor = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('>>', (0, combinator_1.fmap)((0, combinator_1.constraint)(1
|
|
6012
6013
|
/* State.shortcut */
|
|
6013
|
-
, false, (0, combinator_1.focus)(/^>>(?:[
|
|
6014
|
+
, false, (0, combinator_1.focus)(/^>>(?:[a-z][0-9a-z]*(?:-[0-9a-z]+)*\/)?[0-9a-z]+(?:-[0-9a-z]+)*(?![0-9a-z@#:])/i, (0, combinator_1.convert)(source => `[${source}]{ ${source.includes('/') ? `/@${source.slice(2).replace('/', '/timeline/')}` : `?at=${source.slice(2)}`} }`, (0, combinator_1.union)([link_1.unsafelink])))), ([el]) => [(0, dom_1.define)(el, {
|
|
6014
6015
|
class: 'anchor'
|
|
6015
6016
|
})])));
|
|
6016
6017
|
|
|
@@ -6069,7 +6070,7 @@ const source_1 = __webpack_require__(6743);
|
|
|
6069
6070
|
const dom_1 = __webpack_require__(3252); // https://html.spec.whatwg.org/multipage/input.html
|
|
6070
6071
|
|
|
6071
6072
|
|
|
6072
|
-
exports.email = (0, combinator_1.creation)((0, combinator_1.rewrite)((0, combinator_1.verify)((0, source_1.str)(/^[0-
|
|
6073
|
+
exports.email = (0, combinator_1.creation)((0, combinator_1.rewrite)((0, combinator_1.verify)((0, source_1.str)(/^[0-9a-z](?:[.+_-](?=[^\W_])|[0-9a-z]){0,255}@[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?(?:\.[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?)*(?![0-9a-z])/i), ([source]) => source.length <= 255), ({
|
|
6073
6074
|
source
|
|
6074
6075
|
}) => [[(0, dom_1.html)('a', {
|
|
6075
6076
|
class: 'email',
|
|
@@ -6132,7 +6133,7 @@ const dom_1 = __webpack_require__(3252); // https://example/hashtags/a must be a
|
|
|
6132
6133
|
exports.emoji = String.raw`\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F`;
|
|
6133
6134
|
exports.hashtag = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.rewrite)((0, combinator_1.constraint)(1
|
|
6134
6135
|
/* State.shortcut */
|
|
6135
|
-
, false, (0, combinator_1.open)('#', (0, combinator_1.tails)([(0, combinator_1.verify)((0, source_1.str)(/^[0-
|
|
6136
|
+
, false, (0, combinator_1.open)('#', (0, combinator_1.tails)([(0, combinator_1.verify)((0, source_1.str)(/^[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?(?:\.[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?)*\//i), ([source]) => source.length <= 253 + 1), (0, combinator_1.verify)((0, source_1.str)(new RegExp([/^(?=[0-9]{0,127}_?(?:[^\d\p{C}\p{S}\p{P}\s]|emoji))/u.source, /(?:[^\p{C}\p{S}\p{P}\s]|emoji|_(?=[^\p{C}\p{S}\p{P}\s]|emoji)){1,128}/u.source, /(?!_?(?:[^\p{C}\p{S}\p{P}\s]|emoji)|')/u.source].join('').replace(/emoji/g, exports.emoji), 'u')), ([source]) => source.length <= 128)]))), (0, combinator_1.convert)(source => `[${source}]{ ${source.includes('/') ? `https://${source.slice(1).replace('/', '/hashtags/')}` : `/hashtags/${source.slice(1)}`} }`, (0, combinator_1.union)([link_1.unsafelink]))), ([el]) => [(0, dom_1.define)(el, {
|
|
6136
6137
|
class: 'hashtag'
|
|
6137
6138
|
}, el.innerText)]));
|
|
6138
6139
|
|
|
@@ -6155,12 +6156,8 @@ const link_1 = __webpack_require__(9628);
|
|
|
6155
6156
|
|
|
6156
6157
|
const source_1 = __webpack_require__(6743);
|
|
6157
6158
|
|
|
6158
|
-
const dom_1 = __webpack_require__(3252);
|
|
6159
|
-
|
|
6160
6159
|
const closer = /^[-+*=~^,.;:!?]*(?=[\\"`|\[\](){}<>]|$)/;
|
|
6161
|
-
exports.url = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['http://', 'https://'], (0, combinator_1.
|
|
6162
|
-
class: 'url'
|
|
6163
|
-
})])));
|
|
6160
|
+
exports.url = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['http://', 'https://'], (0, combinator_1.rewrite)((0, combinator_1.open)(/^https?:\/\/(?=[\x21-\x7E])/, (0, combinator_1.focus)(/^[\x21-\x7E]+/, (0, combinator_1.some)((0, combinator_1.union)([bracket, (0, combinator_1.some)(source_1.unescsource, closer)])))), (0, combinator_1.convert)(url => `{ ${url} }`, (0, combinator_1.union)([link_1.unsafelink])))));
|
|
6164
6161
|
const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.creation)((0, combinator_1.precedence)(2, (0, combinator_1.union)([(0, combinator_1.surround)('(', (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), ')'), ')', true), (0, combinator_1.surround)('[', (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), ']'), ']', true), (0, combinator_1.surround)('{', (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), '}'), '}', true), (0, combinator_1.surround)('"', (0, combinator_1.precedence)(8, (0, combinator_1.some)(source_1.unescsource, '"')), '"', true)]))));
|
|
6165
6162
|
|
|
6166
6163
|
/***/ }),
|
|
@@ -6934,17 +6931,6 @@ const textlink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(8
|
|
|
6934
6931
|
, 2, 10, 254
|
|
6935
6932
|
/* State.linkable */
|
|
6936
6933
|
, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [[/^\\?\n/, 9], [']', 2]]), ']', true)), (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) => {
|
|
6937
|
-
if (content.length !== 0 && (0, visibility_1.trimNode)(content).length === 0) return;
|
|
6938
|
-
|
|
6939
|
-
for (let source = (0, util_1.stringify)(content); source;) {
|
|
6940
|
-
const result = autolink({
|
|
6941
|
-
source,
|
|
6942
|
-
context
|
|
6943
|
-
});
|
|
6944
|
-
if (typeof (0, parser_1.eval)(result, [])[0] === 'object') return;
|
|
6945
|
-
source = (0, parser_1.exec)(result, '');
|
|
6946
|
-
}
|
|
6947
|
-
|
|
6948
6934
|
return parse(content, params, rest, context);
|
|
6949
6935
|
}))));
|
|
6950
6936
|
const medialink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(8
|
|
@@ -6968,30 +6954,40 @@ const autolink = (0, combinator_1.state)(2
|
|
|
6968
6954
|
, autolink_1.autolink));
|
|
6969
6955
|
|
|
6970
6956
|
function parse(content, params, rest, context) {
|
|
6957
|
+
if (content.length !== 0 && (0, visibility_1.trimNode)(content).length === 0) return;
|
|
6958
|
+
content = (0, dom_1.defrag)(content);
|
|
6959
|
+
|
|
6960
|
+
for (let source = (0, util_1.stringify)(content); source;) {
|
|
6961
|
+
if (/^[a-z][0-9a-z]*(?:[-.][0-9a-z]+)*:\/\/[^/?#]/i.test(source)) return;
|
|
6962
|
+
const result = autolink({
|
|
6963
|
+
source,
|
|
6964
|
+
context
|
|
6965
|
+
});
|
|
6966
|
+
if (typeof (0, parser_1.eval)(result, [])[0] === 'object') return;
|
|
6967
|
+
source = (0, parser_1.exec)(result, '');
|
|
6968
|
+
}
|
|
6969
|
+
|
|
6971
6970
|
const INSECURE_URI = params.shift();
|
|
6972
|
-
const
|
|
6973
|
-
if (el.className === 'invalid') return [[el], rest];
|
|
6974
|
-
return [[(0, dom_1.define)(el, (0, html_1.attributes)('link', [], optspec, params))], rest];
|
|
6975
|
-
}
|
|
6971
|
+
const uri = 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);
|
|
6976
6972
|
|
|
6977
|
-
|
|
6978
|
-
|
|
6979
|
-
|
|
6980
|
-
|
|
6981
|
-
|
|
6982
|
-
&& /^[0-9]*[A-Za-z][0-9A-Za-z]*$/.test(last.slice(last.lastIndexOf('.') + 1)) ? `${host.pathname.slice(0, -last.length)}${uri.slice(2)}` : `${host.pathname.replace(/\/?$/, '/')}${uri.slice(2)}`;
|
|
6973
|
+
switch (uri.protocol) {
|
|
6974
|
+
case 'tel:':
|
|
6975
|
+
{
|
|
6976
|
+
const tel = content.length === 0 ? INSECURE_URI : content[0];
|
|
6977
|
+
const pattern = /^(?:tel:)?(?:\+(?!0))?\d+(?:-\d+)*$/i;
|
|
6983
6978
|
|
|
6984
|
-
|
|
6985
|
-
|
|
6986
|
-
|
|
6979
|
+
if (content.length <= 1 && typeof tel === 'string' && pattern.test(tel) && pattern.test(INSECURE_URI) && tel.replace(/[^+\d]/g, '') === INSECURE_URI.replace(/[^+\d]/g, '')) {
|
|
6980
|
+
break;
|
|
6981
|
+
}
|
|
6987
6982
|
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
return target.origin === host.origin ? target.href.slice(target.origin.length) : target.href;
|
|
6983
|
+
return;
|
|
6984
|
+
}
|
|
6991
6985
|
}
|
|
6992
|
-
}
|
|
6993
6986
|
|
|
6994
|
-
|
|
6987
|
+
const el = elem(INSECURE_URI, content, uri, context.host?.origin || global_1.location.origin);
|
|
6988
|
+
if (el.className === 'invalid') return [[el], rest];
|
|
6989
|
+
return [[(0, dom_1.define)(el, (0, html_1.attributes)('link', [], optspec, params))], rest];
|
|
6990
|
+
}
|
|
6995
6991
|
|
|
6996
6992
|
function elem(INSECURE_URI, content, uri, origin) {
|
|
6997
6993
|
let type;
|
|
@@ -7007,29 +7003,16 @@ function elem(INSECURE_URI, content, uri, origin) {
|
|
|
7007
7003
|
}
|
|
7008
7004
|
|
|
7009
7005
|
return (0, dom_1.html)('a', {
|
|
7010
|
-
class: 'link',
|
|
7006
|
+
class: content.length === 0 ? 'url' : 'link',
|
|
7011
7007
|
href: uri.source,
|
|
7012
7008
|
target: global_1.undefined || uri.origin !== origin || typeof content[0] === 'object' && content[0].classList.contains('media') ? '_blank' : global_1.undefined
|
|
7013
7009
|
}, content.length === 0 ? decode(INSECURE_URI) : content);
|
|
7014
7010
|
|
|
7015
7011
|
case 'tel:':
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
-
|
|
7019
|
-
|
|
7020
|
-
const pattern = /^(?:tel:)?(?:\+(?!0))?\d+(?:-\d+)*$/i;
|
|
7021
|
-
|
|
7022
|
-
switch (true) {
|
|
7023
|
-
case content.length === 1 && typeof content[0] === 'string' && pattern.test(INSECURE_URI) && pattern.test(content[0]) && INSECURE_URI.replace(/[^+\d]/g, '') === content[0].replace(/[^+\d]/g, ''):
|
|
7024
|
-
return (0, dom_1.html)('a', {
|
|
7025
|
-
class: 'tel',
|
|
7026
|
-
href: uri.source
|
|
7027
|
-
}, content);
|
|
7028
|
-
}
|
|
7029
|
-
|
|
7030
|
-
type = 'content';
|
|
7031
|
-
message = 'Invalid phone number';
|
|
7032
|
-
break;
|
|
7012
|
+
return (0, dom_1.html)('a', {
|
|
7013
|
+
class: 'tel',
|
|
7014
|
+
href: uri.source
|
|
7015
|
+
}, content.length === 0 ? [INSECURE_URI] : content);
|
|
7033
7016
|
}
|
|
7034
7017
|
|
|
7035
7018
|
return (0, dom_1.html)('a', {
|
|
@@ -7040,11 +7023,37 @@ function elem(INSECURE_URI, content, uri, origin) {
|
|
|
7040
7023
|
}, content.length === 0 ? INSECURE_URI : content);
|
|
7041
7024
|
}
|
|
7042
7025
|
|
|
7026
|
+
function resolve(uri, host, source) {
|
|
7027
|
+
switch (true) {
|
|
7028
|
+
case uri.slice(0, 2) === '^/':
|
|
7029
|
+
const last = host.pathname.slice(host.pathname.lastIndexOf('/') + 1);
|
|
7030
|
+
return last.includes('.') // isFile
|
|
7031
|
+
&& /^[0-9]*[a-z][0-9a-z]*$/i.test(last.slice(last.lastIndexOf('.') + 1)) ? `${host.pathname.slice(0, -last.length)}${uri.slice(2)}` : `${host.pathname.replace(/\/?$/, '/')}${uri.slice(2)}`;
|
|
7032
|
+
|
|
7033
|
+
case host.origin === source.origin && host.pathname === source.pathname:
|
|
7034
|
+
case uri.slice(0, 2) === '//':
|
|
7035
|
+
return uri;
|
|
7036
|
+
|
|
7037
|
+
default:
|
|
7038
|
+
const target = new url_1.ReadonlyURL(uri, source.href);
|
|
7039
|
+
return target.origin === host.origin ? target.href.slice(target.origin.length) : target.href;
|
|
7040
|
+
}
|
|
7041
|
+
}
|
|
7042
|
+
|
|
7043
|
+
exports.resolve = resolve;
|
|
7044
|
+
|
|
7043
7045
|
function decode(uri) {
|
|
7044
7046
|
if (!uri.includes('%')) return uri;
|
|
7047
|
+
const origin = uri.match(/^[a-z](?:[-.](?=\w)|[0-9a-z])*:\/\/[^/?#]*/i)?.[0] ?? '';
|
|
7045
7048
|
|
|
7046
7049
|
try {
|
|
7047
|
-
|
|
7050
|
+
let path = (0, global_1.decodeURI)(uri.slice(origin.length));
|
|
7051
|
+
|
|
7052
|
+
if (!origin && /^[a-z](?:[-.](?=\w)|[0-9a-z])*:\/\/[^/?#]/i.test(path)) {
|
|
7053
|
+
path = uri.slice(origin.length);
|
|
7054
|
+
}
|
|
7055
|
+
|
|
7056
|
+
uri = origin + path;
|
|
7048
7057
|
} finally {
|
|
7049
7058
|
return uri.replace(/\s+/g, global_1.encodeURI);
|
|
7050
7059
|
}
|
|
@@ -7344,7 +7353,7 @@ exports.ruby = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[', (0,
|
|
|
7344
7353
|
return [(0, dom_1.html)('ruby', attributes(texts, rubies), (0, dom_1.defrag)((0, array_1.unshift)([texts.join(' ')], [(0, dom_1.html)('rp', '('), (0, dom_1.html)('rt', rubies.join(' ').trim()), (0, dom_1.html)('rp', ')')])))];
|
|
7345
7354
|
}
|
|
7346
7355
|
}))));
|
|
7347
|
-
const text = (0, combinator_1.creation)(({
|
|
7356
|
+
const text = (0, combinator_1.creation)(1, false, ({
|
|
7348
7357
|
source,
|
|
7349
7358
|
context
|
|
7350
7359
|
}) => {
|
|
@@ -8155,7 +8164,7 @@ const combinator_1 = __webpack_require__(2087);
|
|
|
8155
8164
|
const text_1 = __webpack_require__(7763);
|
|
8156
8165
|
|
|
8157
8166
|
const delimiter = /[\s\x00-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]/;
|
|
8158
|
-
exports.escsource = (0, combinator_1.creation)(({
|
|
8167
|
+
exports.escsource = (0, combinator_1.creation)(1, false, ({
|
|
8159
8168
|
source
|
|
8160
8169
|
}) => {
|
|
8161
8170
|
if (source === '') return;
|
|
@@ -8223,12 +8232,12 @@ const global_1 = __webpack_require__(4128);
|
|
|
8223
8232
|
const combinator_1 = __webpack_require__(2087);
|
|
8224
8233
|
|
|
8225
8234
|
function str(pattern) {
|
|
8226
|
-
return typeof pattern === 'string' ? (0, combinator_1.creation)(({
|
|
8235
|
+
return typeof pattern === 'string' ? (0, combinator_1.creation)(1, false, ({
|
|
8227
8236
|
source
|
|
8228
8237
|
}) => {
|
|
8229
8238
|
if (source === '') return;
|
|
8230
8239
|
return source.slice(0, pattern.length) === pattern ? [[pattern], source.slice(pattern.length)] : global_1.undefined;
|
|
8231
|
-
}) : (0, combinator_1.creation)(({
|
|
8240
|
+
}) : (0, combinator_1.creation)(1, false, ({
|
|
8232
8241
|
source
|
|
8233
8242
|
}) => {
|
|
8234
8243
|
if (source === '') return;
|
|
@@ -8240,12 +8249,12 @@ function str(pattern) {
|
|
|
8240
8249
|
exports.str = str;
|
|
8241
8250
|
|
|
8242
8251
|
function stropt(pattern) {
|
|
8243
|
-
return typeof pattern === 'string' ? (0, combinator_1.creation)(({
|
|
8252
|
+
return typeof pattern === 'string' ? (0, combinator_1.creation)(1, false, ({
|
|
8244
8253
|
source
|
|
8245
8254
|
}) => {
|
|
8246
8255
|
if (source === '') return;
|
|
8247
8256
|
return source.slice(0, pattern.length) === pattern ? [[pattern], source.slice(pattern.length)] : global_1.undefined;
|
|
8248
|
-
}) : (0, combinator_1.creation)(({
|
|
8257
|
+
}) : (0, combinator_1.creation)(1, false, ({
|
|
8249
8258
|
source
|
|
8250
8259
|
}) => {
|
|
8251
8260
|
if (source === '') return;
|
|
@@ -8281,11 +8290,7 @@ exports.delimiter = /[\s\x00-\x7F]|\S[#>]|[()、。!?][^\S\n]*(?=\\\n)/;
|
|
|
8281
8290
|
exports.nonWhitespace = /[\S\n]|$/;
|
|
8282
8291
|
exports.nonAlphanumeric = /[^0-9A-Za-z]|\S[#>]|$/;
|
|
8283
8292
|
const repeat = (0, str_1.str)(/^(.)\1*/);
|
|
8284
|
-
exports.text = (0, combinator_1.
|
|
8285
|
-
/* Syntax.none */
|
|
8286
|
-
, 1, 1, 0
|
|
8287
|
-
/* State.none */
|
|
8288
|
-
, ({
|
|
8293
|
+
exports.text = (0, combinator_1.creation)(1, false, ({
|
|
8289
8294
|
source,
|
|
8290
8295
|
context
|
|
8291
8296
|
}) => {
|
|
@@ -8389,7 +8394,7 @@ const combinator_1 = __webpack_require__(2087);
|
|
|
8389
8394
|
|
|
8390
8395
|
const text_1 = __webpack_require__(7763);
|
|
8391
8396
|
|
|
8392
|
-
exports.unescsource = (0, combinator_1.creation)(({
|
|
8397
|
+
exports.unescsource = (0, combinator_1.creation)(1, false, ({
|
|
8393
8398
|
source
|
|
8394
8399
|
}) => {
|
|
8395
8400
|
if (source === '') return;
|
|
@@ -9056,7 +9061,10 @@ function twitter(source, url) {
|
|
|
9056
9061
|
status,
|
|
9057
9062
|
statusText
|
|
9058
9063
|
}) {
|
|
9059
|
-
(0, dom_1.define)(el, [(0, parser_1.parse)(
|
|
9064
|
+
(0, dom_1.define)(el, [(0, dom_1.define)((0, parser_1.parse)(`{ ${source.getAttribute('data-src')} }`).querySelector('a'), {
|
|
9065
|
+
class: null,
|
|
9066
|
+
target: '_blank'
|
|
9067
|
+
}), (0, dom_1.html)('pre', `${status}\n${statusText}`)]);
|
|
9060
9068
|
}
|
|
9061
9069
|
|
|
9062
9070
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "securemark",
|
|
3
|
-
"version": "0.260.
|
|
3
|
+
"version": "0.260.3",
|
|
4
4
|
"description": "Secure markdown renderer working on browsers for user input data.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://github.com/falsandtru/securemark",
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"@types/mocha": "9.1.1",
|
|
35
35
|
"@types/power-assert": "1.5.8",
|
|
36
36
|
"@types/prismjs": "1.26.0",
|
|
37
|
-
"@typescript-eslint/parser": "^5.
|
|
37
|
+
"@typescript-eslint/parser": "^5.30.7",
|
|
38
38
|
"babel-loader": "^8.2.5",
|
|
39
39
|
"babel-plugin-unassert": "^3.2.0",
|
|
40
|
-
"concurrently": "^7.
|
|
41
|
-
"eslint": "^8.
|
|
40
|
+
"concurrently": "^7.3.0",
|
|
41
|
+
"eslint": "^8.20.0",
|
|
42
42
|
"eslint-plugin-redos": "^4.4.1",
|
|
43
43
|
"eslint-webpack-plugin": "^3.2.0",
|
|
44
44
|
"glob": "^8.0.3",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"karma-mocha": "^2.0.1",
|
|
50
50
|
"karma-power-assert": "^1.0.0",
|
|
51
51
|
"mocha": "^10.0.0",
|
|
52
|
-
"npm-check-updates": "^
|
|
52
|
+
"npm-check-updates": "^15.3.4",
|
|
53
53
|
"semver": "^7.3.7",
|
|
54
54
|
"spica": "0.0.573",
|
|
55
55
|
"ts-loader": "^9.3.1",
|
|
@@ -87,16 +87,18 @@ export function syntax<T>(syntax: number, prec: number, cost: number, state: num
|
|
|
87
87
|
|
|
88
88
|
export function creation<P extends Parser<unknown>>(parser: P): P;
|
|
89
89
|
export function creation<P extends Parser<unknown>>(cost: number, parser: P): P;
|
|
90
|
-
export function creation(cost: number
|
|
91
|
-
|
|
90
|
+
export function creation<P extends Parser<unknown>>(cost: number, recursion: boolean, parser: P): P;
|
|
91
|
+
export function creation(cost: number | Parser<unknown>, recursion?: boolean | Parser<unknown>, parser?: Parser<unknown>): Parser<unknown> {
|
|
92
|
+
if (typeof cost === 'function') return creation(1, true, cost);
|
|
93
|
+
if (typeof recursion === 'function') return creation(cost, true, recursion);
|
|
92
94
|
assert(cost > 0);
|
|
93
95
|
return ({ source, context }) => {
|
|
94
96
|
const resources = context.resources ?? { clock: 1, recursion: 1 };
|
|
95
97
|
if (resources.clock <= 0) throw new Error('Too many creations');
|
|
96
98
|
if (resources.recursion <= 0) throw new Error('Too much recursion');
|
|
97
|
-
--resources.recursion;
|
|
99
|
+
recursion && --resources.recursion;
|
|
98
100
|
const result = parser!({ source, context });
|
|
99
|
-
++resources.recursion;
|
|
101
|
+
recursion && ++resources.recursion;
|
|
100
102
|
if (result) {
|
|
101
103
|
resources.clock -= cost;
|
|
102
104
|
}
|
|
@@ -127,13 +127,13 @@ describe('Unit: parser/api/parse', () => {
|
|
|
127
127
|
'<figure data-type="math" data-label="$-a" data-group="$" data-number="1" id="label:$-a"><figcaption><span class="figindex">(1)</span><span class="figtext"></span></figcaption><div><div class="math" translate="no">$$\n$$</div></div></figure>',
|
|
128
128
|
'<p><a class="label" data-label="$-a" href="#label:$-a">(1)</a></p>',
|
|
129
129
|
'<p><sup class="annotation" id="annotation:ref:1" title="a"><span hidden="">a</span><a href="#annotation:def:1">*1</a></sup></p>',
|
|
130
|
-
'<p><a class="
|
|
131
|
-
'<p><a class="
|
|
132
|
-
'<p><a class="
|
|
133
|
-
'<p><a class="
|
|
134
|
-
'<p><a class="
|
|
135
|
-
'<p><a class="
|
|
136
|
-
'<p><a class="
|
|
130
|
+
'<p><a class="url" href="https://source/x/a" target="_blank">a</a></p>',
|
|
131
|
+
'<p><a class="url" href="https://source/a" target="_blank">/a</a></p>',
|
|
132
|
+
'<p><a class="url" href="/z/a">^/a</a></p>',
|
|
133
|
+
'<p><a class="url" href="https://source/x/a" target="_blank">./a</a></p>',
|
|
134
|
+
'<p><a class="url" href="https://source/a" target="_blank">../a</a></p>',
|
|
135
|
+
'<p><a class="url" href="https://source/a" target="_blank">../../a</a></p>',
|
|
136
|
+
'<p><a class="url" href="//domain/a" target="_blank">//domain/a</a></p>',
|
|
137
137
|
'<p><a href="https://source/x/a" target="_blank"><img class="media" data-src="https://source/x/a" alt=""></a></p>',
|
|
138
138
|
'<p><a href="/z/a" target="_blank"><img class="media" data-src="/z/a" alt=""></a></p>',
|
|
139
139
|
'<p><a href="https://source/a" target="_blank"><img class="media" data-src="https://source/a" alt=""></a></p>',
|
|
@@ -151,8 +151,8 @@ describe('Unit: parser/api/parse', () => {
|
|
|
151
151
|
].join('\n\n'), { host: new URL(`${location.origin}/index.md`) }).children].map(el => el.outerHTML),
|
|
152
152
|
[
|
|
153
153
|
'<aside class="header"><details open=""><summary>Header</summary><span class="field" data-name="url" data-value="https://source/x/y"><span class="field-name">URL</span>: <span class="field-value">https://source/x/y</span>\n</span></details></aside>',
|
|
154
|
-
'<p><a class="
|
|
155
|
-
'<p><a class="
|
|
154
|
+
'<p><a class="url" href="/a">^/a</a></p>',
|
|
155
|
+
'<p><a class="url" href="https://source/x/a" target="_blank">./a</a></p>',
|
|
156
156
|
]);
|
|
157
157
|
assert.deepStrictEqual(
|
|
158
158
|
[...parse([
|
|
@@ -166,8 +166,8 @@ describe('Unit: parser/api/parse', () => {
|
|
|
166
166
|
].join('\n\n'), { host: new URL(`${location.origin}/z`) }).children].map(el => el.outerHTML),
|
|
167
167
|
[
|
|
168
168
|
`<aside class="header"><details open=""><summary>Header</summary><span class="field" data-name="url" data-value="${location.origin}/x/y"><span class="field-name">URL</span>: <span class="field-value">${location.origin}/x/y</span>\n</span></details></aside>`,
|
|
169
|
-
'<p><a class="
|
|
170
|
-
'<p><a class="
|
|
169
|
+
'<p><a class="url" href="/z/a">^/a</a></p>',
|
|
170
|
+
'<p><a class="url" href="/x/a">./a</a></p>',
|
|
171
171
|
]);
|
|
172
172
|
});
|
|
173
173
|
|
|
@@ -198,8 +198,8 @@ describe('Unit: parser/api/parse', () => {
|
|
|
198
198
|
[
|
|
199
199
|
`<aside class="header"><details open=""><summary>Header</summary><span class="field" data-name="url" data-value="https://example/x"><span class="field-name">URL</span>: <span class="field-value">https://example/x</span>\n</span></details></aside>`,
|
|
200
200
|
'<pre class="invalid" translate="no" data-invalid-syntax="header" data-invalid-type="syntax" data-invalid-message="Invalid syntax">---\nURL: https://example/y\n---\n</pre>',
|
|
201
|
-
'<aside class="example" data-type="markdown"><pre translate="no">---\nURL: https://example/y\n---\n\n{#}</pre><hr><section><aside class="header"><details open=""><summary>Header</summary><span class="field" data-name="url" data-value="https://example/y"><span class="field-name">URL</span>: <span class="field-value">https://example/y</span>\n</span></details></aside><p><a class="
|
|
202
|
-
'<p><a class="
|
|
201
|
+
'<aside class="example" data-type="markdown"><pre translate="no">---\nURL: https://example/y\n---\n\n{#}</pre><hr><section><aside class="header"><details open=""><summary>Header</summary><span class="field" data-name="url" data-value="https://example/y"><span class="field-name">URL</span>: <span class="field-value">https://example/y</span>\n</span></details></aside><p><a class="url" href="https://example/y#" target="_blank">#</a></p><ol class="references"></ol></section></aside>',
|
|
202
|
+
'<p><a class="url" href="https://example/x#" target="_blank">#</a></p>',
|
|
203
203
|
]);
|
|
204
204
|
});
|
|
205
205
|
|