securemark 0.280.2 → 0.280.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 +4 -0
- package/dist/index.js +32 -33
- package/markdown.d.ts +22 -22
- package/package.json +1 -1
- package/src/combinator/control/constraint/block.ts +0 -2
- package/src/combinator/control/constraint/line.ts +0 -2
- package/src/combinator/control/manipulation/fence.ts +2 -2
- package/src/combinator/data/parser/context/memo.ts +7 -3
- package/src/combinator/data/parser/context.ts +5 -7
- package/src/combinator/data/parser/some.ts +1 -1
- package/src/parser/block.ts +5 -2
- package/src/parser/context.ts +15 -13
- package/src/parser/inline/annotation.ts +1 -1
- package/src/parser/inline/htmlentity.ts +1 -1
- package/src/parser/inline/media.ts +7 -4
- package/src/parser/inline/template.ts +6 -3
- package/src/parser/inline.ts +5 -5
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.280.
|
|
1
|
+
/*! securemark v0.280.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("Prism"), require("DOMPurify"));
|
|
@@ -2682,7 +2682,6 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
2682
2682
|
}));
|
|
2683
2683
|
exports.block = void 0;
|
|
2684
2684
|
const parser_1 = __webpack_require__(6728);
|
|
2685
|
-
const memo_1 = __webpack_require__(1090);
|
|
2686
2685
|
const line_1 = __webpack_require__(9315);
|
|
2687
2686
|
function block(parser, separation = true) {
|
|
2688
2687
|
return ({
|
|
@@ -2690,7 +2689,6 @@ function block(parser, separation = true) {
|
|
|
2690
2689
|
context
|
|
2691
2690
|
}) => {
|
|
2692
2691
|
if (source === '') return;
|
|
2693
|
-
context.memo ??= new memo_1.Memo();
|
|
2694
2692
|
const result = parser({
|
|
2695
2693
|
source,
|
|
2696
2694
|
context
|
|
@@ -2767,14 +2765,12 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
2767
2765
|
}));
|
|
2768
2766
|
exports.isBlank = exports.firstline = exports.line = void 0;
|
|
2769
2767
|
const parser_1 = __webpack_require__(6728);
|
|
2770
|
-
const memo_1 = __webpack_require__(1090);
|
|
2771
2768
|
function line(parser) {
|
|
2772
2769
|
return ({
|
|
2773
2770
|
source,
|
|
2774
2771
|
context
|
|
2775
2772
|
}) => {
|
|
2776
2773
|
if (source === '') return;
|
|
2777
|
-
context.memo ??= new memo_1.Memo();
|
|
2778
2774
|
const line = firstline(source);
|
|
2779
2775
|
context.offset ??= 0;
|
|
2780
2776
|
context.offset += source.length - line.length;
|
|
@@ -2927,7 +2923,7 @@ function fence(opener, limit, separation = true) {
|
|
|
2927
2923
|
}
|
|
2928
2924
|
rest = rest.slice(line.length);
|
|
2929
2925
|
}
|
|
2930
|
-
return [(0, array_1.
|
|
2926
|
+
return [(0, array_1.push)([block, overflow, closer], matches), rest];
|
|
2931
2927
|
};
|
|
2932
2928
|
}
|
|
2933
2929
|
exports.fence = fence;
|
|
@@ -3384,16 +3380,15 @@ function syntax(syntax, prec, state, parser) {
|
|
|
3384
3380
|
const position = source.length + context.offset;
|
|
3385
3381
|
const stateOuter = context.state ?? 0;
|
|
3386
3382
|
const stateInner = context.state = stateOuter | state;
|
|
3387
|
-
const cache = syntax
|
|
3383
|
+
const cache = syntax & memo.targets && stateInner && memo.get(position, syntax, stateInner);
|
|
3388
3384
|
const result = cache ? cache.length === 0 ? undefined : [cache[0], source.slice(cache[1])] : parser({
|
|
3389
3385
|
source,
|
|
3390
3386
|
context
|
|
3391
3387
|
});
|
|
3392
|
-
if (
|
|
3393
|
-
|
|
3394
|
-
}
|
|
3395
|
-
|
|
3396
|
-
memo.resize(position + 2);
|
|
3388
|
+
if (stateOuter && !cache && syntax & memo.targets) {
|
|
3389
|
+
memo.set(position, syntax, stateInner, (0, parser_1.eval)(result), source.length - (0, parser_1.exec)(result, '').length);
|
|
3390
|
+
} else if (!stateOuter && result && memo.length >= position + memo.margin) {
|
|
3391
|
+
memo.resize(position + memo.margin);
|
|
3397
3392
|
}
|
|
3398
3393
|
context.state = stateOuter;
|
|
3399
3394
|
return result;
|
|
@@ -3626,20 +3621,23 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
3626
3621
|
}));
|
|
3627
3622
|
exports.Memo = void 0;
|
|
3628
3623
|
class Memo {
|
|
3629
|
-
constructor(targets = ~0) {
|
|
3624
|
+
constructor(targets = ~0, margin = 0) {
|
|
3630
3625
|
this.targets = targets;
|
|
3626
|
+
this.margin = margin;
|
|
3631
3627
|
this.memory = [];
|
|
3632
|
-
this.
|
|
3628
|
+
this.count = 0;
|
|
3633
3629
|
}
|
|
3634
3630
|
get length() {
|
|
3635
3631
|
return this.memory.length;
|
|
3636
3632
|
}
|
|
3637
3633
|
get(position, syntax, state) {
|
|
3634
|
+
if (this.count === 0) return;
|
|
3638
3635
|
//console.log('get', position, syntax, state, this.memory[position - 1]?.[syntax]?.[state]);
|
|
3639
3636
|
const cache = this.memory[position - 1]?.[syntax]?.[state];
|
|
3640
3637
|
return cache?.length === 2 ? [cache[0].slice(), cache[1]] : cache;
|
|
3641
3638
|
}
|
|
3642
3639
|
set(position, syntax, state, nodes, offset) {
|
|
3640
|
+
this.count += +!this.memory[position - 1];
|
|
3643
3641
|
const record = this.memory[position - 1] ??= {};
|
|
3644
3642
|
(record[syntax] ??= {})[state] = nodes ? [nodes.slice(), offset] : [];
|
|
3645
3643
|
//console.log('set', position, syntax, state, record[syntax]?.[state]);
|
|
@@ -3648,13 +3646,14 @@ class Memo {
|
|
|
3648
3646
|
resize(position) {
|
|
3649
3647
|
const memory = this.memory;
|
|
3650
3648
|
for (let len = memory.length, i = position; i < len; ++i) {
|
|
3651
|
-
memory.pop();
|
|
3649
|
+
this.count -= +memory.pop();
|
|
3652
3650
|
}
|
|
3653
|
-
//console.log('resize', position
|
|
3651
|
+
//console.log('resize', position);
|
|
3654
3652
|
}
|
|
3655
3653
|
|
|
3656
3654
|
clear() {
|
|
3657
3655
|
this.memory = [];
|
|
3656
|
+
this.count = 0;
|
|
3658
3657
|
}
|
|
3659
3658
|
}
|
|
3660
3659
|
exports.Memo = Memo;
|
|
@@ -3780,7 +3779,7 @@ function some(parser, end, delimiters = [], limit = -1) {
|
|
|
3780
3779
|
context
|
|
3781
3780
|
});
|
|
3782
3781
|
if (result === undefined) break;
|
|
3783
|
-
nodes = nodes ? nodes.length < (0, parser_1.eval)(result).length ? (0, array_1.unshift)(nodes, (0, parser_1.eval)(result)) : (0, array_1.push)(nodes, (0, parser_1.eval)(result)) : (0, parser_1.eval)(result);
|
|
3782
|
+
nodes = nodes ? nodes.length < (0, parser_1.eval)(result).length / 8 ? (0, array_1.unshift)(nodes, (0, parser_1.eval)(result)) : (0, array_1.push)(nodes, (0, parser_1.eval)(result)) : (0, parser_1.eval)(result);
|
|
3784
3783
|
rest = (0, parser_1.exec)(result);
|
|
3785
3784
|
if (limit >= 0 && source.length - rest.length > limit) break;
|
|
3786
3785
|
}
|
|
@@ -4376,7 +4375,7 @@ exports.block = (0, combinator_1.creation)(0, false, (0, combinator_1.reset)({
|
|
|
4376
4375
|
clock: 20000,
|
|
4377
4376
|
recursion: 20 + 1
|
|
4378
4377
|
},
|
|
4379
|
-
memo: new memo_1.Memo(
|
|
4378
|
+
memo: new memo_1.Memo(508 /* Syntax.targets */, 2)
|
|
4380
4379
|
}, error((0, combinator_1.union)([source_1.emptyline, pagebreak_1.pagebreak, heading_1.heading, ulist_1.ulist, olist_1.olist, ilist_1.ilist, dlist_1.dlist, table_1.table, codeblock_1.codeblock, mathblock_1.mathblock, extension_1.extension, sidefence_1.sidefence, blockquote_1.blockquote, mediablock_1.mediablock, reply_1.reply, paragraph_1.paragraph]))));
|
|
4381
4380
|
function error(parser) {
|
|
4382
4381
|
return (0, combinator_1.recover)((0, combinator_1.fallback)((0, combinator_1.open)('\x07', ({
|
|
@@ -5770,7 +5769,6 @@ const annotation_1 = __webpack_require__(2736);
|
|
|
5770
5769
|
const reference_1 = __webpack_require__(3555);
|
|
5771
5770
|
const template_1 = __webpack_require__(4695);
|
|
5772
5771
|
const remark_1 = __webpack_require__(3217);
|
|
5773
|
-
const math_1 = __webpack_require__(8946);
|
|
5774
5772
|
const extension_1 = __webpack_require__(8053);
|
|
5775
5773
|
const ruby_1 = __webpack_require__(6705);
|
|
5776
5774
|
const link_1 = __webpack_require__(9628);
|
|
@@ -5779,14 +5777,15 @@ const insertion_1 = __webpack_require__(2945);
|
|
|
5779
5777
|
const deletion_1 = __webpack_require__(7501);
|
|
5780
5778
|
const mark_1 = __webpack_require__(2480);
|
|
5781
5779
|
const emstrong_1 = __webpack_require__(6132);
|
|
5782
|
-
const emphasis_1 = __webpack_require__(3867);
|
|
5783
5780
|
const strong_1 = __webpack_require__(6578);
|
|
5781
|
+
const emphasis_1 = __webpack_require__(3867);
|
|
5782
|
+
const math_1 = __webpack_require__(8946);
|
|
5784
5783
|
const code_1 = __webpack_require__(5771);
|
|
5785
5784
|
const htmlentity_1 = __webpack_require__(1562);
|
|
5786
5785
|
const autolink_1 = __webpack_require__(6051);
|
|
5787
5786
|
const bracket_1 = __webpack_require__(5196);
|
|
5788
5787
|
const source_1 = __webpack_require__(6743);
|
|
5789
|
-
exports.inline = (0, combinator_1.lazy)(() => (0, combinator_1.union)([annotation_1.annotation, reference_1.reference, template_1.template, remark_1.remark,
|
|
5788
|
+
exports.inline = (0, combinator_1.lazy)(() => (0, combinator_1.union)([annotation_1.annotation, reference_1.reference, template_1.template, remark_1.remark, extension_1.extension, ruby_1.ruby, link_1.textlink, html_1.html, insertion_1.insertion, deletion_1.deletion, mark_1.mark, emstrong_1.emstrong, strong_1.strong, emphasis_1.emphasis, math_1.math, code_1.code, htmlentity_1.htmlentity, autolink_1.autolink, bracket_1.bracket, source_1.text]));
|
|
5790
5789
|
var indexee_1 = __webpack_require__(1269);
|
|
5791
5790
|
Object.defineProperty(exports, "indexee", ({
|
|
5792
5791
|
enumerable: true,
|
|
@@ -5839,7 +5838,7 @@ const combinator_1 = __webpack_require__(2087);
|
|
|
5839
5838
|
const inline_1 = __webpack_require__(1160);
|
|
5840
5839
|
const visibility_1 = __webpack_require__(7618);
|
|
5841
5840
|
const dom_1 = __webpack_require__(3252);
|
|
5842
|
-
exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.creation)((0, combinator_1.surround)('((', (0, combinator_1.constraint)(256 /* State.annotation */, false, (0, combinator_1.syntax)(
|
|
5841
|
+
exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.creation)((0, combinator_1.surround)('((', (0, combinator_1.constraint)(256 /* State.annotation */, false, (0, combinator_1.syntax)(256 /* Syntax.annotation */, 6, 256 /* State.annotation */ | 8 /* State.media */, (0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ')', [[/^\\?\n/, 9], [')', 2], ['))', 6]])))), '))', false, ([, ns], rest) => [[(0, dom_1.html)('sup', {
|
|
5843
5842
|
class: 'annotation'
|
|
5844
5843
|
}, [(0, dom_1.html)('span', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))])], rest])));
|
|
5845
5844
|
|
|
@@ -6058,11 +6057,11 @@ const source_1 = __webpack_require__(6743);
|
|
|
6058
6057
|
const array_1 = __webpack_require__(8112);
|
|
6059
6058
|
const dom_1 = __webpack_require__(3252);
|
|
6060
6059
|
const index = /^[0-9A-Za-z]+(?:(?:[.-]|, )[0-9A-Za-z]+)*/;
|
|
6061
|
-
exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.creation)((0, combinator_1.syntax)(0 /* Syntax.none */, 2, 0 /* State.none */, (0, source_1.str)(index))), (0, source_1.str)(')')), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.creation)((0, combinator_1.syntax)(
|
|
6060
|
+
exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.creation)((0, combinator_1.syntax)(0 /* Syntax.none */, 2, 0 /* State.none */, (0, source_1.str)(index))), (0, source_1.str)(')')), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.creation)((0, combinator_1.syntax)(4 /* Syntax.bracket */, 2, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, ')', [[/^\\?\n/, 3], [')', 2]]))), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest) => [[(0, dom_1.html)('span', {
|
|
6062
6061
|
class: 'paren'
|
|
6063
|
-
}, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))], rest], ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.creation)((0, combinator_1.syntax)(0 /* Syntax.none */, 2, 0 /* State.none */, (0, source_1.str)(new RegExp(index.source.replace(', ', '[,、]').replace(/[09AZaz.]|\-(?!\w)/g, c => c.trimStart() && String.fromCharCode(c.charCodeAt(0) + 0xFEE0)))))), (0, source_1.str)(')')), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.creation)((0, combinator_1.syntax)(
|
|
6062
|
+
}, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))], rest], ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.creation)((0, combinator_1.syntax)(0 /* Syntax.none */, 2, 0 /* State.none */, (0, source_1.str)(new RegExp(index.source.replace(', ', '[,、]').replace(/[09AZaz.]|\-(?!\w)/g, c => c.trimStart() && String.fromCharCode(c.charCodeAt(0) + 0xFEE0)))))), (0, source_1.str)(')')), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.creation)((0, combinator_1.syntax)(4 /* Syntax.bracket */, 2, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, ')', [[/^\\?\n/, 3], [')', 2]]))), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest) => [[(0, dom_1.html)('span', {
|
|
6064
6063
|
class: 'paren'
|
|
6065
|
-
}, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))], rest], ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.creation)((0, combinator_1.syntax)(
|
|
6064
|
+
}, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))], rest], ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.creation)((0, combinator_1.syntax)(4 /* Syntax.bracket */, 2, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 3], [']', 2]]))), (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.creation)((0, combinator_1.syntax)(4 /* Syntax.bracket */, 2, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 3], [']', 2]]))), (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.creation)((0, combinator_1.syntax)(4 /* Syntax.bracket */, 2, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, '}', [[/^\\?\n/, 3], ['}', 2]]))), (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.creation)((0, combinator_1.syntax)(4 /* Syntax.bracket */, 2, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, '}', [[/^\\?\n/, 3], ['}', 2]]))), (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.creation)((0, combinator_1.syntax)(0 /* Syntax.none */, 3, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, '"', [[/^\\?\n/, 4], ['"', 3]]))), (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.creation)((0, combinator_1.syntax)(0 /* Syntax.none */, 3, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, '”', [[/^\\?\n/, 4], ['”', 3]]))), (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.creation)((0, combinator_1.syntax)(0 /* Syntax.none */, 3, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, '’', [[/^\\?\n/, 4], ['’', 3]]))), (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.creation)((0, combinator_1.syntax)(0 /* Syntax.none */, 3, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, '」', [[/^\\?\n/, 4], ['」', 3]]))), (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.creation)((0, combinator_1.syntax)(0 /* Syntax.none */, 3, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, '』', [[/^\\?\n/, 4], ['』', 3]]))), (0, source_1.str)('』'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest])]));
|
|
6066
6065
|
|
|
6067
6066
|
/***/ }),
|
|
6068
6067
|
|
|
@@ -6204,7 +6203,7 @@ const indexee_1 = __webpack_require__(1269);
|
|
|
6204
6203
|
const source_1 = __webpack_require__(6743);
|
|
6205
6204
|
const visibility_1 = __webpack_require__(7618);
|
|
6206
6205
|
const dom_1 = __webpack_require__(3252);
|
|
6207
|
-
exports.index = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[#', (0, combinator_1.creation)((0, combinator_1.fmap)((0, indexee_1.indexee)((0, combinator_1.surround)('[#', (0, combinator_1.constraint)(64 /* State.index */, false, (0, combinator_1.syntax)(
|
|
6206
|
+
exports.index = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[#', (0, combinator_1.creation)((0, combinator_1.fmap)((0, indexee_1.indexee)((0, combinator_1.surround)('[#', (0, combinator_1.constraint)(64 /* State.index */, false, (0, combinator_1.syntax)(64 /* Syntax.index */, 2, 502 /* State.linkers */ | 8 /* State.media */, (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.inits)([inline_1.inline, exports.signature]), ']', [[/^\\?\n/, 9], [']', 2]])))), ']', false, ([, ns], rest) => [[(0, dom_1.html)('a', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))], rest])), ([el]) => [(0, dom_1.define)(el, {
|
|
6208
6207
|
id: el.id ? null : undefined,
|
|
6209
6208
|
class: 'index',
|
|
6210
6209
|
href: el.id ? `#${el.id}` : undefined
|
|
@@ -6406,7 +6405,7 @@ const array_1 = __webpack_require__(8112);
|
|
|
6406
6405
|
const dom_1 = __webpack_require__(3252);
|
|
6407
6406
|
// Don't use the symbols already used: !#$%@&*+~=|
|
|
6408
6407
|
// All syntax surrounded by square brackets shouldn't contain line breaks.
|
|
6409
|
-
exports.placeholder = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[', (0, combinator_1.creation)((0, combinator_1.surround)((0, source_1.str)(/^\[[:^|]/), (0, combinator_1.syntax)(
|
|
6408
|
+
exports.placeholder = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[', (0, combinator_1.creation)((0, combinator_1.surround)((0, source_1.str)(/^\[[:^|]/), (0, combinator_1.syntax)(32 /* Syntax.placeholder */, 2, 0 /* State.none */, (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [[']', 2]]))), (0, source_1.str)(']'), false, ([, bs], rest) => [[(0, dom_1.html)('span', {
|
|
6410
6409
|
class: 'invalid',
|
|
6411
6410
|
'data-invalid-syntax': 'extension',
|
|
6412
6411
|
'data-invalid-type': 'syntax',
|
|
@@ -6517,7 +6516,7 @@ const parse = (0, memoize_1.reduce)((el => entity => {
|
|
|
6517
6516
|
el.innerHTML = entity;
|
|
6518
6517
|
const text = el.textContent;
|
|
6519
6518
|
return entity === text ? undefined : text;
|
|
6520
|
-
})((0, dom_1.html)('
|
|
6519
|
+
})((0, dom_1.html)('span')));
|
|
6521
6520
|
|
|
6522
6521
|
/***/ }),
|
|
6523
6522
|
|
|
@@ -6564,11 +6563,11 @@ const optspec = {
|
|
|
6564
6563
|
};
|
|
6565
6564
|
Object.setPrototypeOf(optspec, null);
|
|
6566
6565
|
exports.link = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['[', '{'], (0, combinator_1.union)([exports.medialink, exports.textlink])));
|
|
6567
|
-
exports.textlink = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(10, (0, combinator_1.constraint)(16 /* State.link */, false, (0, combinator_1.syntax)(
|
|
6566
|
+
exports.textlink = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(10, (0, combinator_1.constraint)(16 /* State.link */, false, (0, combinator_1.syntax)(8 /* Syntax.link */, 2, 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, visibility_1.trimBlankStart)((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) => {
|
|
6568
6567
|
if (content.length !== 0 && (0, visibility_1.trimNodeEnd)(content = (0, dom_1.defrag)(content)).length === 0) return;
|
|
6569
6568
|
return [[parse(content, params, context)], rest];
|
|
6570
6569
|
})))));
|
|
6571
|
-
exports.medialink = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(10, (0, combinator_1.constraint)(16 /* State.link */ | 8 /* State.media */, false, (0, combinator_1.syntax)(
|
|
6570
|
+
exports.medialink = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(10, (0, combinator_1.constraint)(16 /* State.link */ | 8 /* State.media */, false, (0, combinator_1.syntax)(8 /* Syntax.link */, 2, 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((0, dom_1.defrag)(content), params, context)], rest])))));
|
|
6572
6571
|
exports.linemedialink = (0, combinator_1.surround)(source_1.linebreak, (0, combinator_1.union)([exports.medialink]), /^(?=[^\S\n]*(?:$|\n))/);
|
|
6573
6572
|
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((0, dom_1.defrag)(content), params, context)], rest]))));
|
|
6574
6573
|
exports.uri = (0, combinator_1.union)([(0, combinator_1.open)(/^[^\S\n]+/, (0, source_1.str)(/^\S+/)), (0, source_1.str)(/^[^\s{}]+/)]);
|
|
@@ -6748,7 +6747,7 @@ const optspec = {
|
|
|
6748
6747
|
rel: undefined
|
|
6749
6748
|
};
|
|
6750
6749
|
Object.setPrototypeOf(optspec, null);
|
|
6751
|
-
exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['![', '!{'], (0, combinator_1.creation)(10, (0, combinator_1.open)('!', (0, combinator_1.constraint)(8 /* State.media */, false, (0, combinator_1.syntax)(
|
|
6750
|
+
exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['![', '!{'], (0, combinator_1.creation)(10, (0, combinator_1.open)('!', (0, combinator_1.constraint)(8 /* State.media */, false, (0, combinator_1.syntax)(0 /* Syntax.none */, 2, ~16 /* State.link */, (0, combinator_1.bind)((0, combinator_1.verify)((0, combinator_1.fmap)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ']', [[/^\\?\n/, 9]]), ']', true)), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([link_1.uri, (0, combinator_1.some)(option)]), /^[^\S\n]*}/))]), ([as, bs]) => bs ? [[as.join('').trim() || as.join('')], bs] : [[''], as]), ([[text]]) => text === '' || text.trim() !== ''), ([[text], params], rest, context) => {
|
|
6752
6751
|
const INSECURE_URI = params.shift();
|
|
6753
6752
|
const url = new url_1.ReadonlyURL((0, link_1.resolve)(INSECURE_URI, context.host ?? location, context.url ?? context.host ?? location), context.host?.href || location.href);
|
|
6754
6753
|
let cache;
|
|
@@ -6820,7 +6819,7 @@ const inline_1 = __webpack_require__(1160);
|
|
|
6820
6819
|
const source_1 = __webpack_require__(6743);
|
|
6821
6820
|
const visibility_1 = __webpack_require__(7618);
|
|
6822
6821
|
const dom_1 = __webpack_require__(3252);
|
|
6823
|
-
exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.creation)((0, combinator_1.surround)('[[', (0, combinator_1.constraint)(128 /* State.reference */, false, (0, combinator_1.syntax)(
|
|
6822
|
+
exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.creation)((0, combinator_1.surround)('[[', (0, combinator_1.constraint)(128 /* State.reference */, false, (0, combinator_1.syntax)(128 /* Syntax.reference */, 6, 256 /* State.annotation */ | 128 /* State.reference */ | 8 /* State.media */, (0, combinator_1.subsequence)([abbr, (0, visibility_1.trimBlankStart)((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.trimNodeEnd)((0, dom_1.defrag)(ns)))])], rest])));
|
|
6824
6823
|
// Chicago-Style
|
|
6825
6824
|
const abbr = (0, combinator_1.creation)((0, combinator_1.surround)('^', (0, combinator_1.union)([(0, source_1.str)(/^(?=[A-Z])(?:[0-9A-Za-z]'?|(?:[-.:]|\.?\??,? ?)(?!['\-.:?, ]))+/)]), /^\|?(?=]])|^\|[^\S\n]*/, true, ([, ns], rest) => ns ? [['\n', ns[0].trimEnd()], rest.replace(visibility_1.blank.start, '')] : [[''], `^${rest}`], ([,, rest]) => [[''], `^${rest}`]));
|
|
6826
6825
|
function attributes(ns) {
|
|
@@ -6889,7 +6888,7 @@ const source_1 = __webpack_require__(6743);
|
|
|
6889
6888
|
const visibility_1 = __webpack_require__(7618);
|
|
6890
6889
|
const array_1 = __webpack_require__(8112);
|
|
6891
6890
|
const dom_1 = __webpack_require__(3252);
|
|
6892
|
-
exports.ruby = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[', (0, combinator_1.creation)((0, combinator_1.syntax)(
|
|
6891
|
+
exports.ruby = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[', (0, combinator_1.creation)((0, combinator_1.syntax)(16 /* Syntax.ruby */, 2, -1 /* State.all */, (0, combinator_1.fmap)((0, combinator_1.verify)((0, combinator_1.fmap)((0, combinator_1.sequence)([(0, combinator_1.surround)('[', (0, source_1.str)(/^(?:\\[^\n]|[^\\[\](){}"\n])+/), ']'), (0, combinator_1.surround)('(', (0, source_1.str)(/^(?:\\[^\n]|[^\\[\](){}"\n])+/), ')')]), ([texts, rubies], _, context) => [(0, parser_1.eval)(text({
|
|
6893
6892
|
source: texts,
|
|
6894
6893
|
context
|
|
6895
6894
|
}), [])[0] ?? '', (0, parser_1.eval)(text({
|
package/markdown.d.ts
CHANGED
|
@@ -661,7 +661,6 @@ export namespace MarkdownParser {
|
|
|
661
661
|
InlineParser.ReferenceParser,
|
|
662
662
|
InlineParser.TemplateParser,
|
|
663
663
|
InlineParser.RemarkParser,
|
|
664
|
-
InlineParser.MathParser,
|
|
665
664
|
InlineParser.ExtensionParser,
|
|
666
665
|
InlineParser.RubyParser,
|
|
667
666
|
InlineParser.LinkParser.TextLinkParser,
|
|
@@ -672,6 +671,7 @@ export namespace MarkdownParser {
|
|
|
672
671
|
InlineParser.EmStrongParser,
|
|
673
672
|
InlineParser.StrongParser,
|
|
674
673
|
InlineParser.EmphasisParser,
|
|
674
|
+
InlineParser.MathParser,
|
|
675
675
|
InlineParser.CodeParser,
|
|
676
676
|
InlineParser.HTMLEntityParser,
|
|
677
677
|
InlineParser.AutolinkParser,
|
|
@@ -743,27 +743,6 @@ export namespace MarkdownParser {
|
|
|
743
743
|
InlineParser,
|
|
744
744
|
]> {
|
|
745
745
|
}
|
|
746
|
-
export interface MathParser extends
|
|
747
|
-
// $expr$
|
|
748
|
-
// ${expr}$
|
|
749
|
-
Inline<'math'>,
|
|
750
|
-
Parser<HTMLElement, Context, [
|
|
751
|
-
MathParser.BracketParser,
|
|
752
|
-
Parser<string, Context, [
|
|
753
|
-
MathParser.BracketParser,
|
|
754
|
-
SourceParser.UnescapableSourceParser,
|
|
755
|
-
]>,
|
|
756
|
-
]> {
|
|
757
|
-
}
|
|
758
|
-
export namespace MathParser {
|
|
759
|
-
export interface BracketParser extends
|
|
760
|
-
Inline<'math/bracket'>,
|
|
761
|
-
Parser<HTMLElement, Context, [
|
|
762
|
-
BracketParser,
|
|
763
|
-
SourceParser.EscapableSourceParser,
|
|
764
|
-
]> {
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
746
|
export interface ExtensionParser extends
|
|
768
747
|
Inline<'extension'>,
|
|
769
748
|
Parser<HTMLElement | string, Context, [
|
|
@@ -1097,6 +1076,27 @@ export namespace MarkdownParser {
|
|
|
1097
1076
|
]>,
|
|
1098
1077
|
]> {
|
|
1099
1078
|
}
|
|
1079
|
+
export interface MathParser extends
|
|
1080
|
+
// $expr$
|
|
1081
|
+
// ${expr}$
|
|
1082
|
+
Inline<'math'>,
|
|
1083
|
+
Parser<HTMLElement, Context, [
|
|
1084
|
+
MathParser.BracketParser,
|
|
1085
|
+
Parser<string, Context, [
|
|
1086
|
+
MathParser.BracketParser,
|
|
1087
|
+
SourceParser.UnescapableSourceParser,
|
|
1088
|
+
]>,
|
|
1089
|
+
]> {
|
|
1090
|
+
}
|
|
1091
|
+
export namespace MathParser {
|
|
1092
|
+
export interface BracketParser extends
|
|
1093
|
+
Inline<'math/bracket'>,
|
|
1094
|
+
Parser<HTMLElement, Context, [
|
|
1095
|
+
BracketParser,
|
|
1096
|
+
SourceParser.EscapableSourceParser,
|
|
1097
|
+
]> {
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
1100
|
export interface CodeParser extends
|
|
1101
1101
|
// `abc`
|
|
1102
1102
|
Inline<'code'>,
|
package/package.json
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Parser, exec } from '../../data/parser';
|
|
2
|
-
import { Memo } from '../../data/parser/context/memo';
|
|
3
2
|
import { firstline, isBlank } from './line';
|
|
4
3
|
|
|
5
4
|
export function block<P extends Parser<unknown>>(parser: P, separation?: boolean): P;
|
|
@@ -7,7 +6,6 @@ export function block<T>(parser: Parser<T>, separation = true): Parser<T> {
|
|
|
7
6
|
assert(parser);
|
|
8
7
|
return ({ source, context }) => {
|
|
9
8
|
if (source === '') return;
|
|
10
|
-
context.memo ??= new Memo();
|
|
11
9
|
const result = parser({ source, context });
|
|
12
10
|
if (result === undefined) return;
|
|
13
11
|
const rest = exec(result);
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { Parser, eval, exec, check } from '../../data/parser';
|
|
2
|
-
import { Memo } from '../../data/parser/context/memo';
|
|
3
2
|
|
|
4
3
|
export function line<P extends Parser<unknown>>(parser: P): P;
|
|
5
4
|
export function line<T>(parser: Parser<T>): Parser<T> {
|
|
6
5
|
assert(parser);
|
|
7
6
|
return ({ source, context }) => {
|
|
8
7
|
if (source === '') return;
|
|
9
|
-
context.memo ??= new Memo();
|
|
10
8
|
const line = firstline(source);
|
|
11
9
|
context.offset ??= 0;
|
|
12
10
|
context.offset += source.length - line.length;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Parser, Ctx } from '../../data/parser';
|
|
2
2
|
import { firstline, isBlank } from '../constraint/line';
|
|
3
|
-
import {
|
|
3
|
+
import { push } from 'spica/array';
|
|
4
4
|
|
|
5
5
|
export function fence<C extends Ctx, D extends Parser<unknown, C>[]>(opener: RegExp, limit: number, separation = true): Parser<string, C, D> {
|
|
6
6
|
return ({ source }) => {
|
|
@@ -42,6 +42,6 @@ export function fence<C extends Ctx, D extends Parser<unknown, C>[]>(opener: Reg
|
|
|
42
42
|
}
|
|
43
43
|
rest = rest.slice(line.length);
|
|
44
44
|
}
|
|
45
|
-
return [
|
|
45
|
+
return [push([block, overflow, closer], matches), rest];
|
|
46
46
|
};
|
|
47
47
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export class Memo {
|
|
2
2
|
constructor(
|
|
3
3
|
public readonly targets = ~0,
|
|
4
|
+
public readonly margin = 0,
|
|
4
5
|
) {
|
|
5
|
-
this.targets = targets;
|
|
6
6
|
}
|
|
7
7
|
private memory: Record<number, Record<number, readonly [any[], number] | readonly []>>[/* pos */] = [];
|
|
8
|
+
private count = 0;
|
|
8
9
|
public get length(): number {
|
|
9
10
|
return this.memory.length;
|
|
10
11
|
}
|
|
@@ -13,6 +14,7 @@ export class Memo {
|
|
|
13
14
|
syntax: number,
|
|
14
15
|
state: number,
|
|
15
16
|
): readonly [any[], number] | readonly [] | undefined {
|
|
17
|
+
if (this.count === 0) return;
|
|
16
18
|
//console.log('get', position, syntax, state, this.memory[position - 1]?.[syntax]?.[state]);
|
|
17
19
|
const cache = this.memory[position - 1]?.[syntax]?.[state];
|
|
18
20
|
return cache?.length === 2
|
|
@@ -26,6 +28,7 @@ export class Memo {
|
|
|
26
28
|
nodes: any[] | undefined,
|
|
27
29
|
offset: number,
|
|
28
30
|
): void {
|
|
31
|
+
this.count += +!this.memory[position - 1];
|
|
29
32
|
const record = this.memory[position - 1] ??= {};
|
|
30
33
|
assert(!record[syntax]?.[state]);
|
|
31
34
|
(record[syntax] ??= {})[state] = nodes
|
|
@@ -36,11 +39,12 @@ export class Memo {
|
|
|
36
39
|
public resize(position: number): void {
|
|
37
40
|
const memory = this.memory;
|
|
38
41
|
for (let len = memory.length, i = position; i < len; ++i) {
|
|
39
|
-
memory.pop()
|
|
42
|
+
this.count -= +memory.pop()!;
|
|
40
43
|
}
|
|
41
|
-
//console.log('resize', position
|
|
44
|
+
//console.log('resize', position);
|
|
42
45
|
}
|
|
43
46
|
public clear(): void {
|
|
44
47
|
this.memory = [];
|
|
48
|
+
this.count = 0;
|
|
45
49
|
}
|
|
46
50
|
}
|
|
@@ -69,19 +69,17 @@ export function syntax<T>(syntax: number, prec: number, state: number, parser?:
|
|
|
69
69
|
const position = source.length + context.offset!;
|
|
70
70
|
const stateOuter = context.state ?? 0;
|
|
71
71
|
const stateInner = context.state = stateOuter | state;
|
|
72
|
-
const cache = syntax
|
|
72
|
+
const cache = syntax & memo.targets && stateInner && memo.get(position, syntax, stateInner);
|
|
73
73
|
const result: Result<T> = cache
|
|
74
74
|
? cache.length === 0
|
|
75
75
|
? undefined
|
|
76
76
|
: [cache[0], source.slice(cache[1])]
|
|
77
77
|
: parser!({ source, context });
|
|
78
|
-
if (
|
|
79
|
-
|
|
80
|
-
assert.deepStrictEqual(cache && cache, cache && memo.get(position, syntax, stateInner));
|
|
78
|
+
if (stateOuter && !cache && syntax & memo.targets) {
|
|
79
|
+
memo.set(position, syntax, stateInner, eval(result), source.length - exec(result, '').length);
|
|
81
80
|
}
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
memo.resize(position + 2);
|
|
81
|
+
else if (!stateOuter && result && memo.length! >= position + memo.margin) {
|
|
82
|
+
memo.resize(position + memo.margin);
|
|
85
83
|
}
|
|
86
84
|
context.state = stateOuter;
|
|
87
85
|
return result;
|
|
@@ -32,7 +32,7 @@ export function some<T>(parser: Parser<T>, end?: string | RegExp | number, delim
|
|
|
32
32
|
assert.doesNotThrow(() => limit < 0 && check(rest, result));
|
|
33
33
|
if (result === undefined) break;
|
|
34
34
|
nodes = nodes
|
|
35
|
-
? nodes.length < eval(result).length
|
|
35
|
+
? nodes.length < eval(result).length / 8
|
|
36
36
|
? unshift(nodes, eval(result))
|
|
37
37
|
: push(nodes, eval(result))
|
|
38
38
|
: eval(result);
|
package/src/parser/block.ts
CHANGED
|
@@ -17,7 +17,7 @@ import { blockquote } from './block/blockquote';
|
|
|
17
17
|
import { mediablock } from './block/mediablock';
|
|
18
18
|
import { reply } from './block/reply';
|
|
19
19
|
import { paragraph } from './block/paragraph';
|
|
20
|
-
import {
|
|
20
|
+
import { Syntax } from './context';
|
|
21
21
|
import { rnd0Z } from 'spica/random';
|
|
22
22
|
import { html } from 'typed-dom/dom';
|
|
23
23
|
|
|
@@ -39,7 +39,10 @@ export import ReplyParser = BlockParser.ReplyParser;
|
|
|
39
39
|
export import ParagraphParser = BlockParser.ParagraphParser;
|
|
40
40
|
|
|
41
41
|
export const block: BlockParser = creation(0, false,
|
|
42
|
-
reset({
|
|
42
|
+
reset({
|
|
43
|
+
resources: { clock: 20000, recursion: 20 + 1 },
|
|
44
|
+
memo: new Memo(Syntax.targets, 2),
|
|
45
|
+
},
|
|
43
46
|
error(union([
|
|
44
47
|
emptyline,
|
|
45
48
|
pagebreak,
|
package/src/parser/context.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
export const enum Syntax {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
annotation = 1 << 8,
|
|
3
|
+
reference = 1 << 7,
|
|
4
|
+
index = 1 << 6,
|
|
5
|
+
placeholder = 1 << 5,
|
|
6
|
+
ruby = 1 << 4,
|
|
7
|
+
link = 1 << 3,
|
|
8
|
+
bracket = 1 << 2,
|
|
9
9
|
autolink = 1 << 1,
|
|
10
10
|
none = 0,
|
|
11
|
+
targets = 0
|
|
12
|
+
| Syntax.annotation
|
|
13
|
+
| Syntax.reference
|
|
14
|
+
| Syntax.index
|
|
15
|
+
| Syntax.placeholder
|
|
16
|
+
| Syntax.ruby
|
|
17
|
+
| Syntax.link
|
|
18
|
+
| Syntax.bracket,
|
|
11
19
|
}
|
|
12
20
|
|
|
13
21
|
export const enum State {
|
|
@@ -30,10 +38,4 @@ export const enum State {
|
|
|
30
38
|
| State.link
|
|
31
39
|
| State.mark
|
|
32
40
|
| State.autolink,
|
|
33
|
-
backtrackers = 0
|
|
34
|
-
| State.annotation
|
|
35
|
-
| State.reference
|
|
36
|
-
| State.index
|
|
37
|
-
| State.link
|
|
38
|
-
| State.media,
|
|
39
41
|
}
|
|
@@ -8,7 +8,7 @@ import { html, defrag } from 'typed-dom/dom';
|
|
|
8
8
|
export const annotation: AnnotationParser = lazy(() => creation(surround(
|
|
9
9
|
'((',
|
|
10
10
|
constraint(State.annotation, false,
|
|
11
|
-
syntax(Syntax.
|
|
11
|
+
syntax(Syntax.annotation, 6, State.annotation | State.media,
|
|
12
12
|
trimBlankStart(some(union([inline]), ')', [[/^\\?\n/, 9], [')', 2], ['))', 6]])))),
|
|
13
13
|
'))',
|
|
14
14
|
false,
|
|
@@ -21,7 +21,7 @@ Object.setPrototypeOf(optspec, null);
|
|
|
21
21
|
export const media: MediaParser = lazy(() => validate(['![', '!{'], creation(10, open(
|
|
22
22
|
'!',
|
|
23
23
|
constraint(State.media, false,
|
|
24
|
-
syntax(Syntax.
|
|
24
|
+
syntax(Syntax.none, 2, ~State.link,
|
|
25
25
|
bind(verify(fmap(tails([
|
|
26
26
|
dup(surround(
|
|
27
27
|
'[',
|
|
@@ -68,9 +68,12 @@ export const linemedia: MediaParser.LineMediaParser = surround(
|
|
|
68
68
|
/^(?=[^\S\n]*(?:$|\n))/);
|
|
69
69
|
|
|
70
70
|
const bracket: MediaParser.TextParser.BracketParser = lazy(() => creation(union([
|
|
71
|
-
surround(str('('), some(union([unsafehtmlentity, bracket, txt]), ')'), str(')'), true,
|
|
72
|
-
|
|
73
|
-
surround(str('
|
|
71
|
+
surround(str('('), some(union([unsafehtmlentity, bracket, txt]), ')'), str(')'), true,
|
|
72
|
+
undefined, ([as, bs = []], rest) => [unshift(as, bs), rest]),
|
|
73
|
+
surround(str('['), some(union([unsafehtmlentity, bracket, txt]), ']'), str(']'), true,
|
|
74
|
+
undefined, ([as, bs = []], rest) => [unshift(as, bs), rest]),
|
|
75
|
+
surround(str('{'), some(union([unsafehtmlentity, bracket, txt]), '}'), str('}'), true,
|
|
76
|
+
undefined, ([as, bs = []], rest) => [unshift(as, bs), rest]),
|
|
74
77
|
surround(str('"'), precedence(3, some(union([unsafehtmlentity, txt]), '"')), str('"'), true),
|
|
75
78
|
])));
|
|
76
79
|
|
|
@@ -13,8 +13,11 @@ export const template: TemplateParser = lazy(() => creation(surround(
|
|
|
13
13
|
([, ns = []], rest) => [[html('span', { class: 'template' }, `{{${ns.join('').replace(/\x1B/g, '')}}}`)], rest])));
|
|
14
14
|
|
|
15
15
|
const bracket: TemplateParser.BracketParser = lazy(() => creation(union([
|
|
16
|
-
surround(str('('), some(union([bracket, escsource]), ')'), str(')'), true,
|
|
17
|
-
|
|
18
|
-
surround(str('
|
|
16
|
+
surround(str('('), some(union([bracket, escsource]), ')'), str(')'), true,
|
|
17
|
+
undefined, ([as, bs = []], rest) => [unshift(as, bs), rest]),
|
|
18
|
+
surround(str('['), some(union([bracket, escsource]), ']'), str(']'), true,
|
|
19
|
+
undefined, ([as, bs = []], rest) => [unshift(as, bs), rest]),
|
|
20
|
+
surround(str('{'), some(union([bracket, escsource]), '}'), str('}'), true,
|
|
21
|
+
undefined, ([as, bs = []], rest) => [unshift(as, bs), rest]),
|
|
19
22
|
surround(str('"'), precedence(3, some(escsource, /^"|^\\?\n/)), str('"'), true),
|
|
20
23
|
])));
|
package/src/parser/inline.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { annotation } from './inline/annotation';
|
|
|
4
4
|
import { reference } from './inline/reference';
|
|
5
5
|
import { template } from './inline/template';
|
|
6
6
|
import { remark } from './inline/remark';
|
|
7
|
-
import { math } from './inline/math';
|
|
8
7
|
import { extension } from './inline/extension';
|
|
9
8
|
import { ruby } from './inline/ruby';
|
|
10
9
|
import { textlink } from './inline/link';
|
|
@@ -13,8 +12,9 @@ import { insertion } from './inline/insertion';
|
|
|
13
12
|
import { deletion } from './inline/deletion';
|
|
14
13
|
import { mark } from './inline/mark';
|
|
15
14
|
import { emstrong } from './inline/emstrong';
|
|
16
|
-
import { emphasis } from './inline/emphasis';
|
|
17
15
|
import { strong } from './inline/strong';
|
|
16
|
+
import { emphasis } from './inline/emphasis';
|
|
17
|
+
import { math } from './inline/math';
|
|
18
18
|
import { code } from './inline/code';
|
|
19
19
|
import { htmlentity } from './inline/htmlentity';
|
|
20
20
|
import { autolink } from './inline/autolink';
|
|
@@ -26,7 +26,6 @@ export import AnnotationParser = InlineParser.AnnotationParser;
|
|
|
26
26
|
export import ReferenceParser = InlineParser.ReferenceParser;
|
|
27
27
|
export import TemplateParser = InlineParser.TemplateParser;
|
|
28
28
|
export import RemarkParser = InlineParser.RemarkParser;
|
|
29
|
-
export import MathParser = InlineParser.MathParser;
|
|
30
29
|
export import ExtensionParser = InlineParser.ExtensionParser;
|
|
31
30
|
export import RubyParser = InlineParser.RubyParser;
|
|
32
31
|
export import LinkParser = InlineParser.LinkParser;
|
|
@@ -35,8 +34,9 @@ export import InsertionParser = InlineParser.InsertionParser;
|
|
|
35
34
|
export import DeletionParser = InlineParser.DeletionParser;
|
|
36
35
|
export import MarkParser = InlineParser.MarkParser;
|
|
37
36
|
export import EmStrongParser = InlineParser.EmStrongParser;
|
|
38
|
-
export import EmphasisParser = InlineParser.EmphasisParser;
|
|
39
37
|
export import StrongParser = InlineParser.StrongParser;
|
|
38
|
+
export import EmphasisParser = InlineParser.EmphasisParser;
|
|
39
|
+
export import MathParser = InlineParser.MathParser;
|
|
40
40
|
export import CodeParser = InlineParser.CodeParser;
|
|
41
41
|
export import MediaParser = InlineParser.MediaParser;
|
|
42
42
|
export import HTMLEntityParser = InlineParser.HTMLEntityParser;
|
|
@@ -50,7 +50,6 @@ export const inline: InlineParser = lazy(() => union([
|
|
|
50
50
|
reference,
|
|
51
51
|
template,
|
|
52
52
|
remark,
|
|
53
|
-
math,
|
|
54
53
|
extension,
|
|
55
54
|
ruby,
|
|
56
55
|
textlink,
|
|
@@ -61,6 +60,7 @@ export const inline: InlineParser = lazy(() => union([
|
|
|
61
60
|
emstrong,
|
|
62
61
|
strong,
|
|
63
62
|
emphasis,
|
|
63
|
+
math,
|
|
64
64
|
code,
|
|
65
65
|
htmlentity,
|
|
66
66
|
autolink,
|