securemark 0.296.3 → 0.296.5
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/design.md +3 -4
- package/dist/index.js +146 -82
- package/markdown.d.ts +8 -4
- package/package.json +1 -1
- package/src/combinator/control/constraint/block.ts +12 -6
- package/src/combinator/control/manipulation/recovery.ts +3 -3
- package/src/combinator/data/parser.ts +7 -0
- package/src/parser/api/bind.ts +10 -5
- package/src/parser/api/parse.ts +3 -2
- package/src/parser/block/extension/fig.ts +3 -1
- package/src/parser/block/extension/figure.ts +2 -1
- package/src/parser/block/extension/message.ts +1 -1
- package/src/parser/block/extension.test.ts +3 -3
- package/src/parser/block/extension.ts +3 -4
- package/src/parser/block/heading.ts +4 -4
- package/src/parser/block.ts +22 -12
- package/src/parser/context.ts +13 -0
- package/src/parser/inline/autolink/account.ts +1 -1
- package/src/parser/inline/autolink/anchor.ts +1 -1
- package/src/parser/inline/autolink/hashnum.ts +1 -1
- package/src/parser/inline/autolink/hashtag.ts +1 -1
- package/src/parser/inline/emstrong.ts +1 -1
- package/src/parser/inline/extension/indexee.ts +8 -8
- package/src/parser/inline/mark.ts +1 -1
- package/src/parser/inline.test.ts +0 -1
- package/src/parser/processor/note.test.ts +35 -29
- package/src/parser/processor/note.ts +32 -23
- package/src/parser/segment.test.ts +73 -73
- package/src/parser/segment.ts +9 -11
- package/src/parser/source/line.ts +25 -6
- package/src/parser/source/str.ts +9 -10
- package/src/parser/source.ts +2 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.296.
|
|
1
|
+
/*! securemark v0.296.5 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"));
|
|
@@ -2573,7 +2573,7 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
2573
2573
|
exports.block = void 0;
|
|
2574
2574
|
const parser_1 = __webpack_require__(605);
|
|
2575
2575
|
const line_1 = __webpack_require__(8287);
|
|
2576
|
-
function block(parser, separation = true) {
|
|
2576
|
+
function block(parser, separation = true, segment = 0) {
|
|
2577
2577
|
return (0, parser_1.failsafe)(input => {
|
|
2578
2578
|
const {
|
|
2579
2579
|
context
|
|
@@ -2583,10 +2583,18 @@ function block(parser, separation = true) {
|
|
|
2583
2583
|
position
|
|
2584
2584
|
} = context;
|
|
2585
2585
|
if (position === source.length) return;
|
|
2586
|
+
if (segment !== 0 && context.segment & 1 /* Segment.write */) {
|
|
2587
|
+
if (context.segment !== (segment | 1 /* Segment.write */)) return;
|
|
2588
|
+
context.position = source.length;
|
|
2589
|
+
return new parser_1.List();
|
|
2590
|
+
}
|
|
2586
2591
|
const result = parser(input);
|
|
2587
2592
|
if (result === undefined) return;
|
|
2588
2593
|
if (separation && !(0, line_1.isEmptyline)(source, context.position)) return;
|
|
2589
|
-
|
|
2594
|
+
if (segment !== 0 && context.segment & 1 /* Segment.write */ ^ 1 /* Segment.write */) {
|
|
2595
|
+
context.segment = segment;
|
|
2596
|
+
}
|
|
2597
|
+
return result;
|
|
2590
2598
|
});
|
|
2591
2599
|
}
|
|
2592
2600
|
exports.block = block;
|
|
@@ -2938,7 +2946,7 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
2938
2946
|
value: true
|
|
2939
2947
|
}));
|
|
2940
2948
|
exports.recover = void 0;
|
|
2941
|
-
function recover(parser,
|
|
2949
|
+
function recover(parser, catcher) {
|
|
2942
2950
|
return input => {
|
|
2943
2951
|
const {
|
|
2944
2952
|
context
|
|
@@ -2952,7 +2960,7 @@ function recover(parser, fallback) {
|
|
|
2952
2960
|
} catch (reason) {
|
|
2953
2961
|
context.source = source;
|
|
2954
2962
|
context.position = position;
|
|
2955
|
-
return
|
|
2963
|
+
return catcher(input, reason);
|
|
2956
2964
|
}
|
|
2957
2965
|
};
|
|
2958
2966
|
}
|
|
@@ -3655,6 +3663,7 @@ class Context {
|
|
|
3655
3663
|
constructor({
|
|
3656
3664
|
source,
|
|
3657
3665
|
position,
|
|
3666
|
+
segment,
|
|
3658
3667
|
resources,
|
|
3659
3668
|
delimiters,
|
|
3660
3669
|
precedence,
|
|
@@ -3666,6 +3675,7 @@ class Context {
|
|
|
3666
3675
|
} = {}) {
|
|
3667
3676
|
this.source = source ?? '';
|
|
3668
3677
|
this.position = position ?? 0;
|
|
3678
|
+
this.segment = segment ?? 0;
|
|
3669
3679
|
this.resources = resources;
|
|
3670
3680
|
this.precedence = precedence ?? 0;
|
|
3671
3681
|
this.delimiters = delimiters ?? new delimiter_1.Delimiters();
|
|
@@ -4212,8 +4222,10 @@ function bind(target, settings) {
|
|
|
4212
4222
|
context.url = url ? new url_1.ReadonlyURL(url) : undefined;
|
|
4213
4223
|
const rev = revision = Symbol();
|
|
4214
4224
|
const sourceSegments = [];
|
|
4215
|
-
|
|
4225
|
+
const sourceSegmentAttrs = [];
|
|
4226
|
+
for (const [seg, attr] of (0, segment_1.segment)(source)) {
|
|
4216
4227
|
sourceSegments.push(seg);
|
|
4228
|
+
sourceSegmentAttrs.push(attr);
|
|
4217
4229
|
yield {
|
|
4218
4230
|
type: 'segment',
|
|
4219
4231
|
value: seg
|
|
@@ -4236,13 +4248,14 @@ function bind(target, settings) {
|
|
|
4236
4248
|
// @ts-expect-error
|
|
4237
4249
|
context.header = true;
|
|
4238
4250
|
for (; index < sourceSegments.length - last; ++index) {
|
|
4239
|
-
const
|
|
4240
|
-
|
|
4251
|
+
const src = sourceSegments[index];
|
|
4252
|
+
context.segment = sourceSegmentAttrs[index] | 1 /* Segment.write */;
|
|
4253
|
+
const es = (0, block_1.block)((0, parser_1.input)(src, new context_1.Context(context)))?.foldl((acc, {
|
|
4241
4254
|
value
|
|
4242
4255
|
}) => void acc.push(value) || acc, []) ?? [];
|
|
4243
4256
|
// @ts-expect-error
|
|
4244
4257
|
context.header = false;
|
|
4245
|
-
blocks.splice(index, 0, [
|
|
4258
|
+
blocks.length === index ? blocks.push([src, es, url]) : blocks.splice(index, 0, [src, es, url]);
|
|
4246
4259
|
if (es.length === 0) continue;
|
|
4247
4260
|
// All deletion processes always run after all addition processes have done.
|
|
4248
4261
|
// Therefore any `base` node will never be unavailable by deletions until all the dependent `el` nodes are added.
|
|
@@ -4547,7 +4560,8 @@ function parse(source, options = {}, context) {
|
|
|
4547
4560
|
const node = (0, dom_1.frag)();
|
|
4548
4561
|
// @ts-expect-error
|
|
4549
4562
|
context.header = true;
|
|
4550
|
-
for (const seg of (0, segment_1.segment)(source)) {
|
|
4563
|
+
for (const [seg, attr] of (0, segment_1.segment)(source)) {
|
|
4564
|
+
context.segment = attr | 1 /* Segment.write */;
|
|
4551
4565
|
node.append(...((0, block_1.block)((0, parser_1.input)(seg, new context_1.Context(context)))?.foldl((acc, {
|
|
4552
4566
|
value
|
|
4553
4567
|
}) => void acc.push(value) || acc, []) ?? []));
|
|
@@ -4605,6 +4619,9 @@ const table_1 = __webpack_require__(2752);
|
|
|
4605
4619
|
const codeblock_1 = __webpack_require__(9194);
|
|
4606
4620
|
const mathblock_1 = __webpack_require__(4903);
|
|
4607
4621
|
const extension_1 = __webpack_require__(6193);
|
|
4622
|
+
const figbase_1 = __webpack_require__(8289);
|
|
4623
|
+
const fig_1 = __webpack_require__(7396);
|
|
4624
|
+
const figure_1 = __webpack_require__(4248);
|
|
4608
4625
|
const sidefence_1 = __webpack_require__(6500);
|
|
4609
4626
|
const blockquote_1 = __webpack_require__(5885);
|
|
4610
4627
|
const mediablock_1 = __webpack_require__(2583);
|
|
@@ -4619,16 +4636,27 @@ exports.block = (0, combinator_1.reset)({
|
|
|
4619
4636
|
recursions: [10 || 0 /* Recursion.block */, 20 || 0 /* Recursion.blockquote */, 40 || 0 /* Recursion.listitem */, 20 || 0 /* Recursion.inline */, 20 || 0 /* Recursion.bracket */, 20 || 0 /* Recursion.terminal */]
|
|
4620
4637
|
},
|
|
4621
4638
|
backtracks: {}
|
|
4622
|
-
}, error((0, combinator_1.union)([source_1.
|
|
4639
|
+
}, error((0, combinator_1.union)([source_1.emptysegment, input => {
|
|
4623
4640
|
const {
|
|
4624
4641
|
context: {
|
|
4625
4642
|
source,
|
|
4626
|
-
position
|
|
4643
|
+
position,
|
|
4644
|
+
segment
|
|
4627
4645
|
}
|
|
4628
4646
|
} = input;
|
|
4629
4647
|
if (position === source.length) return;
|
|
4648
|
+
switch (segment ^ 1 /* Segment.write */) {
|
|
4649
|
+
case 6 /* Segment.heading */:
|
|
4650
|
+
return (0, heading_1.heading)(input);
|
|
4651
|
+
case 8 /* Segment.fig */:
|
|
4652
|
+
return (0, fig_1.fig)(input);
|
|
4653
|
+
case 10 /* Segment.figure */:
|
|
4654
|
+
return (0, figure_1.figure)(input);
|
|
4655
|
+
}
|
|
4630
4656
|
const fst = source[position];
|
|
4631
4657
|
switch (fst) {
|
|
4658
|
+
case "\u0007" /* Command.Error */:
|
|
4659
|
+
throw new Error((0, combinator_1.firstline)(source, position + 1).trimEnd());
|
|
4632
4660
|
case '=':
|
|
4633
4661
|
if (source.startsWith('===', position)) return (0, pagebreak_1.pagebreak)(input);
|
|
4634
4662
|
break;
|
|
@@ -4650,7 +4678,7 @@ exports.block = (0, combinator_1.reset)({
|
|
|
4650
4678
|
case '[':
|
|
4651
4679
|
switch (source[position + 1]) {
|
|
4652
4680
|
case '$':
|
|
4653
|
-
return (0,
|
|
4681
|
+
return (0, figbase_1.figbase)(input);
|
|
4654
4682
|
case '!':
|
|
4655
4683
|
return (0, mediablock_1.mediablock)(input);
|
|
4656
4684
|
}
|
|
@@ -4661,11 +4689,9 @@ exports.block = (0, combinator_1.reset)({
|
|
|
4661
4689
|
case '>':
|
|
4662
4690
|
if (source[position + 1] === '>') return (0, blockquote_1.blockquote)(input) || (0, reply_1.reply)(input);
|
|
4663
4691
|
return (0, blockquote_1.blockquote)(input);
|
|
4664
|
-
case '#':
|
|
4665
|
-
return (0, heading_1.heading)(input);
|
|
4666
4692
|
case '$':
|
|
4667
4693
|
if (source[position + 1] === '$') return (0, mathblock_1.mathblock)(input);
|
|
4668
|
-
return (0,
|
|
4694
|
+
return (0, figbase_1.figbase)(input);
|
|
4669
4695
|
case '|':
|
|
4670
4696
|
return (0, table_1.table)(input) || (0, sidefence_1.sidefence)(input);
|
|
4671
4697
|
case '(':
|
|
@@ -4676,14 +4702,7 @@ exports.block = (0, combinator_1.reset)({
|
|
|
4676
4702
|
}, paragraph_1.paragraph])));
|
|
4677
4703
|
function error(parser) {
|
|
4678
4704
|
const reg = new RegExp(String.raw`^${"\u0007" /* Command.Error */}[^\n]*\n`);
|
|
4679
|
-
return (0, combinator_1.recover)(
|
|
4680
|
-
context: {
|
|
4681
|
-
source,
|
|
4682
|
-
position
|
|
4683
|
-
}
|
|
4684
|
-
}) => {
|
|
4685
|
-
throw new Error(source.slice(position).split('\n', 1)[0]);
|
|
4686
|
-
}), parser), ({
|
|
4705
|
+
return (0, combinator_1.recover)(parser, ({
|
|
4687
4706
|
context: {
|
|
4688
4707
|
source,
|
|
4689
4708
|
position,
|
|
@@ -4844,7 +4863,6 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
4844
4863
|
}));
|
|
4845
4864
|
exports.extension = exports.segment = void 0;
|
|
4846
4865
|
const combinator_1 = __webpack_require__(3484);
|
|
4847
|
-
const figbase_1 = __webpack_require__(8289);
|
|
4848
4866
|
const fig_1 = __webpack_require__(7396);
|
|
4849
4867
|
const figure_1 = __webpack_require__(4248);
|
|
4850
4868
|
const table_1 = __webpack_require__(3646);
|
|
@@ -4853,7 +4871,10 @@ const aside_1 = __webpack_require__(6150);
|
|
|
4853
4871
|
const example_1 = __webpack_require__(6624);
|
|
4854
4872
|
const placeholder_1 = __webpack_require__(4091);
|
|
4855
4873
|
exports.segment = (0, combinator_1.union)([fig_1.segment, figure_1.segment, table_1.segment, placeholder_1.segment]);
|
|
4856
|
-
exports.extension = (0, combinator_1.union)([
|
|
4874
|
+
exports.extension = (0, combinator_1.union)([
|
|
4875
|
+
//figbase,
|
|
4876
|
+
//fig,
|
|
4877
|
+
figure_1.figure, table_1.table, message_1.message, aside_1.aside, example_1.example, placeholder_1.placeholder]);
|
|
4857
4878
|
|
|
4858
4879
|
/***/ },
|
|
4859
4880
|
|
|
@@ -4987,7 +5008,7 @@ const table_1 = __webpack_require__(3646);
|
|
|
4987
5008
|
const blockquote_1 = __webpack_require__(5885);
|
|
4988
5009
|
const placeholder_1 = __webpack_require__(4091);
|
|
4989
5010
|
const inline_1 = __webpack_require__(7973);
|
|
4990
|
-
exports.segment = (0, combinator_1.block)((0, combinator_1.sequence)([(0, combinator_1.line)((0, combinator_1.close)(label_1.segment, /(?!\S).*\n/y)), (0, combinator_1.union)([codeblock_1.segment, mathblock_1.segment, table_1.segment, blockquote_1.segment, placeholder_1.segment, (0, combinator_1.some)(source_1.contentline)])]));
|
|
5011
|
+
exports.segment = (0, combinator_1.block)((0, combinator_1.sequence)([(0, combinator_1.line)((0, combinator_1.close)(label_1.segment, /(?!\S).*\n/y)), (0, combinator_1.union)([codeblock_1.segment, mathblock_1.segment, table_1.segment, blockquote_1.segment, placeholder_1.segment, (0, combinator_1.some)(source_1.contentline)])]), true, 8 /* Segment.fig */);
|
|
4991
5012
|
exports.fig = (0, combinator_1.block)((0, combinator_1.rewrite)(exports.segment, (0, combinator_1.verify)((0, combinator_1.convert)((source, context) => {
|
|
4992
5013
|
// Bug: TypeScript
|
|
4993
5014
|
const fence = (/^[^\n]*\n!?>+ /.test(source) && source.match(/^~{3,}(?=[^\S\n]*$)/gm) || []).reduce((max, fence) => fence > max ? fence : max, '~~') + '~';
|
|
@@ -4998,6 +5019,7 @@ exports.fig = (0, combinator_1.block)((0, combinator_1.rewrite)(exports.segment,
|
|
|
4998
5019
|
context
|
|
4999
5020
|
});
|
|
5000
5021
|
context.position = position;
|
|
5022
|
+
context.segment = 10 /* Segment.figure */ | 1 /* Segment.write */;
|
|
5001
5023
|
return result ? `${fence}figure ${source.replace(/^(.+\n.+\n)([\S\s]+?)\n?$/, '$1\n$2')}\n${fence}` : `${fence}figure ${source}\n\n${fence}`;
|
|
5002
5024
|
}, (0, combinator_1.union)([figure_1.figure])), ([{
|
|
5003
5025
|
value: el
|
|
@@ -5064,7 +5086,7 @@ const memoize_1 = __webpack_require__(6925);
|
|
|
5064
5086
|
const dom_1 = __webpack_require__(394);
|
|
5065
5087
|
exports.segment = (0, combinator_1.block)((0, combinator_1.match)(/(~{3,})(?:figure )?(?=\[?\$)/y, (0, memoize_1.memoize)(([, fence], closer = new RegExp(String.raw`${fence}[^\S\n]*(?:$|\n)`, 'y')) => (0, combinator_1.close)((0, combinator_1.sequence)([source_1.contentline, (0, combinator_1.inits)([
|
|
5066
5088
|
// All parsers which can include closing terms.
|
|
5067
|
-
(0, combinator_1.union)([codeblock_1.segment_, mathblock_1.segment_, table_2.segment_, blockquote_1.segment, placeholder_1.segment_, (0, combinator_1.some)(source_1.contentline, closer)]), source_1.emptyline, (0, combinator_1.union)([source_1.emptyline, (0, combinator_1.some)(source_1.contentline, closer)])])]), closer), ([, fence]) => fence.length - 1, [], 2 ** 4 - 1)));
|
|
5089
|
+
(0, combinator_1.union)([codeblock_1.segment_, mathblock_1.segment_, table_2.segment_, blockquote_1.segment, placeholder_1.segment_, (0, combinator_1.some)(source_1.contentline, closer)]), source_1.emptyline, (0, combinator_1.union)([source_1.emptyline, (0, combinator_1.some)(source_1.contentline, closer)])])]), closer), ([, fence]) => fence.length - 1, [], 2 ** 4 - 1)), true, 10 /* Segment.figure */);
|
|
5068
5090
|
exports.figure = (0, combinator_1.block)((0, combinator_1.fallback)((0, combinator_1.rewrite)(exports.segment, (0, combinator_1.fmap)((0, combinator_1.convert)(source => source.slice(source.match(/^~+(?:\w+\s+)?/)[0].length, source.trimEnd().lastIndexOf('\n')), (0, combinator_1.sequence)([(0, combinator_1.line)((0, combinator_1.sequence)([label_1.label, (0, source_1.str)(/(?!\S).*\n/y)])), (0, combinator_1.inits)([(0, combinator_1.block)((0, combinator_1.union)([ulist_1.ulist, olist_1.olist, table_1.table, codeblock_1.codeblock, mathblock_1.mathblock, example_1.example, table_2.table, blockquote_1.blockquote, placeholder_1.placeholder, (0, combinator_1.line)(inline_1.media), (0, combinator_1.line)(inline_1.lineshortmedia)])), source_1.emptyline, (0, combinator_1.block)((0, visibility_1.visualize)((0, visibility_1.trimBlank)((0, combinator_1.some)(inline_1.inline))))])])), nodes => {
|
|
5069
5091
|
const [label, param, content, ...caption] = (0, util_1.unwrap)(nodes);
|
|
5070
5092
|
return new parser_1.List([new parser_1.Node((0, dom_1.html)('figure', attributes(label.getAttribute('data-label'), param, content, caption), [(0, dom_1.html)('figcaption', [(0, dom_1.html)('span', {
|
|
@@ -5172,7 +5194,7 @@ exports.message = (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_
|
|
|
5172
5194
|
return new parser_1.List([new parser_1.Node((0, dom_1.html)('section', {
|
|
5173
5195
|
class: `message`,
|
|
5174
5196
|
'data-type': type
|
|
5175
|
-
}, [...(0, segment_1.segment)(body)].reduce((acc, seg) => (0, array_1.push)(acc, (0, util_1.unwrap)(content((0, parser_1.subinput)(seg, context)))), [(0, dom_1.html)('h1', title(type))])))]);
|
|
5197
|
+
}, [...(0, segment_1.segment)(body)].reduce((acc, [seg]) => (0, array_1.push)(acc, (0, util_1.unwrap)(content((0, parser_1.subinput)(seg, context)))), [(0, dom_1.html)('h1', title(type))])))]);
|
|
5176
5198
|
}));
|
|
5177
5199
|
function title(type) {
|
|
5178
5200
|
switch (type) {
|
|
@@ -5508,10 +5530,10 @@ exports.segment = (0, combinator_1.block)((0, combinator_1.focus)(/#+ +\S[^\n]*(
|
|
|
5508
5530
|
context.position += line.length;
|
|
5509
5531
|
}
|
|
5510
5532
|
return acc;
|
|
5511
|
-
}, false));
|
|
5533
|
+
}, false), true, 6 /* Segment.heading */);
|
|
5512
5534
|
exports.heading = (0, combinator_1.block)((0, combinator_1.rewrite)(exports.segment,
|
|
5513
5535
|
// その他の表示制御は各所のCSSで行う。
|
|
5514
|
-
(0, combinator_1.state)(128 /* State.annotation */ | 64 /* State.reference */ | 32 /* State.index */ | 16 /* State.label */ | 8 /* State.link */, (0, combinator_1.line)((0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.union)([(0, combinator_1.open)((0, source_1.
|
|
5536
|
+
(0, combinator_1.state)(128 /* State.annotation */ | 64 /* State.reference */ | 32 /* State.index */ | 16 /* State.label */ | 8 /* State.link */, (0, combinator_1.line)((0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.union)([(0, combinator_1.open)((0, source_1.strs)('#', 2), (0, visibility_1.visualize)((0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))), true), (0, combinator_1.open)((0, source_1.str)('#'), (0, combinator_1.state)(251 /* State.linkers */, (0, visibility_1.visualize)((0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline]))))), true)]), (nodes, context) => {
|
|
5515
5537
|
const [h, ...ns] = (0, util_1.unwrap)(nodes);
|
|
5516
5538
|
return new parser_1.List([h.length <= 6 ? new parser_1.Node((0, dom_1.html)(`h${h.length}`, {
|
|
5517
5539
|
'data-index': (0, inline_1.dataindex)(nodes)
|
|
@@ -6057,6 +6079,7 @@ class Context extends parser_1.Context {
|
|
|
6057
6079
|
constructor(options = {}) {
|
|
6058
6080
|
super(options);
|
|
6059
6081
|
const {
|
|
6082
|
+
segment,
|
|
6060
6083
|
buffer,
|
|
6061
6084
|
sequential,
|
|
6062
6085
|
header,
|
|
@@ -6065,6 +6088,7 @@ class Context extends parser_1.Context {
|
|
|
6065
6088
|
id,
|
|
6066
6089
|
caches
|
|
6067
6090
|
} = options;
|
|
6091
|
+
this.segment = segment ?? 0 /* Segment.unknown */;
|
|
6068
6092
|
this.buffer = buffer ?? new parser_1.List();
|
|
6069
6093
|
this.sequential = sequential ?? false;
|
|
6070
6094
|
this.header = header ?? true;
|
|
@@ -6394,7 +6418,7 @@ const source_1 = __webpack_require__(8745);
|
|
|
6394
6418
|
const dom_1 = __webpack_require__(394);
|
|
6395
6419
|
// https://example/@user must be a user page or a redirect page going there.
|
|
6396
6420
|
// https://example/@user?ch=a+b must be a user channel page or a redirect page going there.
|
|
6397
|
-
exports.account = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(1 /* State.autolink */, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.surround)((0, combinator_1.surround)(/(?<![0-9a-z])@/yi, (0, source_1.str)(/[0-9a-z](?:[.-](?=[0-9a-z])|[0-9a-z]){0,254}\/|/yi), (0, source_1.str)(/[a-z][0-9a-z]*(?:[.-][0-9a-z]+)*(?![_.-]?[0-9a-z@]|>>|:\S)/yi), false, [3 | 8 /* Backtrack.unescapable */]), (0, combinator_1.some)((0, combinator_1.surround)('#', (0, combinator_1.verify)((0, source_1.str)(new RegExp([/(?!['_])(?:[^\p{C}\p{S}\p{P}\s]|emoji|'(?=[0-9A-Za-z])|_(?=[^\p{C}\p{S}\p{P}\s]|emoji))+/yu.source].join('|').replace(/emoji/g, hashtag_1.emoji.source), 'yu')), ([{
|
|
6421
|
+
exports.account = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(1 /* State.autolink */, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.surround)((0, combinator_1.surround)(/(?<![0-9a-z@#])@/yi, (0, source_1.str)(/[0-9a-z](?:[.-](?=[0-9a-z])|[0-9a-z]){0,254}\/|/yi), (0, source_1.str)(/[a-z][0-9a-z]*(?:[.-][0-9a-z]+)*(?![_.-]?[0-9a-z@]|>>|:\S)/yi), false, [3 | 8 /* Backtrack.unescapable */]), (0, combinator_1.some)((0, combinator_1.surround)('#', (0, combinator_1.verify)((0, source_1.str)(new RegExp([/(?!['_])(?:[^\p{C}\p{S}\p{P}\s]|emoji|'(?=[0-9A-Za-z])|_(?=[^\p{C}\p{S}\p{P}\s]|emoji))+/yu.source].join('|').replace(/emoji/g, hashtag_1.emoji.source), 'yu')), ([{
|
|
6398
6422
|
value
|
|
6399
6423
|
}]) => /^[0-9]{0,4}[^0-9]/.test(value)), new RegExp([/(?![_.-]?[0-9a-z@]|>>|:\S|[^\p{C}\p{S}\p{P}\s]|emoji)/yu.source].join('|').replace(/emoji/g, hashtag_1.emoji.source), 'yu'), false, [3 | 8 /* Backtrack.unescapable */])), '', false, [], ([[{
|
|
6400
6424
|
value: host
|
|
@@ -6447,7 +6471,7 @@ const dom_1 = __webpack_require__(394);
|
|
|
6447
6471
|
// cid: YYYY-MMDD-HHMM-SSmmm
|
|
6448
6472
|
// 内部表現はUnixTimeに統一する(時系列順)
|
|
6449
6473
|
// 外部表現は投稿ごとに投稿者の投稿時のタイムゾーンに統一する(非時系列順)
|
|
6450
|
-
exports.anchor = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(1 /* State.autolink */, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.surround)(/(?<![0-9a-z])>>/yi, (0, source_1.str)(/[0-9a-z]+(?:-[0-9a-z]+)*(?![_.-]?[0-9a-z@#]|>>|:\S)/yi), '', false, [3 | 8 /* Backtrack.unescapable */], ([, [{
|
|
6474
|
+
exports.anchor = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(1 /* State.autolink */, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.surround)(/(?<![0-9a-z@#])>>/yi, (0, source_1.str)(/[0-9a-z]+(?:-[0-9a-z]+)*(?![_.-]?[0-9a-z@#]|>>|:\S)/yi), '', false, [3 | 8 /* Backtrack.unescapable */], ([, [{
|
|
6451
6475
|
value
|
|
6452
6476
|
}]], context) => new parser_1.List([new parser_1.Node((0, dom_1.define)((0, link_1.parse)(new parser_1.List([new parser_1.Node(`>>${value}`)]), new parser_1.List([new parser_1.Node(`?at=${value}`)]), context), {
|
|
6453
6477
|
class: 'anchor'
|
|
@@ -6497,7 +6521,7 @@ const link_1 = __webpack_require__(3628);
|
|
|
6497
6521
|
const hashtag_1 = __webpack_require__(5764);
|
|
6498
6522
|
const source_1 = __webpack_require__(8745);
|
|
6499
6523
|
const dom_1 = __webpack_require__(394);
|
|
6500
|
-
exports.hashnum = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(1 /* State.autolink */, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.surround)(new RegExp([/(?<![^\p{C}\p{S}\p{P}\s]|emoji)#/yu.source].join('|').replace(/emoji/g, hashtag_1.emoji.source), 'yu'), (0, source_1.str)(new RegExp([/[0-9]{1,9}(?![_.-]?[0-9a-z@#]|>>|:\S|[^\p{C}\p{S}\p{P}\s]|emoji)/yu.source].join('|').replace(/emoji/g, hashtag_1.emoji.source), 'yu')), '', false,
|
|
6524
|
+
exports.hashnum = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(1 /* State.autolink */, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.surround)(new RegExp([/(?<![^\p{C}\p{S}\p{P}\s]|emoji|[@#])#/yu.source].join('|').replace(/emoji/g, hashtag_1.emoji.source), 'yu'), (0, source_1.str)(new RegExp([/[0-9]{1,9}(?![_.-]?[0-9a-z@#]|>>|:\S|[^\p{C}\p{S}\p{P}\s]|emoji)/yu.source].join('|').replace(/emoji/g, hashtag_1.emoji.source), 'yu')), '', false,
|
|
6501
6525
|
// unescapableを使用するべきだがhashtagとの重複を回避するためescapableを使用する。
|
|
6502
6526
|
[3 | 16 /* Backtrack.escapable */], ([, [{
|
|
6503
6527
|
value
|
|
@@ -6526,7 +6550,7 @@ const dom_1 = __webpack_require__(394);
|
|
|
6526
6550
|
// https://example/hashtags/a must be a hashtag page or a redirect page going there.
|
|
6527
6551
|
// https://github.com/tc39/proposal-regexp-unicode-property-escapes#matching-emoji
|
|
6528
6552
|
exports.emoji = /\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F|\u200D/u;
|
|
6529
|
-
exports.hashtag = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(1 /* State.autolink */, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.surround)(new RegExp([/(?<![^\p{C}\p{S}\p{P}\s]|emoji)#/yu.source].join('|').replace(/emoji/g, exports.emoji.source), 'yu'), (0, combinator_1.verify)((0, source_1.str)(new RegExp([/(?!['_])(?:[^\p{C}\p{S}\p{P}\s]|emoji|'(?=[0-9A-Za-z])|_(?=[^\p{C}\p{S}\p{P}\s]|emoji))+/yu.source].join('|').replace(/emoji/g, exports.emoji.source), 'yu')), ([{
|
|
6553
|
+
exports.hashtag = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(1 /* State.autolink */, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.surround)(new RegExp([/(?<![^\p{C}\p{S}\p{P}\s]|emoji|[@#])#/yu.source].join('|').replace(/emoji/g, exports.emoji.source), 'yu'), (0, combinator_1.verify)((0, source_1.str)(new RegExp([/(?!['_])(?:[^\p{C}\p{S}\p{P}\s]|emoji|'(?=[0-9A-Za-z])|_(?=[^\p{C}\p{S}\p{P}\s]|emoji))+/yu.source].join('|').replace(/emoji/g, exports.emoji.source), 'yu')), ([{
|
|
6530
6554
|
value
|
|
6531
6555
|
}]) => /^[0-9]{0,4}[^0-9]/.test(value)), new RegExp([/(?![_.-]?[0-9a-z@#]|>>|:\S|[^\p{C}\p{S}\p{P}\s]|emoji)/yu.source].join('|').replace(/emoji/g, exports.emoji.source), 'yu'), false, [3 | 8 /* Backtrack.unescapable */], ([, [{
|
|
6532
6556
|
value
|
|
@@ -6792,7 +6816,7 @@ const subemphasis = (0, combinator_1.lazy)(() => (0, combinator_1.some)((0, comb
|
|
|
6792
6816
|
// 開閉が明示的でない構文は開閉の不明確な記号による再帰的適用を行わず
|
|
6793
6817
|
// 可能な限り早く閉じるよう解析しなければならない。
|
|
6794
6818
|
// このため終端記号の後ろを見て終端を中止し同じ構文を再帰的に適用してはならない。
|
|
6795
|
-
exports.emstrong = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, util_1.repeat)('***', visibility_1.beforeNonblank, (0, combinator_1.surround)('', (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, '*', visibility_1.afterNonblank)])), (0, source_1.strs)('*', 3), false, [], ([, bs, cs], context) => {
|
|
6819
|
+
exports.emstrong = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, util_1.repeat)('***', visibility_1.beforeNonblank, (0, combinator_1.surround)('', (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, '*', visibility_1.afterNonblank)])), (0, source_1.strs)('*', 1, 3), false, [], ([, bs, cs], context) => {
|
|
6796
6820
|
const {
|
|
6797
6821
|
buffer
|
|
6798
6822
|
} = context;
|
|
@@ -7015,7 +7039,7 @@ function identity(type, id, text) {
|
|
|
7015
7039
|
if (typeof text !== 'string') {
|
|
7016
7040
|
const index = text.getAttribute('data-index') ?? undefined;
|
|
7017
7041
|
if (index === '' && text.tagName === 'LI') return undefined;
|
|
7018
|
-
return index ? `${type}:${id ?? ''}:${index}` : identity(type, id, signature(text));
|
|
7042
|
+
return index ? `${type}:${id ?? ''}:${index}` : identity(type, id, signature(text.cloneNode(true)));
|
|
7019
7043
|
}
|
|
7020
7044
|
text = text.trim();
|
|
7021
7045
|
if (text === '') return undefined;
|
|
@@ -7051,9 +7075,8 @@ function baseR(n, r) {
|
|
|
7051
7075
|
} while (n > 0);
|
|
7052
7076
|
return acc;
|
|
7053
7077
|
}
|
|
7054
|
-
function signature(
|
|
7055
|
-
|
|
7056
|
-
for (let es = target.querySelectorAll('code[data-src], .math[data-src], .label[data-label], .remark, rt, rp, br, .annotation, .reference, .checkbox, ul, ol'), len = es.length, i = 0; i < len; ++i) {
|
|
7078
|
+
function signature(target) {
|
|
7079
|
+
for (let es = target.querySelectorAll('code[data-src], .math[data-src], .remark, rt, rp, br, .annotation, .reference, .checkbox, ul, ol, .label[data-label]'), len = es.length, i = 0; i < len; ++i) {
|
|
7057
7080
|
const el = es[i];
|
|
7058
7081
|
switch (el.tagName) {
|
|
7059
7082
|
case 'CODE':
|
|
@@ -7087,8 +7110,7 @@ function signature(source) {
|
|
|
7087
7110
|
return target.textContent.trim();
|
|
7088
7111
|
}
|
|
7089
7112
|
exports.signature = signature;
|
|
7090
|
-
function text(
|
|
7091
|
-
const target = source.cloneNode(true);
|
|
7113
|
+
function text(target) {
|
|
7092
7114
|
for (let es = target.querySelectorAll('code[data-src], .math[data-src], .remark, rt, rp, br, .annotation, .reference, .checkbox, ul, ol'), len = es.length, i = 0; i < len; ++i) {
|
|
7093
7115
|
const el = es[i];
|
|
7094
7116
|
switch (el.tagName) {
|
|
@@ -7576,7 +7598,7 @@ exports.mark = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0,
|
|
|
7576
7598
|
const el = (0, dom_1.html)('mark', (0, dom_1.defrag)((0, util_1.unwrap)(nodes)));
|
|
7577
7599
|
if (state & 251 /* State.linkers */ || nest) return new parser_1.List([new parser_1.Node(el)]);
|
|
7578
7600
|
(0, dom_1.define)(el, {
|
|
7579
|
-
id: (0, indexee_1.identity)('mark', id, (0, indexee_1.signature)(el))
|
|
7601
|
+
id: (0, indexee_1.identity)('mark', id, (0, indexee_1.signature)(el.cloneNode(true)))
|
|
7580
7602
|
});
|
|
7581
7603
|
return el.id ? new parser_1.List([new parser_1.Node(el), new parser_1.Node((0, dom_1.html)('a', {
|
|
7582
7604
|
href: `#${el.id}`
|
|
@@ -8210,25 +8232,30 @@ function build(syntax, marker, splitter = '') {
|
|
|
8210
8232
|
splitter &&= `${splitter}, .${syntax}s`;
|
|
8211
8233
|
// Referenceを含むAnnotationの重複排除は両構文が互いに処理済みであることを必要とするため
|
|
8212
8234
|
// 構文ごとに各1回の処理では不可能
|
|
8213
|
-
const
|
|
8235
|
+
const refInfo = (0, memoize_1.memoize)(ref => {
|
|
8214
8236
|
const content = ref.firstElementChild;
|
|
8215
8237
|
content.replaceWith(content.cloneNode());
|
|
8216
8238
|
const abbr = ref.getAttribute('data-abbr') ?? '';
|
|
8217
|
-
const
|
|
8239
|
+
const clone = content.cloneNode(true);
|
|
8240
|
+
const txt = (0, indexee_1.text)(clone).trim();
|
|
8241
|
+
const identifier = abbr ? (0, indexee_1.identity)('', undefined, abbr.match(/^(?:\S+ )+?(?:(?:January|February|March|April|May|June|August|September|October|November|December) \d{1,2}(?:-\d{0,2})?, \d{1,4}(?:-\d{0,4})?[a-z]?|n\.d\.)(?=,|$)/)?.[0] ?? abbr.match(/^[^,\s]+(?:,? [^,\s]+)*?(?: \d{1,4}(?:-\d{0,4})?[a-z]?(?=,|$)|(?=,(?: [a-z]+\.?)? [0-9]))/)?.[0] ?? abbr)?.slice(2) || '' : (0, indexee_1.identity)('mark', undefined, (0, indexee_1.signature)(clone))?.slice(6) || '';
|
|
8218
8242
|
return {
|
|
8219
8243
|
content,
|
|
8220
8244
|
identifier,
|
|
8221
8245
|
abbr,
|
|
8222
|
-
text:
|
|
8246
|
+
text: txt
|
|
8223
8247
|
};
|
|
8224
8248
|
}, new WeakMap());
|
|
8225
8249
|
return function* (target, note, opts = {}, bottom = null) {
|
|
8226
8250
|
const defs = new Map();
|
|
8227
8251
|
const refs = target.querySelectorAll(`sup.${syntax}:not(.disabled)`);
|
|
8228
|
-
const
|
|
8229
|
-
|
|
8230
|
-
|
|
8231
|
-
|
|
8252
|
+
const identifierInfo = (0, memoize_1.memoize)(identifier => ({
|
|
8253
|
+
defIndex: 0,
|
|
8254
|
+
defSubindex: 0,
|
|
8255
|
+
refSubindex: 0,
|
|
8256
|
+
title: '' && 0,
|
|
8257
|
+
queue: []
|
|
8258
|
+
}));
|
|
8232
8259
|
const scope = target instanceof Element ? ':scope > ' : '';
|
|
8233
8260
|
const splitters = splitter ? target.querySelectorAll(`${scope}:is(${splitter})`) : [];
|
|
8234
8261
|
let iSplitters = 0;
|
|
@@ -8261,29 +8288,36 @@ function build(syntax, marker, splitter = '') {
|
|
|
8261
8288
|
identifier,
|
|
8262
8289
|
abbr,
|
|
8263
8290
|
text
|
|
8264
|
-
} =
|
|
8265
|
-
const
|
|
8266
|
-
|
|
8291
|
+
} = refInfo(ref);
|
|
8292
|
+
const info = identifierInfo(identifier);
|
|
8293
|
+
const refSubindex = ++info.refSubindex;
|
|
8267
8294
|
const refId = opts.id !== '' ? `${syntax}:${opts.id ?? ''}:ref:${identifier}:${refSubindex}` : undefined;
|
|
8268
8295
|
const initial = splitter ? !defs.has(identifier) : refSubindex === 1;
|
|
8269
|
-
const defSubindex =
|
|
8270
|
-
initial && defSubindexes?.set(identifier, defSubindex);
|
|
8296
|
+
const defSubindex = initial ? ++info.defSubindex : info.defSubindex;
|
|
8271
8297
|
const defId = opts.id !== '' ? `${syntax}:${opts.id ?? ''}:def:${identifier}${splitter && `:${defSubindex}`}` : undefined;
|
|
8272
8298
|
const def = initial ? (0, dom_1.html)('li', {
|
|
8273
8299
|
id: defId,
|
|
8274
8300
|
'data-marker': note ? undefined : marker(total + defs.size + 1, abbr)
|
|
8275
8301
|
}, [content.cloneNode(true), (0, dom_1.html)('sup')]) : defs.get(identifier);
|
|
8276
8302
|
initial && defs.set(identifier, def);
|
|
8277
|
-
const defIndex = initial ? total + defs.size :
|
|
8278
|
-
|
|
8279
|
-
const title = initial ? text : titles.get(identifier);
|
|
8280
|
-
initial && titles.set(identifier, title);
|
|
8303
|
+
const defIndex = initial ? info.defIndex = total + defs.size : info.defIndex;
|
|
8304
|
+
const title = info.title ||= text;
|
|
8281
8305
|
ref.childElementCount > 1 && ref.lastElementChild.remove();
|
|
8282
8306
|
(0, dom_1.define)(ref, {
|
|
8283
8307
|
id: refId,
|
|
8284
8308
|
class: opts.id !== '' ? undefined : void ref.classList.add('disabled'),
|
|
8285
8309
|
title
|
|
8286
8310
|
});
|
|
8311
|
+
if (title && info.queue.length > 0) {
|
|
8312
|
+
for (const ref of info.queue) {
|
|
8313
|
+
(0, dom_1.define)(ref, {
|
|
8314
|
+
title
|
|
8315
|
+
});
|
|
8316
|
+
(0, util_1.unmarkInvalid)(ref);
|
|
8317
|
+
}
|
|
8318
|
+
info.queue = [];
|
|
8319
|
+
def.firstElementChild.replaceWith(content.cloneNode(true));
|
|
8320
|
+
}
|
|
8287
8321
|
switch (ref.getAttribute('data-invalid-syntax')) {
|
|
8288
8322
|
case 'format':
|
|
8289
8323
|
case 'content':
|
|
@@ -8291,11 +8325,12 @@ function build(syntax, marker, splitter = '') {
|
|
|
8291
8325
|
}
|
|
8292
8326
|
format ??= abbr ? 'abbr' : 'number';
|
|
8293
8327
|
if (!ref.classList.contains('invalid')) switch (true) {
|
|
8294
|
-
case format === 'number' ?
|
|
8328
|
+
case format === 'number' ? abbr !== '' : abbr === '':
|
|
8295
8329
|
(0, util_1.markInvalid)(ref, syntax, 'format', 'Notation format must be consistent with numbers or abbreviations');
|
|
8296
8330
|
break;
|
|
8297
|
-
case
|
|
8331
|
+
case title === '':
|
|
8298
8332
|
(0, util_1.markInvalid)(ref, syntax, 'content', 'Missing the content');
|
|
8333
|
+
info.queue.push(ref);
|
|
8299
8334
|
break;
|
|
8300
8335
|
}
|
|
8301
8336
|
yield ref.appendChild((0, dom_1.html)('a', {
|
|
@@ -8373,7 +8408,7 @@ const extension_1 = __webpack_require__(6193);
|
|
|
8373
8408
|
const source_1 = __webpack_require__(8745);
|
|
8374
8409
|
exports.MAX_SEGMENT_SIZE = 100_000; // 100,000 bytes (Max value size of FDB)
|
|
8375
8410
|
exports.MAX_INPUT_SIZE = exports.MAX_SEGMENT_SIZE * 10;
|
|
8376
|
-
const parser = (0, combinator_1.union)([(0, combinator_1.some)(source_1.
|
|
8411
|
+
const parser = (0, combinator_1.union)([(0, combinator_1.some)(source_1.emptysegment, exports.MAX_SEGMENT_SIZE + 1), input => {
|
|
8377
8412
|
const {
|
|
8378
8413
|
context: {
|
|
8379
8414
|
source,
|
|
@@ -8390,18 +8425,16 @@ const parser = (0, combinator_1.union)([(0, combinator_1.some)(source_1.emptylin
|
|
|
8390
8425
|
break;
|
|
8391
8426
|
case '$':
|
|
8392
8427
|
if (source[position + 1] === '$') return (0, mathblock_1.segment)(input);
|
|
8393
|
-
|
|
8428
|
+
return (0, extension_1.segment)(input);
|
|
8394
8429
|
case '[':
|
|
8395
8430
|
if (source[position + 1] === '$') return (0, extension_1.segment)(input);
|
|
8396
8431
|
break;
|
|
8397
8432
|
case '#':
|
|
8398
8433
|
return (0, heading_1.segment)(input);
|
|
8399
|
-
case '$':
|
|
8400
|
-
return (0, extension_1.segment)(input);
|
|
8401
8434
|
}
|
|
8402
8435
|
}, (0, combinator_1.some)(source_1.contentline, exports.MAX_SEGMENT_SIZE + 1)]);
|
|
8403
8436
|
function* segment(source) {
|
|
8404
|
-
if (!validate(source, exports.MAX_INPUT_SIZE)) return yield `${"\u0007" /* Command.Error */}Too large input over ${exports.MAX_INPUT_SIZE.toLocaleString('en')} bytes.\n${source.slice(0, 1001)}
|
|
8437
|
+
if (!validate(source, exports.MAX_INPUT_SIZE)) return yield [`${"\u0007" /* Command.Error */}Too large input over ${exports.MAX_INPUT_SIZE.toLocaleString('en')} bytes.\n${source.slice(0, 1001)}`, 0 /* Segment.unknown */];
|
|
8405
8438
|
for (let position = 0; position < source.length;) {
|
|
8406
8439
|
const context = new context_1.Context({
|
|
8407
8440
|
source,
|
|
@@ -8413,11 +8446,11 @@ function* segment(source) {
|
|
|
8413
8446
|
const segs = result.length > 0 ? result.foldl((acc, {
|
|
8414
8447
|
value
|
|
8415
8448
|
}) => void acc.push(value) || acc, []) : [source.slice(position, context.position)];
|
|
8449
|
+
position = context.position;
|
|
8416
8450
|
for (let i = 0; i < segs.length; ++i) {
|
|
8417
8451
|
const seg = segs[i];
|
|
8418
|
-
validate(seg, exports.MAX_SEGMENT_SIZE) ? yield seg : yield `${"\u0007" /* Command.Error */}Too large segment over ${exports.MAX_SEGMENT_SIZE.toLocaleString('en')} bytes.\n${seg}
|
|
8452
|
+
validate(seg, exports.MAX_SEGMENT_SIZE) ? yield [seg, context.segment] : yield [`${"\u0007" /* Command.Error */}Too large segment over ${exports.MAX_SEGMENT_SIZE.toLocaleString('en')} bytes.\n${seg}`, 0 /* Segment.unknown */];
|
|
8419
8453
|
}
|
|
8420
|
-
position = context.position;
|
|
8421
8454
|
}
|
|
8422
8455
|
}
|
|
8423
8456
|
exports.segment = segment;
|
|
@@ -8437,7 +8470,7 @@ exports.validate = validate;
|
|
|
8437
8470
|
Object.defineProperty(exports, "__esModule", ({
|
|
8438
8471
|
value: true
|
|
8439
8472
|
}));
|
|
8440
|
-
exports.anyline = exports.emptyline = exports.contentline = exports.strs = exports.str = exports.unescsource = exports.escsource = exports.txt = exports.text = void 0;
|
|
8473
|
+
exports.anyline = exports.emptysegment = exports.emptyline = exports.contentline = exports.strs = exports.str = exports.unescsource = exports.escsource = exports.txt = exports.text = void 0;
|
|
8441
8474
|
var text_1 = __webpack_require__(5655);
|
|
8442
8475
|
Object.defineProperty(exports, "text", ({
|
|
8443
8476
|
enumerable: true,
|
|
@@ -8491,6 +8524,12 @@ Object.defineProperty(exports, "emptyline", ({
|
|
|
8491
8524
|
return line_1.emptyline;
|
|
8492
8525
|
}
|
|
8493
8526
|
}));
|
|
8527
|
+
Object.defineProperty(exports, "emptysegment", ({
|
|
8528
|
+
enumerable: true,
|
|
8529
|
+
get: function () {
|
|
8530
|
+
return line_1.emptysegment;
|
|
8531
|
+
}
|
|
8532
|
+
}));
|
|
8494
8533
|
Object.defineProperty(exports, "anyline", ({
|
|
8495
8534
|
enumerable: true,
|
|
8496
8535
|
get: function () {
|
|
@@ -8571,7 +8610,7 @@ exports.escsource = escsource;
|
|
|
8571
8610
|
Object.defineProperty(exports, "__esModule", ({
|
|
8572
8611
|
value: true
|
|
8573
8612
|
}));
|
|
8574
|
-
exports.contentline = exports.emptyline = exports.anyline = void 0;
|
|
8613
|
+
exports.contentline = exports.emptysegment = exports.emptyline = exports.anyline = void 0;
|
|
8575
8614
|
const parser_1 = __webpack_require__(605);
|
|
8576
8615
|
const anyline = input => {
|
|
8577
8616
|
const {
|
|
@@ -8596,15 +8635,40 @@ const emptyline = input => {
|
|
|
8596
8635
|
position
|
|
8597
8636
|
} = context;
|
|
8598
8637
|
if (position === source.length) return;
|
|
8599
|
-
|
|
8600
|
-
|
|
8601
|
-
regEmptyline.test(source);
|
|
8602
|
-
const i = regEmptyline.lastIndex;
|
|
8603
|
-
if (i === 0) return;
|
|
8638
|
+
const i = eoel(source, position);
|
|
8639
|
+
if (i === position) return;
|
|
8604
8640
|
context.position = i;
|
|
8605
8641
|
return new parser_1.List();
|
|
8606
8642
|
};
|
|
8607
8643
|
exports.emptyline = emptyline;
|
|
8644
|
+
const emptysegment = input => {
|
|
8645
|
+
const {
|
|
8646
|
+
context
|
|
8647
|
+
} = input;
|
|
8648
|
+
const {
|
|
8649
|
+
source,
|
|
8650
|
+
position,
|
|
8651
|
+
segment
|
|
8652
|
+
} = context;
|
|
8653
|
+
if (position === source.length) return;
|
|
8654
|
+
if (segment & 1 /* Segment.write */) {
|
|
8655
|
+
if (segment !== (2 /* Segment.empty */ | 1 /* Segment.write */)) return;
|
|
8656
|
+
context.position = source.length;
|
|
8657
|
+
return new parser_1.List();
|
|
8658
|
+
}
|
|
8659
|
+
const i = eoel(source, position);
|
|
8660
|
+
if (i === position) return;
|
|
8661
|
+
context.position = i;
|
|
8662
|
+
context.segment = 2 /* Segment.empty */;
|
|
8663
|
+
return new parser_1.List();
|
|
8664
|
+
};
|
|
8665
|
+
exports.emptysegment = emptysegment;
|
|
8666
|
+
function eoel(source, position) {
|
|
8667
|
+
if (source[position] === '\n') return position + 1;
|
|
8668
|
+
regEmptyline.lastIndex = position;
|
|
8669
|
+
regEmptyline.test(source);
|
|
8670
|
+
return regEmptyline.lastIndex || position;
|
|
8671
|
+
}
|
|
8608
8672
|
const regContentline = /[^\S\n]*\S[^\n]*(?:$|\n)/y;
|
|
8609
8673
|
const contentline = input => {
|
|
8610
8674
|
const {
|
|
@@ -8643,19 +8707,19 @@ function str(pattern, after) {
|
|
|
8643
8707
|
return (0, delimiter_1.matcher)(pattern, true, after ? (0, delimiter_1.tester)(after, false) : undefined);
|
|
8644
8708
|
}
|
|
8645
8709
|
exports.str = str;
|
|
8646
|
-
function strs(
|
|
8710
|
+
function strs(char, min = 1, max = -1) {
|
|
8647
8711
|
return ({
|
|
8648
8712
|
context
|
|
8649
8713
|
}) => {
|
|
8650
8714
|
const {
|
|
8651
|
-
source
|
|
8715
|
+
source,
|
|
8716
|
+
position
|
|
8652
8717
|
} = context;
|
|
8653
|
-
let
|
|
8654
|
-
for (
|
|
8655
|
-
|
|
8656
|
-
context.position += pattern.length;
|
|
8718
|
+
let cnt = 0;
|
|
8719
|
+
for (; cnt !== max && context.position < source.length && source[context.position] === char; ++cnt) {
|
|
8720
|
+
context.position += char.length;
|
|
8657
8721
|
}
|
|
8658
|
-
return
|
|
8722
|
+
return cnt >= min ? new parser_1.List([new parser_1.Node(source.slice(position, context.position))]) : undefined;
|
|
8659
8723
|
};
|
|
8660
8724
|
}
|
|
8661
8725
|
exports.strs = strs;
|
package/markdown.d.ts
CHANGED
|
@@ -15,12 +15,12 @@ export namespace MarkdownParser {
|
|
|
15
15
|
export interface SegmentParser extends
|
|
16
16
|
Markdown<'segment'>,
|
|
17
17
|
Parser<string, Context, [
|
|
18
|
+
SourceParser.EmptySegmentParser,
|
|
18
19
|
BlockParser.HeadingParser.SegmentParser,
|
|
19
20
|
BlockParser.CodeBlockParser.SegmentParser,
|
|
20
21
|
BlockParser.MathBlockParser.SegmentParser,
|
|
21
22
|
BlockParser.ExtensionParser.SegmentParser,
|
|
22
23
|
SourceParser.ContentLineParser,
|
|
23
|
-
SourceParser.EmptyLineParser,
|
|
24
24
|
]> {
|
|
25
25
|
}
|
|
26
26
|
export interface HeaderParser extends
|
|
@@ -47,7 +47,7 @@ export namespace MarkdownParser {
|
|
|
47
47
|
export interface BlockParser extends
|
|
48
48
|
Markdown<'block'>,
|
|
49
49
|
Parser<HTMLElement, Context, [
|
|
50
|
-
SourceParser.
|
|
50
|
+
SourceParser.EmptySegmentParser,
|
|
51
51
|
BlockParser.PagebreakParser,
|
|
52
52
|
BlockParser.HeadingParser,
|
|
53
53
|
BlockParser.UListParser,
|
|
@@ -296,8 +296,8 @@ export namespace MarkdownParser {
|
|
|
296
296
|
// ~~~
|
|
297
297
|
Block<'extension'>,
|
|
298
298
|
Parser<HTMLElement, Context, [
|
|
299
|
-
ExtensionParser.FigbaseParser,
|
|
300
|
-
ExtensionParser.FigParser,
|
|
299
|
+
//ExtensionParser.FigbaseParser,
|
|
300
|
+
//ExtensionParser.FigParser,
|
|
301
301
|
ExtensionParser.FigureParser,
|
|
302
302
|
ExtensionParser.TableParser,
|
|
303
303
|
ExtensionParser.MessageParser,
|
|
@@ -1196,6 +1196,10 @@ export namespace MarkdownParser {
|
|
|
1196
1196
|
Source<'emptyline'>,
|
|
1197
1197
|
Parser<never, Context, []> {
|
|
1198
1198
|
}
|
|
1199
|
+
export interface EmptySegmentParser extends
|
|
1200
|
+
Source<'emptysegment'>,
|
|
1201
|
+
Parser<never, Context, []> {
|
|
1202
|
+
}
|
|
1199
1203
|
export interface AnyLineParser extends
|
|
1200
1204
|
Source<'anyline'>,
|
|
1201
1205
|
Parser<never, Context, []> {
|