securemark 0.268.2 → 0.269.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/index.js +45 -35
- package/markdown.d.ts +59 -41
- package/package.json +6 -6
- package/src/parser/api/bind.test.ts +3 -3
- package/src/parser/api/parse.test.ts +3 -3
- package/src/parser/autolink.test.ts +2 -2
- package/src/parser/autolink.ts +5 -12
- package/src/parser/block/blockquote.test.ts +1 -1
- package/src/parser/block/extension/example.test.ts +1 -1
- package/src/parser/block/paragraph.test.ts +4 -2
- package/src/parser/block/paragraph.ts +3 -2
- package/src/parser/block/reply/quote.test.ts +2 -2
- package/src/parser/block/reply/quote.ts +8 -12
- package/src/parser/inline/autolink/url.test.ts +2 -0
- package/src/parser/inline/autolink/url.ts +13 -2
- package/src/parser/inline/autolink.ts +33 -30
- package/src/parser/inline/extension/indexee.ts +3 -2
- package/src/parser/inline/extension/placeholder.test.ts +1 -1
- package/src/parser/inline/link.ts +8 -3
- package/src/parser/inline/media.ts +6 -1
- package/src/parser/inline/shortmedia.ts +12 -3
- package/src/parser/inline.test.ts +6 -9
- package/src/parser/inline.ts +8 -7
- package/src/parser/processor/footnote.test.ts +17 -17
- package/src/parser/processor/footnote.ts +6 -5
- package/src/parser/source/escapable.ts +5 -1
- package/src/parser/source/text.ts +5 -1
- package/src/parser/source/unescapable.ts +7 -1
- package/src/parser/util.ts +0 -10
- package/src/parser/visibility.ts +1 -2
- package/src/util/quote.test.ts +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.
|
|
1
|
+
/*! securemark v0.269.1 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
|
|
2
2
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
3
3
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
4
4
|
module.exports = factory(require("Prism"), require("DOMPurify"));
|
|
@@ -4274,14 +4274,11 @@ exports.parse = parse;
|
|
|
4274
4274
|
Object.defineProperty(exports, "__esModule", ({
|
|
4275
4275
|
value: true
|
|
4276
4276
|
}));
|
|
4277
|
-
exports.
|
|
4277
|
+
exports.autolink = void 0;
|
|
4278
4278
|
const combinator_1 = __webpack_require__(2087);
|
|
4279
|
-
const link_1 = __webpack_require__(9628);
|
|
4280
4279
|
const autolink_1 = __webpack_require__(6051);
|
|
4281
4280
|
const source_1 = __webpack_require__(6743);
|
|
4282
|
-
|
|
4283
|
-
exports.autolink = (0, combinator_1.lazy)(() => (0, combinator_1.some)((0, combinator_1.line)((0, combinator_1.subsequence)([exports.lineurl, (0, combinator_1.some)((0, combinator_1.union)([autolink_1.autolink, source_1.linebreak, source_1.unescsource]))]))));
|
|
4284
|
-
exports.lineurl = (0, combinator_1.lazy)(() => (0, combinator_1.focus)(/^!?https?:\/\/\S+(?=[^\S\n]*(?:$|\n))/, (0, util_1.format)((0, combinator_1.tails)([(0, source_1.str)('!'), link_1.link]))));
|
|
4281
|
+
exports.autolink = (0, combinator_1.lazy)(() => (0, combinator_1.convert)(source => `\r${source}`, (0, combinator_1.some)((0, combinator_1.union)([autolink_1.autolink, source_1.linebreak, source_1.unescsource]))));
|
|
4285
4282
|
|
|
4286
4283
|
/***/ }),
|
|
4287
4284
|
|
|
@@ -5378,7 +5375,7 @@ const combinator_1 = __webpack_require__(2087);
|
|
|
5378
5375
|
const inline_1 = __webpack_require__(1160);
|
|
5379
5376
|
const visibility_1 = __webpack_require__(7618);
|
|
5380
5377
|
const dom_1 = __webpack_require__(3252);
|
|
5381
|
-
exports.paragraph = (0, combinator_1.block)((0, combinator_1.fmap)((0, visibility_1.visualize)((0, combinator_1.trimEnd)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline])))), ns => [(0, dom_1.html)('p', (0, dom_1.defrag)(ns))]));
|
|
5378
|
+
exports.paragraph = (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.convert)(source => `\r${source}`, (0, visibility_1.visualize)((0, combinator_1.trimEnd)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))))), ns => [(0, dom_1.html)('p', (0, dom_1.defrag)(ns))]));
|
|
5382
5379
|
|
|
5383
5380
|
/***/ }),
|
|
5384
5381
|
|
|
@@ -5462,7 +5459,6 @@ const combinator_1 = __webpack_require__(2087);
|
|
|
5462
5459
|
const math_1 = __webpack_require__(8946);
|
|
5463
5460
|
const autolink_1 = __webpack_require__(6051);
|
|
5464
5461
|
const source_1 = __webpack_require__(6743);
|
|
5465
|
-
const autolink_2 = __webpack_require__(7185);
|
|
5466
5462
|
const dom_1 = __webpack_require__(3252);
|
|
5467
5463
|
exports.syntax = /^>+(?=[^\S\n])|^>(?=[^\s>])|^>+(?=[^\s>])(?![0-9a-z]+(?:-[0-9a-z]+)*(?![0-9A-Za-z@#:]))/;
|
|
5468
5464
|
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 ? {
|
|
@@ -5482,7 +5478,7 @@ const qblock = ({
|
|
|
5482
5478
|
const quotes = source.match(/^>+[^\S\n]/mg);
|
|
5483
5479
|
const content = lines.reduce((acc, line, i) => acc + line.slice(quotes[i].length), '');
|
|
5484
5480
|
const nodes = (0, parser_1.eval)(text({
|
|
5485
|
-
source: content
|
|
5481
|
+
source: `\r${content}`,
|
|
5486
5482
|
context
|
|
5487
5483
|
}), []);
|
|
5488
5484
|
nodes.unshift(quotes.shift());
|
|
@@ -5508,7 +5504,7 @@ const qblock = ({
|
|
|
5508
5504
|
nodes.unshift('');
|
|
5509
5505
|
return [nodes, ''];
|
|
5510
5506
|
};
|
|
5511
|
-
const text = (0, combinator_1.some)((0, combinator_1.
|
|
5507
|
+
const text = (0, combinator_1.some)((0, combinator_1.union)([math_1.math, autolink_1.autolink, source_1.linebreak, source_1.unescsource]));
|
|
5512
5508
|
|
|
5513
5509
|
/***/ }),
|
|
5514
5510
|
|
|
@@ -5702,7 +5698,7 @@ const shortmedia_1 = __webpack_require__(4189);
|
|
|
5702
5698
|
const autolink_1 = __webpack_require__(6051);
|
|
5703
5699
|
const bracket_1 = __webpack_require__(5196);
|
|
5704
5700
|
const source_1 = __webpack_require__(6743);
|
|
5705
|
-
exports.inline = (0, combinator_1.union)([annotation_1.annotation, reference_1.reference, template_1.template, comment_1.comment, math_1.math, extension_1.extension, ruby_1.ruby, link_1.
|
|
5701
|
+
exports.inline = (0, combinator_1.union)([annotation_1.annotation, reference_1.reference, template_1.template, comment_1.comment, math_1.math, extension_1.extension, ruby_1.ruby, link_1.textlink, link_1.linemedialink, media_1.linemedia, html_1.html, insertion_1.insertion, deletion_1.deletion, mark_1.mark, strong_1.strong, emphasis_1.emphasis, code_1.code, htmlentity_1.htmlentity, shortmedia_1.lineshortmedia, autolink_1.autolink, bracket_1.bracket, source_1.text]);
|
|
5706
5702
|
var indexee_1 = __webpack_require__(1269);
|
|
5707
5703
|
Object.defineProperty(exports, "indexee", ({
|
|
5708
5704
|
enumerable: true,
|
|
@@ -5776,7 +5772,7 @@ const hashnum_1 = __webpack_require__(5631);
|
|
|
5776
5772
|
const anchor_1 = __webpack_require__(6495);
|
|
5777
5773
|
const source_1 = __webpack_require__(6743);
|
|
5778
5774
|
const util_1 = __webpack_require__(9437);
|
|
5779
|
-
exports.autolink = (0, combinator_1.
|
|
5775
|
+
exports.autolink = (0, combinator_1.validate)(/^(?:[@#>0-9a-z\r\n]|\S[#>])/i, (0, combinator_1.constraint)(2 /* State.autolink */, false, (0, combinator_1.syntax)(2 /* Syntax.autolink */, 1, 1, ~1 /* State.shortcut */, (0, combinator_1.union)([(0, combinator_1.some)((0, combinator_1.union)([url_1.lineurl])), (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.union)([url_1.url, email_1.email,
|
|
5780
5776
|
// Escape unmatched email-like strings.
|
|
5781
5777
|
(0, combinator_1.focus)(/^[0-9a-z](?:[_.+-](?=[0-9a-z])|[0-9a-z])*(?:@(?:[0-9a-z]+(?:[.-][0-9a-z]+)*)?)*/i, ({
|
|
5782
5778
|
source
|
|
@@ -5793,7 +5789,7 @@ exports.autolink = (0, combinator_1.fmap)((0, combinator_1.validate)(/^(?:[@#>0-
|
|
|
5793
5789
|
// Escape unmatched hashtag-like strings.
|
|
5794
5790
|
(0, source_1.str)(new RegExp(/^#+(?:[^\p{C}\p{S}\p{P}\s]|emoji|')*/u.source.replace('emoji', hashtag_1.emoji), 'u')),
|
|
5795
5791
|
// Escape invalid leading characters.
|
|
5796
|
-
(0, source_1.str)(/^[0-9\p{Sc}](?=>)/u), anchor_1.anchor]))
|
|
5792
|
+
(0, source_1.str)(/^[0-9\p{Sc}](?=>)/u), anchor_1.anchor])), ns => ns.length === 1 ? ns : [(0, util_1.stringify)(ns)])]))));
|
|
5797
5793
|
|
|
5798
5794
|
/***/ }),
|
|
5799
5795
|
|
|
@@ -5949,12 +5945,13 @@ exports.hashtag = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combin
|
|
|
5949
5945
|
Object.defineProperty(exports, "__esModule", ({
|
|
5950
5946
|
value: true
|
|
5951
5947
|
}));
|
|
5952
|
-
exports.url = void 0;
|
|
5948
|
+
exports.lineurl = exports.url = void 0;
|
|
5953
5949
|
const combinator_1 = __webpack_require__(2087);
|
|
5954
5950
|
const link_1 = __webpack_require__(9628);
|
|
5955
5951
|
const source_1 = __webpack_require__(6743);
|
|
5956
5952
|
const closer = /^[-+*=~^_,.;:!?]*(?=[\\"`|\[\](){}<>]|$)/;
|
|
5957
5953
|
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])))));
|
|
5954
|
+
exports.lineurl = (0, combinator_1.open)(source_1.linebreak, (0, combinator_1.tails)([(0, source_1.str)('!'), (0, combinator_1.focus)(/^https?:\/\/\S+(?=[^\S\n]*(?:$|\n))/, (0, combinator_1.convert)(url => `{ ${url} }`, link_1.unsafelink))]));
|
|
5958
5955
|
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)]))));
|
|
5959
5956
|
|
|
5960
5957
|
/***/ }),
|
|
@@ -6149,6 +6146,7 @@ function identity(id, text, name = 'index') {
|
|
|
6149
6146
|
case 'index':
|
|
6150
6147
|
return `${name}:${id ?? ''}:${cs.slice(0, 97).join('')}...`;
|
|
6151
6148
|
case 'mark':
|
|
6149
|
+
case 'note':
|
|
6152
6150
|
return `${name}:${id ?? ''}:${cs.slice(0, 50).join('')}...${cs.slice(-47).join('')}`;
|
|
6153
6151
|
}
|
|
6154
6152
|
}
|
|
@@ -6419,7 +6417,7 @@ exports.insertion = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0,
|
|
|
6419
6417
|
Object.defineProperty(exports, "__esModule", ({
|
|
6420
6418
|
value: true
|
|
6421
6419
|
}));
|
|
6422
|
-
exports.resolve = exports.option = exports.uri = exports.unsafelink = exports.link = void 0;
|
|
6420
|
+
exports.resolve = exports.option = exports.uri = exports.unsafelink = exports.linemedialink = exports.medialink = exports.textlink = exports.link = void 0;
|
|
6423
6421
|
const combinator_1 = __webpack_require__(2087);
|
|
6424
6422
|
const inline_1 = __webpack_require__(1160);
|
|
6425
6423
|
const html_1 = __webpack_require__(5994);
|
|
@@ -6432,11 +6430,12 @@ const optspec = {
|
|
|
6432
6430
|
rel: ['nofollow']
|
|
6433
6431
|
};
|
|
6434
6432
|
Object.setPrototypeOf(optspec, null);
|
|
6435
|
-
exports.link = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['[', '{'], (0, combinator_1.union)([medialink, textlink])));
|
|
6436
|
-
|
|
6433
|
+
exports.link = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['[', '{'], (0, combinator_1.union)([exports.medialink, exports.textlink])));
|
|
6434
|
+
exports.textlink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(16 /* State.link */, false, (0, combinator_1.syntax)(16 /* Syntax.link */, 2, 10, 502 /* State.linkers */ | 8 /* State.media */, (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) => {
|
|
6437
6435
|
return parse(content, params, rest, context);
|
|
6438
6436
|
}))));
|
|
6439
|
-
|
|
6437
|
+
exports.medialink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(16 /* State.link */ | 8 /* State.media */, false, (0, combinator_1.syntax)(16 /* Syntax.link */, 2, 10, 502 /* State.linkers */, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.sequence)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.union)([inline_1.media, inline_1.shortmedia]), ']')), (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) => parse(content, params, rest, context)))));
|
|
6438
|
+
exports.linemedialink = (0, combinator_1.surround)(source_1.linebreak, (0, combinator_1.union)([exports.medialink]), /^(?=[^\S\n]*(?:$|\n))/);
|
|
6440
6439
|
exports.unsafelink = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(10, (0, combinator_1.precedence)(2, (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)([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) => parse(content, params, rest, context)))));
|
|
6441
6440
|
exports.uri = (0, combinator_1.union)([(0, combinator_1.open)(/^[^\S\n]+/, (0, source_1.str)(/^\S+/)), (0, source_1.str)(/^[^\s{}]+/)]);
|
|
6442
6441
|
exports.option = (0, combinator_1.union)([(0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+nofollow(?=[^\S\n]|})/), () => [` rel="nofollow"`]), (0, source_1.str)(/^[^\S\n]+[a-z]+(?:-[a-z]+)*(?:="(?:\\[^\n]|[^\\\n"])*")?(?=[^\S\n]|})/), (0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+[^\s{}]+/), opt => [` \\${opt.slice(1)}`])]);
|
|
@@ -6601,7 +6600,7 @@ const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.creation)((0, comb
|
|
|
6601
6600
|
Object.defineProperty(exports, "__esModule", ({
|
|
6602
6601
|
value: true
|
|
6603
6602
|
}));
|
|
6604
|
-
exports.media = void 0;
|
|
6603
|
+
exports.linemedia = exports.media = void 0;
|
|
6605
6604
|
const combinator_1 = __webpack_require__(2087);
|
|
6606
6605
|
const link_1 = __webpack_require__(9628);
|
|
6607
6606
|
const html_1 = __webpack_require__(5994);
|
|
@@ -6646,6 +6645,7 @@ exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['![', '
|
|
|
6646
6645
|
context
|
|
6647
6646
|
});
|
|
6648
6647
|
}))))));
|
|
6648
|
+
exports.linemedia = (0, combinator_1.surround)(source_1.linebreak, (0, combinator_1.union)([exports.media]), /^(?=[^\S\n]*(?:$|\n))/);
|
|
6649
6649
|
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)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ')'), (0, source_1.str)(')'), true, 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)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ']'), (0, source_1.str)(']'), true, 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)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), '}'), (0, source_1.str)('}'), true, 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)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, source_1.txt]), '"')), (0, source_1.str)('"'), true)])));
|
|
6650
6650
|
const option = (0, combinator_1.union)([(0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+[1-9][0-9]*x[1-9][0-9]*(?=[^\S\n]|})/), ([opt]) => [` width="${opt.slice(1).split('x')[0]}"`, ` height="${opt.slice(1).split('x')[1]}"`]), (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('/')}"`]), link_1.option]);
|
|
6651
6651
|
function sanitize(target, uri, alt) {
|
|
@@ -6825,11 +6825,13 @@ function attributes(texts, rubies) {
|
|
|
6825
6825
|
Object.defineProperty(exports, "__esModule", ({
|
|
6826
6826
|
value: true
|
|
6827
6827
|
}));
|
|
6828
|
-
exports.shortmedia = void 0;
|
|
6828
|
+
exports.lineshortmedia = exports.shortmedia = void 0;
|
|
6829
6829
|
const combinator_1 = __webpack_require__(2087);
|
|
6830
6830
|
const url_1 = __webpack_require__(4318);
|
|
6831
6831
|
const media_1 = __webpack_require__(1303);
|
|
6832
|
+
const source_1 = __webpack_require__(6743);
|
|
6832
6833
|
exports.shortmedia = (0, combinator_1.rewrite)((0, combinator_1.constraint)(8 /* State.media */, false, (0, combinator_1.open)('!', url_1.url)), (0, combinator_1.convert)(source => `!{ ${source.slice(1)} }`, (0, combinator_1.union)([media_1.media])));
|
|
6834
|
+
exports.lineshortmedia = (0, combinator_1.open)(source_1.linebreak, (0, combinator_1.focus)(/^!https?:\/\/\S+(?=[^\S\n]*(?:$|\n))/, (0, combinator_1.convert)(source => `!{ ${source.slice(1)} }`, (0, combinator_1.union)([media_1.media]))));
|
|
6833
6835
|
|
|
6834
6836
|
/***/ }),
|
|
6835
6837
|
|
|
@@ -7084,7 +7086,9 @@ function build(syntax, marker, splitter = '_') {
|
|
|
7084
7086
|
const ref = refs[i];
|
|
7085
7087
|
const identifier = ref.getAttribute('data-abbr') || ` ${ref.firstElementChild.innerHTML}`;
|
|
7086
7088
|
if (titles.has(identifier)) continue;
|
|
7087
|
-
const content = (0, dom_1.
|
|
7089
|
+
const content = (0, dom_1.html)('span', {
|
|
7090
|
+
id: (0, indexee_1.identity)(opts.id, (0, indexee_1.text)(ref.firstElementChild), 'note')
|
|
7091
|
+
}, ref.firstElementChild.cloneNode(true).childNodes);
|
|
7088
7092
|
const title = (0, indexee_1.text)(content).trim();
|
|
7089
7093
|
if (!title) continue;
|
|
7090
7094
|
titles.set(identifier, title);
|
|
@@ -7130,7 +7134,6 @@ function build(syntax, marker, splitter = '_') {
|
|
|
7130
7134
|
ref.lastChild?.remove();
|
|
7131
7135
|
}
|
|
7132
7136
|
const title = titles.get(identifier);
|
|
7133
|
-
const content = (0, dom_1.frag)(ref.firstElementChild.cloneNode(true).childNodes);
|
|
7134
7137
|
const refIndex = ++count;
|
|
7135
7138
|
const refId = opts.id !== '' ? `${syntax}:${opts.id ?? ''}:ref:${refIndex}` : undefined;
|
|
7136
7139
|
const def = false || defs.get(identifier) || defs.set(identifier, (0, dom_1.html)('li', {
|
|
@@ -7156,7 +7159,7 @@ function build(syntax, marker, splitter = '_') {
|
|
|
7156
7159
|
}, marker(defIndex, abbr)));
|
|
7157
7160
|
def.lastChild.appendChild((0, dom_1.html)('a', {
|
|
7158
7161
|
href: refId && `#${refId}`,
|
|
7159
|
-
title: abbr && (0, indexee_1.text)(
|
|
7162
|
+
title: abbr && (0, indexee_1.text)((0, dom_1.frag)(ref.firstElementChild.cloneNode(true).childNodes)).trim() || undefined
|
|
7160
7163
|
}, `^${refIndex}`));
|
|
7161
7164
|
}
|
|
7162
7165
|
if (defs.size > 0 || footnote) {
|
|
@@ -7336,7 +7339,8 @@ const combinator_1 = __webpack_require__(2087);
|
|
|
7336
7339
|
const text_1 = __webpack_require__(7763);
|
|
7337
7340
|
const delimiter = /[\s\x00-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]/;
|
|
7338
7341
|
exports.escsource = (0, combinator_1.creation)(1, false, ({
|
|
7339
|
-
source
|
|
7342
|
+
source,
|
|
7343
|
+
context
|
|
7340
7344
|
}) => {
|
|
7341
7345
|
if (source === '') return;
|
|
7342
7346
|
const i = source.search(delimiter);
|
|
@@ -7345,6 +7349,9 @@ exports.escsource = (0, combinator_1.creation)(1, false, ({
|
|
|
7345
7349
|
return [[source], ''];
|
|
7346
7350
|
case 0:
|
|
7347
7351
|
switch (source[0]) {
|
|
7352
|
+
case '\r':
|
|
7353
|
+
context.resources && ++context.resources.clock;
|
|
7354
|
+
return [[], source.slice(1)];
|
|
7348
7355
|
case '\x1B':
|
|
7349
7356
|
return [[source.slice(1, 2)], source.slice(2)];
|
|
7350
7357
|
case '\\':
|
|
@@ -7458,6 +7465,9 @@ exports.text = (0, combinator_1.creation)(1, false, ({
|
|
|
7458
7465
|
return [[source], ''];
|
|
7459
7466
|
case 0:
|
|
7460
7467
|
switch (source[0]) {
|
|
7468
|
+
case '\r':
|
|
7469
|
+
context.resources && ++context.resources.clock;
|
|
7470
|
+
return [[], source.slice(1)];
|
|
7461
7471
|
case '\x1B':
|
|
7462
7472
|
case '\\':
|
|
7463
7473
|
switch (source[1]) {
|
|
@@ -7489,7 +7499,7 @@ exports.text = (0, combinator_1.creation)(1, false, ({
|
|
|
7489
7499
|
}
|
|
7490
7500
|
});
|
|
7491
7501
|
exports.txt = (0, combinator_1.union)([exports.text]);
|
|
7492
|
-
exports.linebreak = (0, combinator_1.focus)(
|
|
7502
|
+
exports.linebreak = (0, combinator_1.focus)(/^[\r\n]/, (0, combinator_1.union)([exports.text]));
|
|
7493
7503
|
function isAlphanumeric(char) {
|
|
7494
7504
|
if (char < '0' || '\x7F' < char) return false;
|
|
7495
7505
|
return '0' <= char && char <= '9' || 'a' <= char && char <= 'z' || 'A' <= char && char <= 'Z';
|
|
@@ -7511,7 +7521,8 @@ exports.unescsource = void 0;
|
|
|
7511
7521
|
const combinator_1 = __webpack_require__(2087);
|
|
7512
7522
|
const text_1 = __webpack_require__(7763);
|
|
7513
7523
|
exports.unescsource = (0, combinator_1.creation)(1, false, ({
|
|
7514
|
-
source
|
|
7524
|
+
source,
|
|
7525
|
+
context
|
|
7515
7526
|
}) => {
|
|
7516
7527
|
if (source === '') return;
|
|
7517
7528
|
const i = source.search(text_1.delimiter);
|
|
@@ -7520,6 +7531,11 @@ exports.unescsource = (0, combinator_1.creation)(1, false, ({
|
|
|
7520
7531
|
return [[source], ''];
|
|
7521
7532
|
case 0:
|
|
7522
7533
|
{
|
|
7534
|
+
switch (source[0]) {
|
|
7535
|
+
case '\r':
|
|
7536
|
+
context.resources && ++context.resources.clock;
|
|
7537
|
+
return [[], source.slice(1)];
|
|
7538
|
+
}
|
|
7523
7539
|
const b = source[0] !== '\n' && source[0].trimStart() === '';
|
|
7524
7540
|
const i = b || (0, text_1.isAlphanumeric)(source[0]) ? source.search(b ? text_1.nonWhitespace : text_1.nonAlphanumeric) || 1 : 1;
|
|
7525
7541
|
return [[source.slice(0, i - +b || 1)], source.slice(i - +b || 1)];
|
|
@@ -7532,7 +7548,7 @@ exports.unescsource = (0, combinator_1.creation)(1, false, ({
|
|
|
7532
7548
|
/***/ }),
|
|
7533
7549
|
|
|
7534
7550
|
/***/ 9437:
|
|
7535
|
-
/***/ ((__unused_webpack_module, exports
|
|
7551
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
7536
7552
|
|
|
7537
7553
|
"use strict";
|
|
7538
7554
|
|
|
@@ -7540,12 +7556,7 @@ exports.unescsource = (0, combinator_1.creation)(1, false, ({
|
|
|
7540
7556
|
Object.defineProperty(exports, "__esModule", ({
|
|
7541
7557
|
value: true
|
|
7542
7558
|
}));
|
|
7543
|
-
exports.stringify =
|
|
7544
|
-
const combinator_1 = __webpack_require__(2087);
|
|
7545
|
-
function format(parser) {
|
|
7546
|
-
return (0, combinator_1.convert)(source => source.replace(/(?<=^!?)https?:\/\/(?:[[]|[^\p{C}\p{S}\p{P}\s])\S*(?=[^\S\n]*(?:$|\n))/gm, '{ $& }'), parser);
|
|
7547
|
-
}
|
|
7548
|
-
exports.format = format;
|
|
7559
|
+
exports.stringify = void 0;
|
|
7549
7560
|
function stringify(nodes) {
|
|
7550
7561
|
let acc = '';
|
|
7551
7562
|
for (let i = 0; i < nodes.length; ++i) {
|
|
@@ -7577,13 +7588,12 @@ const parser_1 = __webpack_require__(6728);
|
|
|
7577
7588
|
const combinator_1 = __webpack_require__(2087);
|
|
7578
7589
|
const htmlentity_1 = __webpack_require__(1562);
|
|
7579
7590
|
const source_1 = __webpack_require__(6743);
|
|
7580
|
-
const util_1 = __webpack_require__(9437);
|
|
7581
7591
|
const normalize_1 = __webpack_require__(185);
|
|
7582
7592
|
const memoize_1 = __webpack_require__(1808);
|
|
7583
7593
|
const array_1 = __webpack_require__(8112);
|
|
7584
7594
|
function visualize(parser) {
|
|
7585
7595
|
const blankline = new RegExp(/^(?:\\$|\\?[^\S\n]|&IHN;|<wbr[^\S\n]*>)+$/.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`), 'gm');
|
|
7586
|
-
return (0, combinator_1.union)([(0, combinator_1.convert)(source => source.replace(blankline, line => line.replace(/[\\&<]/g, '\x1B$&')), (0, combinator_1.verify)(
|
|
7596
|
+
return (0, combinator_1.union)([(0, combinator_1.convert)(source => source.replace(blankline, line => line.replace(/[\\&<]/g, '\x1B$&')), (0, combinator_1.verify)(parser, (ns, rest, context) => !rest && hasVisible(ns, context))), (0, combinator_1.some)((0, combinator_1.union)([source_1.linebreak, source_1.unescsource]))]);
|
|
7587
7597
|
}
|
|
7588
7598
|
exports.visualize = visualize;
|
|
7589
7599
|
function hasVisible(nodes, {
|
package/markdown.d.ts
CHANGED
|
@@ -346,7 +346,7 @@ export namespace MarkdownParser {
|
|
|
346
346
|
BlockquoteParser,
|
|
347
347
|
PlaceholderParser,
|
|
348
348
|
InlineParser.MediaParser,
|
|
349
|
-
InlineParser.
|
|
349
|
+
InlineParser.ShortMediaParser,
|
|
350
350
|
]>,
|
|
351
351
|
SourceParser.EmptyLineParser,
|
|
352
352
|
InlineParser,
|
|
@@ -598,13 +598,10 @@ export namespace MarkdownParser {
|
|
|
598
598
|
export interface TextParser extends
|
|
599
599
|
Block<'reply/quote/text'>,
|
|
600
600
|
Parser<string | HTMLElement, Context, [
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
SourceParser.LinebreakParser,
|
|
606
|
-
SourceParser.UnescapableSourceParser,
|
|
607
|
-
]>,
|
|
601
|
+
InlineParser.MathParser,
|
|
602
|
+
InlineParser.AutolinkParser,
|
|
603
|
+
SourceParser.LinebreakParser,
|
|
604
|
+
SourceParser.UnescapableSourceParser,
|
|
608
605
|
]> {
|
|
609
606
|
}
|
|
610
607
|
export interface PlaceholderParser extends
|
|
@@ -633,8 +630,9 @@ export namespace MarkdownParser {
|
|
|
633
630
|
InlineParser.MathParser,
|
|
634
631
|
InlineParser.ExtensionParser,
|
|
635
632
|
InlineParser.RubyParser,
|
|
636
|
-
InlineParser.LinkParser,
|
|
637
|
-
InlineParser.
|
|
633
|
+
InlineParser.LinkParser.TextLinkParser,
|
|
634
|
+
InlineParser.LinkParser.LineMediaLinkParser,
|
|
635
|
+
InlineParser.MediaParser.LineMediaParser,
|
|
638
636
|
InlineParser.HTMLParser,
|
|
639
637
|
InlineParser.InsertionParser,
|
|
640
638
|
InlineParser.DeletionParser,
|
|
@@ -643,7 +641,7 @@ export namespace MarkdownParser {
|
|
|
643
641
|
InlineParser.EmphasisParser,
|
|
644
642
|
InlineParser.CodeParser,
|
|
645
643
|
InlineParser.HTMLEntityParser,
|
|
646
|
-
InlineParser.
|
|
644
|
+
InlineParser.ShortMediaParser.LineShortMediaParser,
|
|
647
645
|
InlineParser.AutolinkParser,
|
|
648
646
|
InlineParser.BracketParser,
|
|
649
647
|
SourceParser.TextParser,
|
|
@@ -842,6 +840,12 @@ export namespace MarkdownParser {
|
|
|
842
840
|
]> {
|
|
843
841
|
}
|
|
844
842
|
export namespace LinkParser {
|
|
843
|
+
export interface LineMediaLinkParser extends
|
|
844
|
+
Inline<'link/linemedialink'>,
|
|
845
|
+
Parser<HTMLElement, Context, [
|
|
846
|
+
LinkParser.MediaLinkParser,
|
|
847
|
+
]> {
|
|
848
|
+
}
|
|
845
849
|
export interface TextLinkParser extends
|
|
846
850
|
Inline<'link/textlink'>,
|
|
847
851
|
Parser<HTMLAnchorElement, Context, [
|
|
@@ -856,7 +860,7 @@ export namespace MarkdownParser {
|
|
|
856
860
|
Parser<HTMLAnchorElement, Context, [
|
|
857
861
|
Parser<HTMLElement[], Context, [
|
|
858
862
|
MediaParser,
|
|
859
|
-
|
|
863
|
+
ShortMediaParser,
|
|
860
864
|
]>,
|
|
861
865
|
LinkParser.ParameterParser,
|
|
862
866
|
]> {
|
|
@@ -872,7 +876,7 @@ export namespace MarkdownParser {
|
|
|
872
876
|
Inline<'link/content'>,
|
|
873
877
|
Parser<(HTMLElement | string)[], Context, [
|
|
874
878
|
MediaParser,
|
|
875
|
-
|
|
879
|
+
ShortMediaParser,
|
|
876
880
|
InlineParser,
|
|
877
881
|
]> {
|
|
878
882
|
}
|
|
@@ -917,6 +921,12 @@ export namespace MarkdownParser {
|
|
|
917
921
|
]> {
|
|
918
922
|
}
|
|
919
923
|
export namespace MediaParser {
|
|
924
|
+
export interface LineMediaParser extends
|
|
925
|
+
Inline<'media/linemedia'>,
|
|
926
|
+
Parser<HTMLElement, Context, [
|
|
927
|
+
MediaParser,
|
|
928
|
+
]> {
|
|
929
|
+
}
|
|
920
930
|
export interface TextParser extends
|
|
921
931
|
Inline<'media/text'>,
|
|
922
932
|
Parser<string[], Context, [
|
|
@@ -1060,28 +1070,41 @@ export namespace MarkdownParser {
|
|
|
1060
1070
|
Inline<'unsafehtmlentity'>,
|
|
1061
1071
|
Parser<string, Context, []> {
|
|
1062
1072
|
}
|
|
1063
|
-
export interface
|
|
1073
|
+
export interface ShortMediaParser extends
|
|
1064
1074
|
// !https://host
|
|
1065
1075
|
Inline<'shortmedia'>,
|
|
1066
1076
|
Parser<HTMLElement, Context, [
|
|
1067
1077
|
MediaParser,
|
|
1068
1078
|
]> {
|
|
1069
1079
|
}
|
|
1080
|
+
export namespace ShortMediaParser {
|
|
1081
|
+
export interface LineShortMediaParser extends
|
|
1082
|
+
Inline<'shortmedia/lineshortmedia'>,
|
|
1083
|
+
Parser<HTMLElement, Context, [
|
|
1084
|
+
MediaParser,
|
|
1085
|
+
]> {
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1070
1088
|
export interface AutolinkParser extends
|
|
1071
1089
|
Inline<'autolink'>,
|
|
1072
1090
|
Parser<HTMLElement | string, Context, [
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1091
|
+
Parser<HTMLElement | string, Context, [
|
|
1092
|
+
AutolinkParser.UrlParser.LineUrlParser,
|
|
1093
|
+
]>,
|
|
1094
|
+
Parser<HTMLElement | string, Context, [
|
|
1095
|
+
AutolinkParser.UrlParser,
|
|
1096
|
+
AutolinkParser.EmailParser,
|
|
1097
|
+
SourceParser.StrParser,
|
|
1098
|
+
AutolinkParser.ChannelParser,
|
|
1099
|
+
AutolinkParser.AccountParser,
|
|
1100
|
+
SourceParser.StrParser,
|
|
1101
|
+
SourceParser.StrParser,
|
|
1102
|
+
AutolinkParser.HashtagParser,
|
|
1103
|
+
AutolinkParser.HashnumParser,
|
|
1104
|
+
SourceParser.StrParser,
|
|
1105
|
+
SourceParser.StrParser,
|
|
1106
|
+
AutolinkParser.AnchorParser,
|
|
1107
|
+
]>,
|
|
1085
1108
|
]> {
|
|
1086
1109
|
}
|
|
1087
1110
|
export namespace AutolinkParser {
|
|
@@ -1093,6 +1116,13 @@ export namespace MarkdownParser {
|
|
|
1093
1116
|
]> {
|
|
1094
1117
|
}
|
|
1095
1118
|
export namespace UrlParser {
|
|
1119
|
+
export interface LineUrlParser extends
|
|
1120
|
+
Inline<'url/lineurl'>,
|
|
1121
|
+
Parser<string | HTMLElement, Context, [
|
|
1122
|
+
SourceParser.StrParser,
|
|
1123
|
+
InlineParser.LinkParser.UnsafeLinkParser,
|
|
1124
|
+
]> {
|
|
1125
|
+
}
|
|
1096
1126
|
export interface BracketParser extends
|
|
1097
1127
|
Inline<'url/bracket'>,
|
|
1098
1128
|
Parser<string, Context, [
|
|
@@ -1176,23 +1206,11 @@ export namespace MarkdownParser {
|
|
|
1176
1206
|
export interface AutolinkParser extends
|
|
1177
1207
|
Markdown<'autolink'>,
|
|
1178
1208
|
Parser<string | HTMLElement, Context, [
|
|
1179
|
-
AutolinkParser
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
SourceParser.LinebreakParser,
|
|
1183
|
-
SourceParser.UnescapableSourceParser,
|
|
1184
|
-
]>,
|
|
1209
|
+
InlineParser.AutolinkParser,
|
|
1210
|
+
SourceParser.LinebreakParser,
|
|
1211
|
+
SourceParser.UnescapableSourceParser,
|
|
1185
1212
|
]> {
|
|
1186
1213
|
}
|
|
1187
|
-
export namespace AutolinkParser {
|
|
1188
|
-
export interface LineUrlParser extends
|
|
1189
|
-
Markdown<'autolink/lineurl'>,
|
|
1190
|
-
Parser<string | HTMLElement, Context, [
|
|
1191
|
-
SourceParser.StrParser,
|
|
1192
|
-
InlineParser.LinkParser,
|
|
1193
|
-
]> {
|
|
1194
|
-
}
|
|
1195
|
-
}
|
|
1196
1214
|
export namespace SourceParser {
|
|
1197
1215
|
interface Source<T extends string> extends Markdown<`source/${T}`> { }
|
|
1198
1216
|
export interface TextParser extends
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "securemark",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.269.1",
|
|
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",
|
|
@@ -28,17 +28,17 @@
|
|
|
28
28
|
"LICENSE"
|
|
29
29
|
],
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@types/dompurify": "
|
|
31
|
+
"@types/dompurify": "3.0.0",
|
|
32
32
|
"@types/jquery": "3.5.16",
|
|
33
33
|
"@types/mathjax": "0.0.37",
|
|
34
34
|
"@types/mocha": "10.0.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.55.0",
|
|
38
38
|
"babel-loader": "^9.1.2",
|
|
39
39
|
"babel-plugin-unassert": "^3.2.0",
|
|
40
40
|
"concurrently": "^7.6.0",
|
|
41
|
-
"eslint": "^8.
|
|
41
|
+
"eslint": "^8.36.0",
|
|
42
42
|
"eslint-plugin-redos": "^4.4.5",
|
|
43
43
|
"eslint-webpack-plugin": "^4.0.0",
|
|
44
44
|
"glob": "^8.1.0",
|
|
@@ -49,13 +49,13 @@
|
|
|
49
49
|
"karma-mocha": "^2.0.1",
|
|
50
50
|
"karma-power-assert": "^1.0.0",
|
|
51
51
|
"mocha": "^10.2.0",
|
|
52
|
-
"npm-check-updates": "^16.7.
|
|
52
|
+
"npm-check-updates": "^16.7.12",
|
|
53
53
|
"semver": "^7.3.8",
|
|
54
54
|
"spica": "0.0.719",
|
|
55
55
|
"ts-loader": "^9.4.2",
|
|
56
56
|
"typed-dom": "^0.0.317",
|
|
57
57
|
"typescript": "4.9.5",
|
|
58
|
-
"webpack": "^5.
|
|
58
|
+
"webpack": "^5.76.1",
|
|
59
59
|
"webpack-cli": "^5.0.1",
|
|
60
60
|
"webpack-merge": "^5.8.0"
|
|
61
61
|
},
|
|
@@ -214,15 +214,15 @@ describe('Unit: parser/api/bind', () => {
|
|
|
214
214
|
cfgs.footnotes.references?.outerHTML,
|
|
215
215
|
html('ol', [
|
|
216
216
|
html('li', { id: 'reference::def:1' }, [
|
|
217
|
-
'1',
|
|
217
|
+
html('span', { id: 'note::1' }, '1'),
|
|
218
218
|
html('sup', [html('a', { href: '#reference::ref:1' }, '^1')]),
|
|
219
219
|
]),
|
|
220
220
|
html('li', { id: 'reference::def:2' }, [
|
|
221
|
-
'2',
|
|
221
|
+
html('span', { id: 'note::2' }, '2'),
|
|
222
222
|
html('sup', [html('a', { href: '#reference::ref:2' }, '^2')]),
|
|
223
223
|
]),
|
|
224
224
|
html('li', { id: 'reference::def:3' }, [
|
|
225
|
-
'3',
|
|
225
|
+
html('span', { id: 'note::3' }, '3'),
|
|
226
226
|
html('sup', [html('a', { href: '#reference::ref:3' }, '^3')]),
|
|
227
227
|
]),
|
|
228
228
|
]).outerHTML);
|
|
@@ -135,7 +135,7 @@ describe('Unit: parser/api/parse', () => {
|
|
|
135
135
|
'<p><a href="https://source/x/a" target="_blank"><img class="media" data-src="https://source/x/a" alt=""></a></p>',
|
|
136
136
|
'<p><a href="/z/a" target="_blank"><img class="media" data-src="/z/a" alt=""></a></p>',
|
|
137
137
|
'<p><a href="https://source/a" target="_blank"><img class="media" data-src="https://source/a" alt=""></a></p>',
|
|
138
|
-
'<ol class="annotations"><li id="annotation::def:1" data-marker="*1">a
|
|
138
|
+
'<ol class="annotations"><li id="annotation::def:1" data-marker="*1"><span id="note::a">a</span><sup><a href="#annotation::ref:1">^1</a></sup></li></ol>',
|
|
139
139
|
]);
|
|
140
140
|
assert.deepStrictEqual(
|
|
141
141
|
[...parse([
|
|
@@ -208,11 +208,11 @@ describe('Unit: parser/api/parse', () => {
|
|
|
208
208
|
[
|
|
209
209
|
'<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>',
|
|
210
210
|
'<p><sup class="annotation" id="annotation::ref:1" title="(1)"><span hidden=""><a class="label" data-label="$-a" href="#label:$-a">(1)</a><sup class="reference" id="reference::ref:1" title="b"><span hidden="">b</span><a href="#reference::def:1">[1]</a></sup><sup class="reference" id="reference::ref:2" title="cd"><span hidden="">c<em>d</em></span><a href="#reference::def:2">[2]</a></sup></span><a href="#annotation::def:1">*1</a></sup></p>',
|
|
211
|
-
'<ol class="annotations"><li id="annotation::def:1" data-marker="*1"><a class="label" data-label="$-a" href="#label:$-a">(1)</a><sup class="reference" id="reference::ref:1" title="b"><span hidden="">b</span><a href="#reference::def:1">[1]</a></sup><sup class="reference" id="reference::ref:2" title="cd"><span hidden="">c<em>d</em></span><a href="#reference::def:2">[2]</a></sup><sup><a href="#annotation::ref:1">^1</a></sup></li></ol>',
|
|
211
|
+
'<ol class="annotations"><li id="annotation::def:1" data-marker="*1"><span id="note::(1)"><a class="label" data-label="$-a" href="#label:$-a">(1)</a><sup class="reference" id="reference::ref:1" title="b"><span hidden="">b</span><a href="#reference::def:1">[1]</a></sup><sup class="reference" id="reference::ref:2" title="cd"><span hidden="">c<em>d</em></span><a href="#reference::def:2">[2]</a></sup></span><sup><a href="#annotation::ref:1">^1</a></sup></li></ol>',
|
|
212
212
|
]);
|
|
213
213
|
assert.deepStrictEqual(
|
|
214
214
|
footnotes.references.outerHTML,
|
|
215
|
-
'<ol><li id="reference::def:1">b
|
|
215
|
+
'<ol><li id="reference::def:1"><span id="note::b">b</span><sup><a href="#reference::ref:1">^1</a></sup></li><li id="reference::def:2"><span id="note::cd">c<em>d</em></span><sup><a href="#reference::ref:2">^2</a></sup></li></ol>');
|
|
216
216
|
});
|
|
217
217
|
|
|
218
218
|
it('normalize', () => {
|
|
@@ -6,8 +6,8 @@ describe('Unit: parser/autolink', () => {
|
|
|
6
6
|
const parser = (source: string) => autolink({ source, context: {} });
|
|
7
7
|
|
|
8
8
|
it('basic', () => {
|
|
9
|
-
assert.deepStrictEqual(inspect(parser('
|
|
10
|
-
assert.deepStrictEqual(inspect(parser('!http://host')), [['!', '<a class="url" href="http://host" target="_blank">http://host
|
|
9
|
+
assert.deepStrictEqual(inspect(parser('http://host#\\')), [['<a class="url" href="http://host#\\" target="_blank">http://host#\\</a>'], '']);
|
|
10
|
+
assert.deepStrictEqual(inspect(parser('!http://host#\\')), [['!', '<a class="url" href="http://host#\\" target="_blank">http://host#\\</a>'], '']);
|
|
11
11
|
assert.deepStrictEqual(inspect(parser('#a')), [['<a class="hashtag" href="/hashtags/a">#a</a>'], '']);
|
|
12
12
|
assert.deepStrictEqual(inspect(parser('@a#b')), [['<a class="channel" href="/@a?ch=b">@a#b</a>'], '']);
|
|
13
13
|
assert.deepStrictEqual(inspect(parser('\\\n')), [['\\', '<br>'], '']);
|
package/src/parser/autolink.ts
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
import { MarkdownParser } from '../../markdown';
|
|
2
|
-
import { union,
|
|
3
|
-
import { link } from './inline/link';
|
|
2
|
+
import { union, some, convert, lazy } from '../combinator';
|
|
4
3
|
import { autolink as autolink_ } from './inline/autolink';
|
|
5
|
-
import { linebreak, unescsource
|
|
6
|
-
import { format } from './util';
|
|
4
|
+
import { linebreak, unescsource } from './source';
|
|
7
5
|
|
|
8
6
|
export import AutolinkParser = MarkdownParser.AutolinkParser;
|
|
9
7
|
|
|
10
|
-
export const autolink: AutolinkParser = lazy(() =>
|
|
11
|
-
|
|
8
|
+
export const autolink: AutolinkParser = lazy(() =>
|
|
9
|
+
convert(source => `\r${source}`,
|
|
12
10
|
some(union([
|
|
13
11
|
autolink_,
|
|
14
12
|
linebreak,
|
|
15
13
|
unescsource,
|
|
16
|
-
]))
|
|
17
|
-
]))));
|
|
18
|
-
|
|
19
|
-
export const lineurl: AutolinkParser.LineUrlParser = lazy(() => focus(
|
|
20
|
-
/^!?https?:\/\/\S+(?=[^\S\n]*(?:$|\n))/,
|
|
21
|
-
format(tails([str('!'), link]))));
|
|
14
|
+
]))));
|