securemark 0.280.3 → 0.280.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/dist/index.js +41 -31
- package/index.ts +2 -0
- package/markdown.d.ts +4 -14
- package/package.json +1 -1
- package/src/combinator/control/constraint/contract.ts +0 -1
- package/src/combinator/control/manipulation/convert.ts +7 -2
- package/src/combinator/control/manipulation/indent.ts +4 -2
- package/src/combinator/control/manipulation/scope.ts +8 -4
- package/src/combinator/data/parser/context/memo.ts +2 -2
- package/src/parser/block/dlist.ts +2 -1
- package/src/parser/block/extension/table.ts +2 -1
- package/src/parser/block/ilist.ts +4 -2
- package/src/parser/block/olist.test.ts +4 -2
- package/src/parser/block/olist.ts +5 -8
- package/src/parser/block/paragraph.ts +3 -3
- package/src/parser/block/reply.ts +2 -1
- package/src/parser/block/ulist.test.ts +4 -2
- package/src/parser/block/ulist.ts +7 -9
- package/src/parser/inline/autolink.ts +1 -1
- package/src/parser/util.ts +7 -0
- package/src/parser/visibility.ts +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.280.
|
|
1
|
+
/*! securemark v0.280.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"));
|
|
@@ -40,6 +40,7 @@ var __exportStar = this && this.__exportStar || function (m, exports) {
|
|
|
40
40
|
Object.defineProperty(exports, "__esModule", ({
|
|
41
41
|
value: true
|
|
42
42
|
}));
|
|
43
|
+
__webpack_require__(4128);
|
|
43
44
|
__exportStar(__webpack_require__(3019), exports);
|
|
44
45
|
__exportStar(__webpack_require__(4613), exports);
|
|
45
46
|
__exportStar(__webpack_require__(256), exports);
|
|
@@ -2713,7 +2714,6 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
2713
2714
|
value: true
|
|
2714
2715
|
}));
|
|
2715
2716
|
exports.verify = exports.validate = void 0;
|
|
2716
|
-
__webpack_require__(4128);
|
|
2717
2717
|
const alias_1 = __webpack_require__(5406);
|
|
2718
2718
|
const parser_1 = __webpack_require__(6728);
|
|
2719
2719
|
function validate(patterns, has, parser) {
|
|
@@ -2814,6 +2814,7 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
2814
2814
|
}));
|
|
2815
2815
|
exports.convert = void 0;
|
|
2816
2816
|
const parser_1 = __webpack_require__(6728);
|
|
2817
|
+
const alias_1 = __webpack_require__(5406);
|
|
2817
2818
|
function convert(conv, parser, empty = false) {
|
|
2818
2819
|
return ({
|
|
2819
2820
|
source,
|
|
@@ -2822,13 +2823,14 @@ function convert(conv, parser, empty = false) {
|
|
|
2822
2823
|
if (source === '') return;
|
|
2823
2824
|
const src = conv(source, context);
|
|
2824
2825
|
if (src === '') return empty ? [[], ''] : undefined;
|
|
2826
|
+
const offset = (0, alias_1.max)(source.length - src.length, 0);
|
|
2825
2827
|
context.offset ??= 0;
|
|
2826
|
-
context.offset +=
|
|
2828
|
+
context.offset += offset;
|
|
2827
2829
|
const result = parser({
|
|
2828
2830
|
source: src,
|
|
2829
2831
|
context
|
|
2830
2832
|
});
|
|
2831
|
-
context.offset -=
|
|
2833
|
+
context.offset -= offset;
|
|
2832
2834
|
return result;
|
|
2833
2835
|
};
|
|
2834
2836
|
}
|
|
@@ -2953,13 +2955,14 @@ function indent(opener, parser, separation = false) {
|
|
|
2953
2955
|
return (0, bind_1.bind)((0, block_1.block)((0, match_1.match)(opener, (0, memoize_1.memoize)(([indent]) => (0, some_1.some)((0, line_1.line)((0, surround_1.open)(indent, ({
|
|
2954
2956
|
source
|
|
2955
2957
|
}) => [[source], '']))), ([indent]) => indent.length * 2 + +(indent[0] === ' '), {})), separation), (lines, rest, context) => {
|
|
2958
|
+
const offset = rest.length;
|
|
2956
2959
|
context.offset ??= 0;
|
|
2957
|
-
context.offset +=
|
|
2960
|
+
context.offset += offset;
|
|
2958
2961
|
const result = parser({
|
|
2959
2962
|
source: trimBlockEnd(lines.join('')),
|
|
2960
2963
|
context
|
|
2961
2964
|
});
|
|
2962
|
-
context.offset -=
|
|
2965
|
+
context.offset -= offset;
|
|
2963
2966
|
return result && (0, parser_1.exec)(result) === '' ? [(0, parser_1.eval)(result), rest] : undefined;
|
|
2964
2967
|
});
|
|
2965
2968
|
}
|
|
@@ -3080,13 +3083,14 @@ function focus(scope, parser) {
|
|
|
3080
3083
|
if (source === '') return;
|
|
3081
3084
|
const src = match(source);
|
|
3082
3085
|
if (src === '') return;
|
|
3086
|
+
const offset = source.length - src.length;
|
|
3083
3087
|
context.offset ??= 0;
|
|
3084
|
-
context.offset +=
|
|
3088
|
+
context.offset += offset;
|
|
3085
3089
|
const result = parser({
|
|
3086
3090
|
source: src,
|
|
3087
3091
|
context
|
|
3088
3092
|
});
|
|
3089
|
-
context.offset -=
|
|
3093
|
+
context.offset -= offset;
|
|
3090
3094
|
if (result === undefined) return;
|
|
3091
3095
|
return (0, parser_1.exec)(result).length < src.length ? [(0, parser_1.eval)(result), (0, parser_1.exec)(result) + source.slice(src.length)] : undefined;
|
|
3092
3096
|
};
|
|
@@ -3107,13 +3111,14 @@ function rewrite(scope, parser) {
|
|
|
3107
3111
|
context.memo = memo;
|
|
3108
3112
|
if (res1 === undefined || (0, parser_1.exec)(res1).length >= source.length) return;
|
|
3109
3113
|
const src = source.slice(0, source.length - (0, parser_1.exec)(res1).length);
|
|
3114
|
+
const offset = source.length - src.length;
|
|
3110
3115
|
context.offset ??= 0;
|
|
3111
|
-
context.offset +=
|
|
3116
|
+
context.offset += offset;
|
|
3112
3117
|
const res2 = parser({
|
|
3113
3118
|
source: src,
|
|
3114
3119
|
context
|
|
3115
3120
|
});
|
|
3116
|
-
context.offset -=
|
|
3121
|
+
context.offset -= offset;
|
|
3117
3122
|
if (res2 === undefined) return;
|
|
3118
3123
|
return (0, parser_1.exec)(res2).length < src.length ? [(0, parser_1.eval)(res2), (0, parser_1.exec)(res2) + (0, parser_1.exec)(res1)] : undefined;
|
|
3119
3124
|
};
|
|
@@ -3645,10 +3650,10 @@ class Memo {
|
|
|
3645
3650
|
|
|
3646
3651
|
resize(position) {
|
|
3647
3652
|
const memory = this.memory;
|
|
3648
|
-
for (let
|
|
3653
|
+
for (let i = memory.length; i > position; --i) {
|
|
3649
3654
|
this.count -= +memory.pop();
|
|
3650
3655
|
}
|
|
3651
|
-
//console.log('resize', position);
|
|
3656
|
+
//console.log('resize', position + 1);
|
|
3652
3657
|
}
|
|
3653
3658
|
|
|
3654
3659
|
clear() {
|
|
@@ -4513,12 +4518,13 @@ exports.dlist = void 0;
|
|
|
4513
4518
|
const combinator_1 = __webpack_require__(2087);
|
|
4514
4519
|
const inline_1 = __webpack_require__(1160);
|
|
4515
4520
|
const source_1 = __webpack_require__(6743);
|
|
4521
|
+
const util_1 = __webpack_require__(9437);
|
|
4516
4522
|
const visibility_1 = __webpack_require__(7618);
|
|
4517
4523
|
const array_1 = __webpack_require__(8112);
|
|
4518
4524
|
const dom_1 = __webpack_require__(3252);
|
|
4519
4525
|
exports.dlist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^~[^\S\n]+(?=\S)/, (0, combinator_1.some)((0, combinator_1.inits)([(0, combinator_1.state)(256 /* State.annotation */ | 128 /* State.reference */ | 64 /* State.index */ | 32 /* State.label */ | 16 /* State.link */ | 8 /* State.media */, (0, combinator_1.some)(term)), (0, combinator_1.some)(desc)]))), es => [(0, dom_1.html)('dl', fillTrailingDescription(es))])));
|
|
4520
4526
|
const term = (0, combinator_1.creation)(1, false, (0, combinator_1.line)((0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.open)(/^~[^\S\n]+(?=\S)/, (0, visibility_1.visualize)((0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))), true), ns => [(0, dom_1.html)('dt', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))]))));
|
|
4521
|
-
const desc = (0, combinator_1.creation)(1, false, (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)(/^:[^\S\n]+(?=\S)|/, (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.anyline, /^[~:][^\S\n]+\S/), (0, visibility_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline])))), true), ns => [(0, dom_1.html)('dd', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))]), false));
|
|
4527
|
+
const desc = (0, combinator_1.creation)(1, false, (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)(/^:[^\S\n]+(?=\S)|/, (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.anyline, /^[~:][^\S\n]+\S/), (0, visibility_1.visualize)((0, util_1.lineable)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))))), true), ns => [(0, dom_1.html)('dd', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))]), false));
|
|
4522
4528
|
function fillTrailingDescription(es) {
|
|
4523
4529
|
return es.length > 0 && es[es.length - 1].tagName === 'DT' ? (0, array_1.push)(es, [(0, dom_1.html)('dd')]) : es;
|
|
4524
4530
|
}
|
|
@@ -4963,6 +4969,7 @@ const parser_1 = __webpack_require__(6728);
|
|
|
4963
4969
|
const combinator_1 = __webpack_require__(2087);
|
|
4964
4970
|
const inline_1 = __webpack_require__(1160);
|
|
4965
4971
|
const source_1 = __webpack_require__(6743);
|
|
4972
|
+
const util_1 = __webpack_require__(9437);
|
|
4966
4973
|
const visibility_1 = __webpack_require__(7618);
|
|
4967
4974
|
const array_1 = __webpack_require__(8112);
|
|
4968
4975
|
const dom_1 = __webpack_require__(3252);
|
|
@@ -5004,7 +5011,7 @@ const alignment = /^[-=<>]+(?:\/[-=^v]*)?(?=[^\S\n]*\n)/;
|
|
|
5004
5011
|
const align = (0, combinator_1.line)((0, combinator_1.fmap)((0, combinator_1.union)([(0, source_1.str)(alignment)]), ([s]) => s.split('/').map(s => s.split(''))));
|
|
5005
5012
|
const delimiter = /^[-=<>]+(?:\/[-=^v]*)?(?=[^\S\n]*\n)|^[#:](?:(?!:\D|0)\d*:(?!0)\d*)?(?:!+[+]?)?(?=\s)/;
|
|
5006
5013
|
const head = (0, combinator_1.creation)(1, false, (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)((0, source_1.str)(/^#(?:(?!:\D|0)\d*:(?!0)\d*)?(?:!+[+]?)?(?=\s)/), (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.anyline, (0, combinator_1.some)(source_1.contentline, delimiter)]), (0, combinator_1.union)([(0, combinator_1.block)((0, combinator_1.surround)(/^[^\n]/, inline_1.medialink, /^\s*$/)), (0, combinator_1.block)((0, combinator_1.surround)(/^[^\n]/, inline_1.media, /^\s*$/)), (0, combinator_1.block)((0, combinator_1.surround)(/^[^\n]/, inline_1.shortmedia, /^\s*$/)), (0, combinator_1.open)(/^(?:\s*\n|\s)/, (0, visibility_1.visualize)((0, visibility_1.trimBlankStart)((0, combinator_1.some)(inline_1.inline))), true)])), true), ns => [(0, dom_1.html)('th', attributes(ns.shift()), (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))]), false));
|
|
5007
|
-
const data = (0, combinator_1.creation)(1, false, (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)((0, source_1.str)(/^:(?:(?!:\D|0)\d*:(?!0)\d*)?(?:!+[+]?)?(?=\s)/), (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.anyline, (0, combinator_1.some)(source_1.contentline, delimiter)]), (0, combinator_1.union)([(0, combinator_1.block)((0, combinator_1.surround)(/^[^\n]/, inline_1.medialink, /^\s*$/)), (0, combinator_1.block)((0, combinator_1.surround)(/^[^\n]/, inline_1.media, /^\s*$/)), (0, combinator_1.block)((0, combinator_1.surround)(/^[^\n]/, inline_1.shortmedia, /^\s*$/)), (0, combinator_1.open)(/^(?:\s*\n|\s)/, (0, visibility_1.visualize)((0, combinator_1.some)(inline_1.inline)), true)])), true), ns => [(0, dom_1.html)('td', attributes(ns.shift()), (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))]), false));
|
|
5014
|
+
const data = (0, combinator_1.creation)(1, false, (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)((0, source_1.str)(/^:(?:(?!:\D|0)\d*:(?!0)\d*)?(?:!+[+]?)?(?=\s)/), (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.anyline, (0, combinator_1.some)(source_1.contentline, delimiter)]), (0, combinator_1.union)([(0, combinator_1.block)((0, combinator_1.surround)(/^[^\n]/, inline_1.medialink, /^\s*$/)), (0, combinator_1.block)((0, combinator_1.surround)(/^[^\n]/, inline_1.media, /^\s*$/)), (0, combinator_1.block)((0, combinator_1.surround)(/^[^\n]/, inline_1.shortmedia, /^\s*$/)), (0, combinator_1.open)(/^(?:\s*\n|\s)/, (0, visibility_1.visualize)((0, util_1.lineable)((0, combinator_1.some)(inline_1.inline))), true)])), true), ns => [(0, dom_1.html)('td', attributes(ns.shift()), (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))]), false));
|
|
5008
5015
|
const dataline = (0, combinator_1.creation)(1, false, (0, combinator_1.line)((0, combinator_1.rewrite)(source_1.contentline, (0, combinator_1.union)([(0, combinator_1.validate)(/^!+\s/, (0, combinator_1.convert)(source => `:${source}`, data)), (0, combinator_1.convert)(source => `: ${source}`, data)]))));
|
|
5009
5016
|
function attributes(source) {
|
|
5010
5017
|
let [, rowspan = undefined, colspan = undefined, highlight = undefined, extension = undefined] = source.match(/^[#:](?:(\d+)?:(\d+)?)?(?:(!+)([+]?))?$/) ?? [];
|
|
@@ -5254,9 +5261,11 @@ const combinator_1 = __webpack_require__(2087);
|
|
|
5254
5261
|
const ulist_1 = __webpack_require__(5425);
|
|
5255
5262
|
const olist_1 = __webpack_require__(7471);
|
|
5256
5263
|
const inline_1 = __webpack_require__(1160);
|
|
5264
|
+
const util_1 = __webpack_require__(9437);
|
|
5265
|
+
const visibility_1 = __webpack_require__(7618);
|
|
5257
5266
|
const dom_1 = __webpack_require__(3252);
|
|
5258
5267
|
exports.ilist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(/^[-+*](?=[^\S\n]|\n[^\S\n]*\S)/, exports.ilist_)));
|
|
5259
|
-
exports.ilist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^[-+*](?:$|\s)/, (0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(/^[-+*](?:$|\s)/, (0, combinator_1.some)(inline_1.inline), true)), (0, combinator_1.indent)((0, combinator_1.union)([ulist_1.ulist_, olist_1.olist_, exports.ilist_]))]), ulist_1.invalid), ns => [(0, dom_1.html)('li', (0, dom_1.defrag)((0, ulist_1.fillFirstLine)(ns)))])])))), es => [(0, dom_1.html)('ul', {
|
|
5268
|
+
exports.ilist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^[-+*](?:$|\s)/, (0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(/^[-+*](?:$|\s)/, (0, combinator_1.trim)((0, visibility_1.visualize)((0, visibility_1.trimBlank)((0, util_1.lineable)((0, combinator_1.some)(inline_1.inline))))), true)), (0, combinator_1.indent)((0, combinator_1.union)([ulist_1.ulist_, olist_1.olist_, exports.ilist_]))]), ulist_1.invalid), ns => [(0, dom_1.html)('li', (0, dom_1.defrag)((0, ulist_1.fillFirstLine)(ns)))])])))), es => [(0, dom_1.html)('ul', {
|
|
5260
5269
|
class: 'invalid',
|
|
5261
5270
|
'data-invalid-syntax': 'list',
|
|
5262
5271
|
'data-invalid-type': 'syntax',
|
|
@@ -5338,7 +5347,7 @@ const combinator_1 = __webpack_require__(2087);
|
|
|
5338
5347
|
const ulist_1 = __webpack_require__(5425);
|
|
5339
5348
|
const ilist_1 = __webpack_require__(238);
|
|
5340
5349
|
const inline_1 = __webpack_require__(1160);
|
|
5341
|
-
const
|
|
5350
|
+
const util_1 = __webpack_require__(9437);
|
|
5342
5351
|
const visibility_1 = __webpack_require__(7618);
|
|
5343
5352
|
const memoize_1 = __webpack_require__(1808);
|
|
5344
5353
|
const dom_1 = __webpack_require__(3252);
|
|
@@ -5348,10 +5357,7 @@ const openers = {
|
|
|
5348
5357
|
};
|
|
5349
5358
|
exports.olist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(new RegExp([/^([0-9]+|[a-z]+|[A-Z]+)(?:-[0-9]+)*\.(?=[^\S\n]|\n[^\S\n]*\S)/.source, /^\(([0-9]+|[a-z]+)\)(?:-[0-9]+)*(?=[^\S\n]|\n[^\S\n]*\S)/.source].join('|')), exports.olist_)));
|
|
5350
5359
|
exports.olist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.union)([(0, combinator_1.match)(openers['.'], (0, memoize_1.memoize)(ms => list(type(ms[1]), '.'), ms => idx(ms[1]), [])), (0, combinator_1.match)(openers['('], (0, memoize_1.memoize)(ms => list(type(ms[1]), '('), ms => idx(ms[1]), []))])));
|
|
5351
|
-
const list = (type, form) => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(heads[form], (0, combinator_1.subsequence)([ulist_1.checkbox, (0, combinator_1.trim)((0,
|
|
5352
|
-
class: void el.classList.add('indexer'),
|
|
5353
|
-
'data-index': ''
|
|
5354
|
-
})]), (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.indent)((0, combinator_1.union)([ulist_1.ulist_, exports.olist_, ilist_1.ilist_]))]), ulist_1.invalid), ns => [(0, dom_1.html)('li', {
|
|
5360
|
+
const list = (type, form) => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(heads[form], (0, combinator_1.subsequence)([ulist_1.checkbox, (0, combinator_1.trim)((0, visibility_1.visualize)((0, util_1.lineable)((0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline]))))))]), true)), (0, combinator_1.indent)((0, combinator_1.union)([ulist_1.ulist_, exports.olist_, ilist_1.ilist_]))]), ulist_1.invalid), ns => [(0, dom_1.html)('li', {
|
|
5355
5361
|
'data-marker': ns.shift() || undefined
|
|
5356
5362
|
}, (0, dom_1.defrag)((0, ulist_1.fillFirstLine)(ns)))]), true)]))), es => [format((0, dom_1.html)('ol', es), type, form)]);
|
|
5357
5363
|
const heads = {
|
|
@@ -5482,9 +5488,10 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
5482
5488
|
exports.paragraph = void 0;
|
|
5483
5489
|
const combinator_1 = __webpack_require__(2087);
|
|
5484
5490
|
const inline_1 = __webpack_require__(1160);
|
|
5491
|
+
const util_1 = __webpack_require__(9437);
|
|
5485
5492
|
const visibility_1 = __webpack_require__(7618);
|
|
5486
5493
|
const dom_1 = __webpack_require__(3252);
|
|
5487
|
-
exports.paragraph = (0, combinator_1.block)((0, combinator_1.fmap)((0,
|
|
5494
|
+
exports.paragraph = (0, combinator_1.block)((0, combinator_1.fmap)((0, visibility_1.visualize)((0, util_1.lineable)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline])))), ns => [(0, dom_1.html)('p', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))]));
|
|
5488
5495
|
|
|
5489
5496
|
/***/ }),
|
|
5490
5497
|
|
|
@@ -5503,6 +5510,7 @@ const cite_1 = __webpack_require__(6315);
|
|
|
5503
5510
|
const quote_1 = __webpack_require__(6058);
|
|
5504
5511
|
const inline_1 = __webpack_require__(1160);
|
|
5505
5512
|
const source_1 = __webpack_require__(6743);
|
|
5513
|
+
const util_1 = __webpack_require__(9437);
|
|
5506
5514
|
const visibility_1 = __webpack_require__(7618);
|
|
5507
5515
|
const array_1 = __webpack_require__(8112);
|
|
5508
5516
|
const dom_1 = __webpack_require__(3252);
|
|
@@ -5512,7 +5520,7 @@ const dom_1 = __webpack_require__(3252);
|
|
|
5512
5520
|
対象をURLで指定すべき(引用ツリーにルートを追加する)場合はない
|
|
5513
5521
|
対象と引用は1:N(分割)、N:1(統合)のみ可能、N:N(混合)は不可能
|
|
5514
5522
|
*/
|
|
5515
|
-
exports.reply = (0, combinator_1.block)((0, combinator_1.validate)('>', (0, combinator_1.fmap)((0, combinator_1.inits)([(0, combinator_1.some)((0, combinator_1.inits)([cite_1.cite, quote_1.quote])), (0, combinator_1.some)((0, combinator_1.subsequence)([(0, combinator_1.some)(quote_1.quote), (0, combinator_1.fmap)((0, combinator_1.rewrite)((0, combinator_1.some)(source_1.anyline, quote_1.syntax), (0, visibility_1.visualize)((0, combinator_1.some)(inline_1.inline))), ns => (0, array_1.push)(ns, [(0, dom_1.html)('br')]))]))]), ns => [(0, dom_1.html)('p', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))])));
|
|
5523
|
+
exports.reply = (0, combinator_1.block)((0, combinator_1.validate)('>', (0, combinator_1.fmap)((0, combinator_1.inits)([(0, combinator_1.some)((0, combinator_1.inits)([cite_1.cite, quote_1.quote])), (0, combinator_1.some)((0, combinator_1.subsequence)([(0, combinator_1.some)(quote_1.quote), (0, combinator_1.fmap)((0, combinator_1.rewrite)((0, combinator_1.some)(source_1.anyline, quote_1.syntax), (0, visibility_1.visualize)((0, util_1.lineable)((0, combinator_1.some)(inline_1.inline)))), ns => (0, array_1.push)(ns, [(0, dom_1.html)('br')]))]))]), ns => [(0, dom_1.html)('p', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))])));
|
|
5516
5524
|
|
|
5517
5525
|
/***/ }),
|
|
5518
5526
|
|
|
@@ -5667,16 +5675,13 @@ const combinator_1 = __webpack_require__(2087);
|
|
|
5667
5675
|
const olist_1 = __webpack_require__(7471);
|
|
5668
5676
|
const ilist_1 = __webpack_require__(238);
|
|
5669
5677
|
const inline_1 = __webpack_require__(1160);
|
|
5670
|
-
const index_1 = __webpack_require__(4479);
|
|
5671
5678
|
const source_1 = __webpack_require__(6743);
|
|
5679
|
+
const util_1 = __webpack_require__(9437);
|
|
5672
5680
|
const visibility_1 = __webpack_require__(7618);
|
|
5673
5681
|
const array_1 = __webpack_require__(8112);
|
|
5674
5682
|
const dom_1 = __webpack_require__(3252);
|
|
5675
5683
|
exports.ulist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(/^-(?=[^\S\n]|\n[^\S\n]*\S)/, exports.ulist_)));
|
|
5676
|
-
exports.ulist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^-(?=$|\s)/, (0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(/^-(?:$|\s)/, (0, combinator_1.subsequence)([exports.checkbox, (0, combinator_1.trim)((0, combinator_1.
|
|
5677
|
-
class: void el.classList.add('indexer'),
|
|
5678
|
-
'data-index': ''
|
|
5679
|
-
})]), (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.indent)((0, combinator_1.union)([exports.ulist_, olist_1.olist_, ilist_1.ilist_]))]), exports.invalid), ns => [(0, dom_1.html)('li', (0, dom_1.defrag)(fillFirstLine(ns)))]), true)])))), es => [format((0, dom_1.html)('ul', es))])));
|
|
5684
|
+
exports.ulist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^-(?=$|\s)/, (0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(/^-(?:$|\s)/, (0, combinator_1.subsequence)([exports.checkbox, (0, combinator_1.trim)((0, visibility_1.visualize)((0, util_1.lineable)((0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline]))))))]), true)), (0, combinator_1.indent)((0, combinator_1.union)([exports.ulist_, olist_1.olist_, ilist_1.ilist_]))]), exports.invalid), ns => [(0, dom_1.html)('li', (0, dom_1.defrag)(fillFirstLine(ns)))]), true)])))), es => [format((0, dom_1.html)('ul', es))])));
|
|
5680
5685
|
exports.checkbox = (0, combinator_1.creation)(1, false, (0, combinator_1.focus)(/^\[[xX ]\](?=$|\s)/, ({
|
|
5681
5686
|
source
|
|
5682
5687
|
}) => [[(0, dom_1.html)('span', {
|
|
@@ -5874,7 +5879,7 @@ exports.autolink = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(/^(?:
|
|
|
5874
5879
|
// Escape unmatched hashtag-like strings.
|
|
5875
5880
|
(0, source_1.str)(new RegExp(/^#+(?:[^\p{C}\p{S}\p{P}\s]|emoji|['_])*/u.source.replace('emoji', hashtag_1.emoji), 'u')),
|
|
5876
5881
|
// Escape invalid leading characters.
|
|
5877
|
-
(0, source_1.str)(/^[0-
|
|
5882
|
+
(0, source_1.str)(/^[0-9a-z](?=>)/iu), anchor_1.anchor])), ns => ns.length === 1 ? ns : [(0, util_1.stringify)(ns)])])))));
|
|
5878
5883
|
|
|
5879
5884
|
/***/ }),
|
|
5880
5885
|
|
|
@@ -7664,8 +7669,13 @@ exports.unescsource = (0, combinator_1.creation)(1, false, ({
|
|
|
7664
7669
|
Object.defineProperty(exports, "__esModule", ({
|
|
7665
7670
|
value: true
|
|
7666
7671
|
}));
|
|
7667
|
-
exports.stringify = exports.unmarkInvalid = exports.markInvalid = void 0;
|
|
7672
|
+
exports.stringify = exports.unmarkInvalid = exports.markInvalid = exports.lineable = void 0;
|
|
7673
|
+
const combinator_1 = __webpack_require__(2087);
|
|
7668
7674
|
const dom_1 = __webpack_require__(3252);
|
|
7675
|
+
function lineable(parser) {
|
|
7676
|
+
return (0, combinator_1.convert)(source => `\r${source}`, parser);
|
|
7677
|
+
}
|
|
7678
|
+
exports.lineable = lineable;
|
|
7669
7679
|
function markInvalid(el, syntax, type, message) {
|
|
7670
7680
|
return (0, dom_1.define)(el, {
|
|
7671
7681
|
class: void el.classList.add('invalid'),
|
|
@@ -7720,8 +7730,8 @@ const memoize_1 = __webpack_require__(1808);
|
|
|
7720
7730
|
const array_1 = __webpack_require__(8112);
|
|
7721
7731
|
var blank;
|
|
7722
7732
|
(function (blank) {
|
|
7723
|
-
blank.line = new RegExp(/^(?:\\?[^\S\n]|&IHN;|<wbr[^\S\n]*>|\\$)+$/.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`), 'gm');
|
|
7724
|
-
blank.start = new RegExp(/^(?:\\?[^\S\n]|&IHN;|<wbr[^\S\n]*>)+/.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`));
|
|
7733
|
+
blank.line = new RegExp(/^(?:\\?[^\S\r\n]|&IHN;|<wbr[^\S\n]*>|\\$)+$/.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`), 'gm');
|
|
7734
|
+
blank.start = new RegExp(/^(?:\\?[^\S\r\n]|&IHN;|<wbr[^\S\n]*>)+/.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`));
|
|
7725
7735
|
})(blank || (exports.blank = blank = {}));
|
|
7726
7736
|
function visualize(parser) {
|
|
7727
7737
|
return (0, combinator_1.union)([(0, combinator_1.convert)(source => source.replace(blank.line, line => line.replace(/[\\&<]/g, '\x1B$&')), (0, combinator_1.verify)(parser, (ns, rest) => !rest && hasVisible(ns))), (0, combinator_1.some)((0, combinator_1.union)([source_1.linebreak, source_1.unescsource]))]);
|
package/index.ts
CHANGED
package/markdown.d.ts
CHANGED
|
@@ -119,13 +119,8 @@ export namespace MarkdownParser {
|
|
|
119
119
|
Parser<HTMLElement | string, Context, [
|
|
120
120
|
InlineParser,
|
|
121
121
|
Parser<HTMLElement | string, Context, [
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
]>,
|
|
125
|
-
Parser<HTMLElement | string, Context, [
|
|
126
|
-
InlineParser.ExtensionParser.IndexerParser,
|
|
127
|
-
InlineParser,
|
|
128
|
-
]>,
|
|
122
|
+
InlineParser.ExtensionParser.IndexerParser,
|
|
123
|
+
InlineParser,
|
|
129
124
|
]>,
|
|
130
125
|
]>,
|
|
131
126
|
Parser<HTMLUListElement | HTMLOListElement, Context, [
|
|
@@ -159,13 +154,8 @@ export namespace MarkdownParser {
|
|
|
159
154
|
Parser<HTMLElement | string, Context, [
|
|
160
155
|
InlineParser,
|
|
161
156
|
Parser<HTMLElement | string, Context, [
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
]>,
|
|
165
|
-
Parser<HTMLElement | string, Context, [
|
|
166
|
-
InlineParser.ExtensionParser.IndexerParser,
|
|
167
|
-
InlineParser,
|
|
168
|
-
]>,
|
|
157
|
+
InlineParser.ExtensionParser.IndexerParser,
|
|
158
|
+
InlineParser,
|
|
169
159
|
]>,
|
|
170
160
|
]>,
|
|
171
161
|
Parser<HTMLUListElement | HTMLOListElement, Context, [
|
package/package.json
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Parser, Ctx, Context, check } from '../../data/parser';
|
|
2
|
+
import { max } from 'spica/alias';
|
|
2
3
|
|
|
4
|
+
// 設計上キャッシュが汚染されるが運用で回避可能
|
|
5
|
+
// 変換の前または後のみキャッシュされるなら問題ない
|
|
3
6
|
export function convert<P extends Parser<unknown>>(conv: (source: string, context: Context<P>) => string, parser: P, empty?: boolean): P;
|
|
4
7
|
export function convert<T>(conv: (source: string, context: Ctx) => string, parser: Parser<T>, empty = false): Parser<T> {
|
|
5
8
|
assert(parser);
|
|
@@ -7,11 +10,13 @@ export function convert<T>(conv: (source: string, context: Ctx) => string, parse
|
|
|
7
10
|
if (source === '') return;
|
|
8
11
|
const src = conv(source, context);
|
|
9
12
|
if (src === '') return empty ? [[], ''] : undefined;
|
|
13
|
+
const offset = max(source.length - src.length, 0);
|
|
14
|
+
assert(offset >= 0);
|
|
10
15
|
context.offset ??= 0;
|
|
11
|
-
context.offset +=
|
|
16
|
+
context.offset += offset;
|
|
12
17
|
const result = parser({ source: src, context });
|
|
13
18
|
assert(check(src, result));
|
|
14
|
-
context.offset -=
|
|
19
|
+
context.offset -= offset;
|
|
15
20
|
return result;
|
|
16
21
|
};
|
|
17
22
|
}
|
|
@@ -20,10 +20,12 @@ export function indent<T>(opener: RegExp | Parser<T>, parser?: Parser<T> | boole
|
|
|
20
20
|
([indent]) => indent.length * 2 + +(indent[0] === ' '), {})), separation),
|
|
21
21
|
(lines, rest, context) => {
|
|
22
22
|
assert(parser = parser as Parser<T>);
|
|
23
|
+
const offset = rest.length;
|
|
24
|
+
assert(offset >= 0);
|
|
23
25
|
context.offset ??= 0;
|
|
24
|
-
context.offset +=
|
|
26
|
+
context.offset += offset;
|
|
25
27
|
const result = parser({ source: trimBlockEnd(lines.join('')), context });
|
|
26
|
-
context.offset -=
|
|
28
|
+
context.offset -= offset;
|
|
27
29
|
return result && exec(result) === ''
|
|
28
30
|
? [eval(result), rest]
|
|
29
31
|
: undefined;
|
|
@@ -12,11 +12,13 @@ export function focus<T>(scope: string | RegExp, parser: Parser<T>): Parser<T> {
|
|
|
12
12
|
const src = match(source);
|
|
13
13
|
assert(source.startsWith(src));
|
|
14
14
|
if (src === '') return;
|
|
15
|
+
const offset = source.length - src.length;
|
|
16
|
+
assert(offset >= 0);
|
|
15
17
|
context.offset ??= 0;
|
|
16
|
-
context.offset +=
|
|
18
|
+
context.offset += offset;
|
|
17
19
|
const result = parser({ source: src, context });
|
|
18
20
|
assert(check(src, result));
|
|
19
|
-
context.offset -=
|
|
21
|
+
context.offset -= offset;
|
|
20
22
|
if (result === undefined) return;
|
|
21
23
|
assert(exec(result).length < src.length);
|
|
22
24
|
return exec(result).length < src.length
|
|
@@ -41,11 +43,13 @@ export function rewrite<T>(scope: Parser<unknown>, parser: Parser<T>): Parser<T>
|
|
|
41
43
|
const src = source.slice(0, source.length - exec(res1).length);
|
|
42
44
|
assert(src !== '');
|
|
43
45
|
assert(source.startsWith(src));
|
|
46
|
+
const offset = source.length - src.length;
|
|
47
|
+
assert(offset >= 0);
|
|
44
48
|
context.offset ??= 0;
|
|
45
|
-
context.offset +=
|
|
49
|
+
context.offset += offset;
|
|
46
50
|
const res2 = parser({ source: src, context });
|
|
47
51
|
assert(check(src, res2));
|
|
48
|
-
context.offset -=
|
|
52
|
+
context.offset -= offset;
|
|
49
53
|
if (res2 === undefined) return;
|
|
50
54
|
assert(exec(res2) === '');
|
|
51
55
|
return exec(res2).length < src.length
|
|
@@ -38,10 +38,10 @@ export class Memo {
|
|
|
38
38
|
}
|
|
39
39
|
public resize(position: number): void {
|
|
40
40
|
const memory = this.memory;
|
|
41
|
-
for (let
|
|
41
|
+
for (let i = memory.length; i > position; --i) {
|
|
42
42
|
this.count -= +memory.pop()!;
|
|
43
43
|
}
|
|
44
|
-
//console.log('resize', position);
|
|
44
|
+
//console.log('resize', position + 1);
|
|
45
45
|
}
|
|
46
46
|
public clear(): void {
|
|
47
47
|
this.memory = [];
|
|
@@ -3,6 +3,7 @@ import { union, inits, some, creation, state, block, line, validate, rewrite, op
|
|
|
3
3
|
import { inline, indexee, indexer } from '../inline';
|
|
4
4
|
import { anyline } from '../source';
|
|
5
5
|
import { State } from '../context';
|
|
6
|
+
import { lineable } from '../util';
|
|
6
7
|
import { visualize, trimBlankStart, trimNodeEnd } from '../visibility';
|
|
7
8
|
import { push } from 'spica/array';
|
|
8
9
|
import { html, defrag } from 'typed-dom/dom';
|
|
@@ -26,7 +27,7 @@ const desc: DListParser.DescriptionParser = creation(1, false, block(fmap(open(
|
|
|
26
27
|
/^:[^\S\n]+(?=\S)|/,
|
|
27
28
|
rewrite(
|
|
28
29
|
some(anyline, /^[~:][^\S\n]+\S/),
|
|
29
|
-
visualize(some(union([inline])))),
|
|
30
|
+
visualize(lineable(some(union([inline]))))),
|
|
30
31
|
true),
|
|
31
32
|
ns => [html('dd', trimNodeEnd(defrag(ns)))]),
|
|
32
33
|
false));
|
|
@@ -4,6 +4,7 @@ import { Tree, eval } from '../../../combinator/data/parser';
|
|
|
4
4
|
import { union, subsequence, inits, some, creation, block, line, validate, fence, rewrite, surround, open, clear, convert, dup, lazy, fmap } from '../../../combinator';
|
|
5
5
|
import { inline, medialink, media, shortmedia } from '../../inline';
|
|
6
6
|
import { str, anyline, emptyline, contentline } from '../../source';
|
|
7
|
+
import { lineable } from '../../util';
|
|
7
8
|
import { visualize, trimBlankStart, trimNodeEnd } from '../../visibility';
|
|
8
9
|
import { unshift, splice } from 'spica/array';
|
|
9
10
|
import { html, define, defrag } from 'typed-dom/dom';
|
|
@@ -105,7 +106,7 @@ const data: CellParser.DataParser = creation(1, false, block(fmap(open(
|
|
|
105
106
|
block(surround(/^[^\n]/, medialink, /^\s*$/)),
|
|
106
107
|
block(surround(/^[^\n]/, media, /^\s*$/)),
|
|
107
108
|
block(surround(/^[^\n]/, shortmedia, /^\s*$/)),
|
|
108
|
-
open(/^(?:\s*\n|\s)/, visualize(some(inline)), true),
|
|
109
|
+
open(/^(?:\s*\n|\s)/, visualize(lineable(some(inline))), true),
|
|
109
110
|
])),
|
|
110
111
|
true),
|
|
111
112
|
ns => [html('td', attributes(ns.shift()! as string), trimNodeEnd(defrag(ns)))]),
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { IListParser } from '../block';
|
|
2
|
-
import { union, inits, some, creation, block, line, validate, indent, open, fallback, lazy, fmap } from '../../combinator';
|
|
2
|
+
import { union, inits, some, creation, block, line, validate, indent, open, trim, fallback, lazy, fmap } from '../../combinator';
|
|
3
3
|
import { ulist_, invalid, fillFirstLine } from './ulist';
|
|
4
4
|
import { olist_ } from './olist';
|
|
5
5
|
import { inline } from '../inline';
|
|
6
|
+
import { lineable } from '../util';
|
|
7
|
+
import { visualize, trimBlank } from '../visibility';
|
|
6
8
|
import { html, defrag } from 'typed-dom/dom';
|
|
7
9
|
|
|
8
10
|
export const ilist: IListParser = lazy(() => block(validate(
|
|
@@ -14,7 +16,7 @@ export const ilist_: IListParser = lazy(() => block(fmap(validate(
|
|
|
14
16
|
some(creation(1, false, union([
|
|
15
17
|
fmap(fallback(
|
|
16
18
|
inits([
|
|
17
|
-
line(open(/^[-+*](?:$|\s)/, some(inline), true)),
|
|
19
|
+
line(open(/^[-+*](?:$|\s)/, trim(visualize(trimBlank(lineable(some(inline))))), true)),
|
|
18
20
|
indent(union([ulist_, olist_, ilist_])),
|
|
19
21
|
]),
|
|
20
22
|
invalid),
|
|
@@ -81,6 +81,8 @@ describe('Unit: parser/block/olist', () => {
|
|
|
81
81
|
assert.deepStrictEqual(inspect(parser('0. 1\n 0. 2\n 0. 3')), [['<ol><li id="index::1">1<ol><li id="index::2">2</li><li id="index::3">3</li></ol></li></ol>'], '']);
|
|
82
82
|
assert.deepStrictEqual(inspect(parser('0. 1\n 0. 2\n 0. 3')), [['<ol><li id="index::1">1<ol><li id="index::2">2<ol><li id="index::3">3</li></ol></li></ol></li></ol>'], '']);
|
|
83
83
|
assert.deepStrictEqual(inspect(parser('0. 1\n 0. 2\n 0. 3')), [['<ol><li id="index::1">1<ol><li id="index::2">2</li></ol></li><li id="index::0._3"><span class="invalid"> 0. 3</span></li></ol>'], '']);
|
|
84
|
+
assert.deepStrictEqual(inspect(parser('0. a [#b]')), [['<ol><li id="index::a_b">a <a class="index" href="#index::b">b</a></li></ol>'], '']);
|
|
85
|
+
assert.deepStrictEqual(inspect(parser('0. http://host\\')), [['<ol><li id="index::http://host\\"><a class="url" href="http://host\\" target="_blank">http://host\\</a></li></ol>'], '']);
|
|
84
86
|
assert.deepStrictEqual(inspect(parser('0. !http://host')), [['<ol><li id="index::!http://host">!<a class="url" href="http://host" target="_blank">http://host</a></li></ol>'], '']);
|
|
85
87
|
});
|
|
86
88
|
|
|
@@ -127,10 +129,10 @@ describe('Unit: parser/block/olist', () => {
|
|
|
127
129
|
});
|
|
128
130
|
|
|
129
131
|
it('indexer', () => {
|
|
130
|
-
assert.deepStrictEqual(inspect(parser('1. [|a]')), [['<ol><li id="index::a"
|
|
132
|
+
assert.deepStrictEqual(inspect(parser('1. [|a]')), [['<ol><li id="index::[|a]">[|a]</li></ol>'], '']);
|
|
131
133
|
assert.deepStrictEqual(inspect(parser('1. a [|]')), [['<ol><li>a<span class="indexer" data-index=""></span></li></ol>'], '']);
|
|
132
134
|
assert.deepStrictEqual(inspect(parser('1. a [|b]')), [['<ol><li id="index::b">a<span class="indexer" data-index="b"></span></li></ol>'], '']);
|
|
133
|
-
assert.deepStrictEqual(inspect(parser('1. [ ] [|a]')), [['<ol class="checklist"><li id="index::a"><span class="checkbox">☐</span
|
|
135
|
+
assert.deepStrictEqual(inspect(parser('1. [ ] [|a]')), [['<ol class="checklist"><li id="index::[|a]"><span class="checkbox">☐</span>[|a]</li></ol>'], '']);
|
|
134
136
|
assert.deepStrictEqual(inspect(parser('1. [ ] a [|b]')), [['<ol class="checklist"><li id="index::b"><span class="checkbox">☐</span>a<span class="indexer" data-index="b"></span></li></ol>'], '']);
|
|
135
137
|
assert.deepStrictEqual(inspect(parser('1. a [|]\n 1. c [|d]')), [['<ol><li>a<span class="indexer" data-index=""></span><ol><li id="index::d">c<span class="indexer" data-index="d"></span></li></ol></li></ol>'], '']);
|
|
136
138
|
assert.deepStrictEqual(inspect(parser('1. a [|b]\n 1. c [|d]')), [['<ol><li id="index::b">a<span class="indexer" data-index="b"></span><ol><li id="index::d">c<span class="indexer" data-index="d"></span></li></ol></li></ol>'], '']);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { OListParser } from '../block';
|
|
2
|
-
import { union, inits, subsequence, some, creation, block, line, validate, indent, focus, open,
|
|
2
|
+
import { union, inits, subsequence, some, creation, block, line, validate, indent, focus, open, match, trim, fallback, lazy, fmap } from '../../combinator';
|
|
3
3
|
import { ulist_, checkbox, invalid, fillFirstLine } from './ulist';
|
|
4
4
|
import { ilist_ } from './ilist';
|
|
5
5
|
import { inline, indexee, indexer } from '../inline';
|
|
6
|
-
import {
|
|
6
|
+
import { lineable } from '../util';
|
|
7
7
|
import { visualize, trimBlank } from '../visibility';
|
|
8
8
|
import { memoize } from 'spica/memoize';
|
|
9
9
|
import { html, define, defrag } from 'typed-dom/dom';
|
|
@@ -33,12 +33,9 @@ const list = (type: string, form: string): OListParser.ListParser => fmap(
|
|
|
33
33
|
some(creation(1, false, union([
|
|
34
34
|
indexee(fmap(fallback(
|
|
35
35
|
inits([
|
|
36
|
-
line(open(heads[form], subsequence([
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
]),
|
|
40
|
-
visualize(trimBlank(some(union([indexer, inline])))),
|
|
41
|
-
]))]), true)),
|
|
36
|
+
line(open(heads[form], subsequence([
|
|
37
|
+
checkbox,
|
|
38
|
+
trim(visualize(lineable(trimBlank(some(union([indexer, inline]))))))]), true)),
|
|
42
39
|
indent(union([ulist_, olist_, ilist_])),
|
|
43
40
|
]),
|
|
44
41
|
invalid),
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ParagraphParser } from '../block';
|
|
2
|
-
import { union, some, block,
|
|
2
|
+
import { union, some, block, fmap } from '../../combinator';
|
|
3
3
|
import { inline } from '../inline';
|
|
4
|
+
import { lineable } from '../util';
|
|
4
5
|
import { visualize, trimNodeEnd } from '../visibility';
|
|
5
6
|
import { html, defrag } from 'typed-dom/dom';
|
|
6
7
|
|
|
7
8
|
export const paragraph: ParagraphParser = block(fmap(
|
|
8
|
-
|
|
9
|
-
visualize(some(union([inline])))),
|
|
9
|
+
visualize(lineable(some(union([inline])))),
|
|
10
10
|
ns => [html('p', trimNodeEnd(defrag(ns)))]));
|
|
@@ -4,6 +4,7 @@ import { cite } from './reply/cite';
|
|
|
4
4
|
import { quote, syntax as delimiter } from './reply/quote';
|
|
5
5
|
import { inline } from '../inline';
|
|
6
6
|
import { anyline } from '../source';
|
|
7
|
+
import { lineable } from '../util';
|
|
7
8
|
import { visualize, trimNodeEnd } from '../visibility';
|
|
8
9
|
import { push } from 'spica/array';
|
|
9
10
|
import { html, defrag } from 'typed-dom/dom';
|
|
@@ -25,7 +26,7 @@ export const reply: ReplyParser = block(validate('>', fmap(
|
|
|
25
26
|
some(quote),
|
|
26
27
|
fmap(rewrite(
|
|
27
28
|
some(anyline, delimiter),
|
|
28
|
-
visualize(some(inline))),
|
|
29
|
+
visualize(lineable(some(inline)))),
|
|
29
30
|
ns => push(ns, [html('br')])),
|
|
30
31
|
])),
|
|
31
32
|
]),
|
|
@@ -56,6 +56,8 @@ describe('Unit: parser/block/ulist', () => {
|
|
|
56
56
|
assert.deepStrictEqual(inspect(parser('- 1\n 0.')), [['<ul><li id="index::1">1<ol><li></li></ol></li></ul>'], '']);
|
|
57
57
|
assert.deepStrictEqual(inspect(parser('- 1\n 0. ')), [['<ul><li id="index::1">1<ol><li></li></ol></li></ul>'], '']);
|
|
58
58
|
assert.deepStrictEqual(inspect(parser('- 1\n 0. 2')), [['<ul><li id="index::1">1<ol><li id="index::2">2</li></ol></li></ul>'], '']);
|
|
59
|
+
assert.deepStrictEqual(inspect(parser('- a [#b]')), [['<ul><li id="index::a_b">a <a class="index" href="#index::b">b</a></li></ul>'], '']);
|
|
60
|
+
assert.deepStrictEqual(inspect(parser('- http://host\\')), [['<ul><li id="index::http://host\\"><a class="url" href="http://host\\" target="_blank">http://host\\</a></li></ul>'], '']);
|
|
59
61
|
assert.deepStrictEqual(inspect(parser('- !http://host')), [['<ul><li id="index::!http://host">!<a class="url" href="http://host" target="_blank">http://host</a></li></ul>'], '']);
|
|
60
62
|
});
|
|
61
63
|
|
|
@@ -67,10 +69,10 @@ describe('Unit: parser/block/ulist', () => {
|
|
|
67
69
|
});
|
|
68
70
|
|
|
69
71
|
it('indexer', () => {
|
|
70
|
-
assert.deepStrictEqual(inspect(parser('- [|a]')), [['<ul><li id="index::a"
|
|
72
|
+
assert.deepStrictEqual(inspect(parser('- [|a]')), [['<ul><li id="index::[|a]">[|a]</li></ul>'], '']);
|
|
71
73
|
assert.deepStrictEqual(inspect(parser('- a [|]')), [['<ul><li>a<span class="indexer" data-index=""></span></li></ul>'], '']);
|
|
72
74
|
assert.deepStrictEqual(inspect(parser('- a [|b]')), [['<ul><li id="index::b">a<span class="indexer" data-index="b"></span></li></ul>'], '']);
|
|
73
|
-
assert.deepStrictEqual(inspect(parser('- [ ] [|a]')), [['<ul class="checklist"><li id="index::a"><span class="checkbox">☐</span
|
|
75
|
+
assert.deepStrictEqual(inspect(parser('- [ ] [|a]')), [['<ul class="checklist"><li id="index::[|a]"><span class="checkbox">☐</span>[|a]</li></ul>'], '']);
|
|
74
76
|
assert.deepStrictEqual(inspect(parser('- [ ] a [|b]')), [['<ul class="checklist"><li id="index::b"><span class="checkbox">☐</span>a<span class="indexer" data-index="b"></span></li></ul>'], '']);
|
|
75
77
|
assert.deepStrictEqual(inspect(parser('- a [|]\n - c [|d]')), [['<ul><li>a<span class="indexer" data-index=""></span><ul><li id="index::d">c<span class="indexer" data-index="d"></span></li></ul></li></ul>'], '']);
|
|
76
78
|
assert.deepStrictEqual(inspect(parser('- a [|b]\n - c [|d]')), [['<ul><li id="index::b">a<span class="indexer" data-index="b"></span><ul><li id="index::d">c<span class="indexer" data-index="d"></span></li></ul></li></ul>'], '']);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { UListParser } from '../block';
|
|
2
2
|
import { Parser } from '../../combinator/data/parser';
|
|
3
|
-
import { union, inits, subsequence, some, creation, block, line, validate, indent, focus, rewrite, open,
|
|
3
|
+
import { union, inits, subsequence, some, creation, block, line, validate, indent, focus, rewrite, open, trim, fallback, lazy, fmap } from '../../combinator';
|
|
4
4
|
import { olist_ } from './olist';
|
|
5
5
|
import { ilist_ } from './ilist';
|
|
6
6
|
import { inline, indexer, indexee } from '../inline';
|
|
7
|
-
import { index } from '../inline/extension/index';
|
|
8
7
|
import { contentline } from '../source';
|
|
8
|
+
import { lineable } from '../util';
|
|
9
9
|
import { visualize, trimBlank } from '../visibility';
|
|
10
10
|
import { unshift } from 'spica/array';
|
|
11
|
-
import { html,
|
|
11
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
12
12
|
|
|
13
13
|
export const ulist: UListParser = lazy(() => block(validate(
|
|
14
14
|
/^-(?=[^\S\n]|\n[^\S\n]*\S)/,
|
|
@@ -19,12 +19,10 @@ export const ulist_: UListParser = lazy(() => block(fmap(validate(
|
|
|
19
19
|
some(creation(1, false, union([
|
|
20
20
|
indexee(fmap(fallback(
|
|
21
21
|
inits([
|
|
22
|
-
line(open(/^-(?:$|\s)/, subsequence([
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
visualize(trimBlank(some(union([indexer, inline])))),
|
|
27
|
-
]))]), true)),
|
|
22
|
+
line(open(/^-(?:$|\s)/, subsequence([
|
|
23
|
+
checkbox,
|
|
24
|
+
trim(visualize(lineable(trimBlank(some(union([indexer, inline])))))),
|
|
25
|
+
]), true)),
|
|
28
26
|
indent(union([ulist_, olist_, ilist_])),
|
|
29
27
|
]),
|
|
30
28
|
invalid),
|
|
@@ -33,7 +33,7 @@ export const autolink: AutolinkParser = lazy(() =>
|
|
|
33
33
|
// Escape unmatched hashtag-like strings.
|
|
34
34
|
str(new RegExp(/^#+(?:[^\p{C}\p{S}\p{P}\s]|emoji|['_])*/u.source.replace('emoji', emoji), 'u')),
|
|
35
35
|
// Escape invalid leading characters.
|
|
36
|
-
str(/^[0-
|
|
36
|
+
str(/^[0-9a-z](?=>)/iu),
|
|
37
37
|
anchor,
|
|
38
38
|
])),
|
|
39
39
|
ns => ns.length === 1 ? ns : [stringify(ns)]),
|
package/src/parser/util.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
import { Parser } from '../combinator/data/parser';
|
|
2
|
+
import { convert } from '../combinator';
|
|
1
3
|
import { define } from 'typed-dom/dom';
|
|
2
4
|
|
|
5
|
+
export function lineable<P extends Parser<HTMLElement | string>>(parser: P): P;
|
|
6
|
+
export function lineable<T extends HTMLElement | string>(parser: Parser<T>): Parser<T> {
|
|
7
|
+
return convert(source => `\r${source}`, parser);
|
|
8
|
+
}
|
|
9
|
+
|
|
3
10
|
export function markInvalid<T extends Element>(
|
|
4
11
|
el: T,
|
|
5
12
|
syntax: string,
|
package/src/parser/visibility.ts
CHANGED
|
@@ -9,11 +9,11 @@ import { push } from 'spica/array';
|
|
|
9
9
|
|
|
10
10
|
export namespace blank {
|
|
11
11
|
export const line = new RegExp(
|
|
12
|
-
/^(?:\\?[^\S\n]|&IHN;|<wbr[^\S\n]*>|\\$)+$/.source
|
|
12
|
+
/^(?:\\?[^\S\r\n]|&IHN;|<wbr[^\S\n]*>|\\$)+$/.source
|
|
13
13
|
.replace('IHN', `(?:${invisibleHTMLEntityNames.join('|')})`),
|
|
14
14
|
'gm');
|
|
15
15
|
export const start = new RegExp(
|
|
16
|
-
/^(?:\\?[^\S\n]|&IHN;|<wbr[^\S\n]*>)+/.source
|
|
16
|
+
/^(?:\\?[^\S\r\n]|&IHN;|<wbr[^\S\n]*>)+/.source
|
|
17
17
|
.replace('IHN', `(?:${invisibleHTMLEntityNames.join('|')})`));
|
|
18
18
|
}
|
|
19
19
|
|