securemark 0.260.1 → 0.260.2
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 +33 -36
- package/package.json +1 -1
- package/src/combinator/data/parser/context.ts +6 -4
- package/src/parser/block/blockquote.ts +3 -3
- package/src/parser/block/dlist.ts +2 -2
- package/src/parser/block/extension/table.ts +3 -3
- package/src/parser/block/ilist.ts +1 -1
- package/src/parser/block/olist.ts +1 -1
- package/src/parser/block/reply/cite.ts +1 -1
- package/src/parser/block/reply/quote.ts +1 -1
- package/src/parser/block/sidefence.ts +1 -1
- package/src/parser/block/table.ts +4 -4
- package/src/parser/block/ulist.ts +2 -2
- package/src/parser/block.ts +1 -1
- package/src/parser/inline/ruby.ts +1 -1
- package/src/parser/source/escapable.ts +1 -1
- package/src/parser/source/str.ts +4 -4
- package/src/parser/source/text.ts +2 -3
- package/src/parser/source/unescapable.ts +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.260.
|
|
1
|
+
/*! securemark v0.260.2 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
|
|
2
2
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
3
3
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
4
4
|
module.exports = factory(require("DOMPurify"), require("Prism"));
|
|
@@ -2979,8 +2979,9 @@ function syntax(syntax, prec, cost, state, parser) {
|
|
|
2979
2979
|
|
|
2980
2980
|
exports.syntax = syntax;
|
|
2981
2981
|
|
|
2982
|
-
function creation(cost, parser) {
|
|
2983
|
-
if (typeof cost === 'function') return creation(1, cost);
|
|
2982
|
+
function creation(cost, recursion, parser) {
|
|
2983
|
+
if (typeof cost === 'function') return creation(1, true, cost);
|
|
2984
|
+
if (typeof recursion === 'function') return creation(cost, true, recursion);
|
|
2984
2985
|
return ({
|
|
2985
2986
|
source,
|
|
2986
2987
|
context
|
|
@@ -2991,12 +2992,12 @@ function creation(cost, parser) {
|
|
|
2991
2992
|
};
|
|
2992
2993
|
if (resources.clock <= 0) throw new Error('Too many creations');
|
|
2993
2994
|
if (resources.recursion <= 0) throw new Error('Too much recursion');
|
|
2994
|
-
--resources.recursion;
|
|
2995
|
+
recursion && --resources.recursion;
|
|
2995
2996
|
const result = parser({
|
|
2996
2997
|
source,
|
|
2997
2998
|
context
|
|
2998
2999
|
});
|
|
2999
|
-
++resources.recursion;
|
|
3000
|
+
recursion && ++resources.recursion;
|
|
3000
3001
|
|
|
3001
3002
|
if (result) {
|
|
3002
3003
|
resources.clock -= cost;
|
|
@@ -4115,7 +4116,7 @@ const dom_1 = __webpack_require__(3252);
|
|
|
4115
4116
|
|
|
4116
4117
|
const random_1 = __webpack_require__(7325);
|
|
4117
4118
|
|
|
4118
|
-
exports.block = (0, combinator_1.creation)(error((0, combinator_1.reset)({
|
|
4119
|
+
exports.block = (0, combinator_1.creation)(1, false, error((0, combinator_1.reset)({
|
|
4119
4120
|
resources: {
|
|
4120
4121
|
clock: 50 * 1000,
|
|
4121
4122
|
recursion: 20
|
|
@@ -4171,8 +4172,8 @@ const indent = (0, combinator_1.block)((0, combinator_1.open)(opener, (0, combin
|
|
|
4171
4172
|
|
|
4172
4173
|
const unindent = source => source.replace(/(^|\n)>(?:[^\S\n]|(?=>*(?:$|\s)))|\n$/g, '$1');
|
|
4173
4174
|
|
|
4174
|
-
const source = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)((0, combinator_1.union)([(0, combinator_1.rewrite)(indent, (0, combinator_1.convert)(unindent, source)), (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, (0, combinator_1.fmap)((0, combinator_1.some)(autolink_1.autolink), ns => [(0, dom_1.html)('pre', (0, dom_1.defrag)(ns))])))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
|
|
4175
|
-
const markdown = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)((0, combinator_1.union)([(0, combinator_1.rewrite)(indent, (0, combinator_1.convert)(unindent, markdown)), (0, combinator_1.creation)(99, (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, ({
|
|
4175
|
+
const source = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, combinator_1.rewrite)(indent, (0, combinator_1.convert)(unindent, source)), (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, (0, combinator_1.fmap)((0, combinator_1.some)(autolink_1.autolink), ns => [(0, dom_1.html)('pre', (0, dom_1.defrag)(ns))])))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
|
|
4176
|
+
const markdown = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, combinator_1.rewrite)(indent, (0, combinator_1.convert)(unindent, markdown)), (0, combinator_1.creation)(99, false, (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, ({
|
|
4176
4177
|
source,
|
|
4177
4178
|
context
|
|
4178
4179
|
}) => {
|
|
@@ -4303,8 +4304,8 @@ exports.dlist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, locale_
|
|
|
4303
4304
|
| 4
|
|
4304
4305
|
/* State.media */
|
|
4305
4306
|
, (0, combinator_1.some)(term)), (0, combinator_1.some)(desc)]))), es => [(0, dom_1.html)('dl', fillTrailingDescription(es))]))));
|
|
4306
|
-
const term = (0, combinator_1.creation)((0, combinator_1.line)((0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.open)(/^~[^\S\n]+(?=\S)/, (0, visibility_1.visualize)((0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))), true), ns => [(0, dom_1.html)('dt', (0, dom_1.defrag)(ns))]))));
|
|
4307
|
-
const desc = (0, combinator_1.creation)((0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)(/^:[^\S\n]+(?=\S)|/, (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.anyline, /^[~:][^\S\n]+\S/), (0, visibility_1.visualize)((0, combinator_1.trimEnd)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))))), true), ns => [(0, dom_1.html)('dd', (0, dom_1.defrag)(ns))]), false));
|
|
4307
|
+
const term = (0, combinator_1.creation)(1, false, (0, combinator_1.line)((0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.open)(/^~[^\S\n]+(?=\S)/, (0, visibility_1.visualize)((0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))), true), ns => [(0, dom_1.html)('dt', (0, dom_1.defrag)(ns))]))));
|
|
4308
|
+
const desc = (0, combinator_1.creation)(1, false, (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)(/^:[^\S\n]+(?=\S)|/, (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.anyline, /^[~:][^\S\n]+\S/), (0, visibility_1.visualize)((0, combinator_1.trimEnd)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))))), true), ns => [(0, dom_1.html)('dd', (0, dom_1.defrag)(ns))]), false));
|
|
4308
4309
|
|
|
4309
4310
|
function fillTrailingDescription(es) {
|
|
4310
4311
|
return es.length > 0 && es[es.length - 1].tagName === 'DT' ? (0, array_1.push)(es, [(0, dom_1.html)('dd')]) : es;
|
|
@@ -4890,9 +4891,9 @@ const row = (0, combinator_1.lazy)(() => (0, combinator_1.dup)((0, combinator_1.
|
|
|
4890
4891
|
const alignment = /^[-=<>]+(?:\/[-=^v]*)?(?=[^\S\n]*\n)/;
|
|
4891
4892
|
const align = (0, combinator_1.line)((0, combinator_1.fmap)((0, combinator_1.union)([(0, source_1.str)(alignment)]), ([s]) => s.split('/').map(s => s.split(''))));
|
|
4892
4893
|
const delimiter = /^[-=<>]+(?:\/[-=^v]*)?(?=[^\S\n]*\n)|^[#:](?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=\s)/;
|
|
4893
|
-
const head = (0, combinator_1.creation)((0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)((0, source_1.str)(/^#(?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=\s)/), (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.anyline, (0, combinator_1.some)(source_1.contentline, delimiter)]), (0, combinator_1.trim)((0, visibility_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))))), true), ns => [(0, dom_1.html)('th', attributes(ns.shift()), (0, dom_1.defrag)(ns))]), false));
|
|
4894
|
-
const data = (0, combinator_1.creation)((0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)((0, source_1.str)(/^:(?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=\s)/), (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.anyline, (0, combinator_1.some)(source_1.contentline, delimiter)]), (0, combinator_1.trim)((0, visibility_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))))), true), ns => [(0, dom_1.html)('td', attributes(ns.shift()), (0, dom_1.defrag)(ns))]), false));
|
|
4895
|
-
const dataline = (0, combinator_1.creation)((0, combinator_1.line)((0, combinator_1.rewrite)(source_1.contentline, (0, combinator_1.union)([(0, combinator_1.validate)(/^!+\s/, (0, combinator_1.convert)(source => `:${source}`, data)), (0, combinator_1.convert)(source => `: ${source}`, data)]))));
|
|
4894
|
+
const head = (0, combinator_1.creation)(1, false, (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)((0, source_1.str)(/^#(?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=\s)/), (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.anyline, (0, combinator_1.some)(source_1.contentline, delimiter)]), (0, combinator_1.trim)((0, visibility_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))))), true), ns => [(0, dom_1.html)('th', attributes(ns.shift()), (0, dom_1.defrag)(ns))]), false));
|
|
4895
|
+
const data = (0, combinator_1.creation)(1, false, (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)((0, source_1.str)(/^:(?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=\s)/), (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.anyline, (0, combinator_1.some)(source_1.contentline, delimiter)]), (0, combinator_1.trim)((0, visibility_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))))), true), ns => [(0, dom_1.html)('td', attributes(ns.shift()), (0, dom_1.defrag)(ns))]), false));
|
|
4896
|
+
const dataline = (0, combinator_1.creation)(1, false, (0, combinator_1.line)((0, combinator_1.rewrite)(source_1.contentline, (0, combinator_1.union)([(0, combinator_1.validate)(/^!+\s/, (0, combinator_1.convert)(source => `:${source}`, data)), (0, combinator_1.convert)(source => `: ${source}`, data)]))));
|
|
4896
4897
|
|
|
4897
4898
|
function attributes(source) {
|
|
4898
4899
|
let [, rowspan = global_1.undefined, colspan = global_1.undefined, highlight = global_1.undefined] = source.match(/^.(?:(\d+)?:(\d+)?)?(!+)?$/) ?? [];
|
|
@@ -5195,7 +5196,7 @@ const dom_1 = __webpack_require__(3252);
|
|
|
5195
5196
|
exports.ilist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(/^[-+*](?=[^\S\n]|\n[^\S\n]*\S)/, (0, combinator_1.state)(4
|
|
5196
5197
|
/* State.media */
|
|
5197
5198
|
, exports.ilist_))));
|
|
5198
|
-
exports.ilist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^[-+*](?:$|\s)/, (0, combinator_1.some)((0, combinator_1.creation)((0, combinator_1.union)([(0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(/^[-+*](?:$|\s)/, (0, combinator_1.some)(inline_1.inline), true)), (0, combinator_1.indent)((0, combinator_1.union)([ulist_1.ulist_, olist_1.olist_, exports.ilist_]))]), olist_1.invalid), ns => [(0, dom_1.html)('li', (0, dom_1.defrag)((0, ulist_1.fillFirstLine)(ns)))])])))), es => [(0, dom_1.html)('ul', {
|
|
5199
|
+
exports.ilist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^[-+*](?:$|\s)/, (0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(/^[-+*](?:$|\s)/, (0, combinator_1.some)(inline_1.inline), true)), (0, combinator_1.indent)((0, combinator_1.union)([ulist_1.ulist_, olist_1.olist_, exports.ilist_]))]), olist_1.invalid), ns => [(0, dom_1.html)('li', (0, dom_1.defrag)((0, ulist_1.fillFirstLine)(ns)))])])))), es => [(0, dom_1.html)('ul', {
|
|
5199
5200
|
class: 'invalid',
|
|
5200
5201
|
'data-invalid-syntax': 'list',
|
|
5201
5202
|
'data-invalid-type': 'syntax',
|
|
@@ -5284,7 +5285,7 @@ exports.olist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combina
|
|
|
5284
5285
|
, exports.olist_))));
|
|
5285
5286
|
exports.olist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.union)([(0, combinator_1.match)(openers['.'], (0, memoize_1.memoize)(ms => list(type(ms[1]), '.'), ms => type(ms[1]).charCodeAt(0) || 0, [])), (0, combinator_1.match)(openers['('], (0, memoize_1.memoize)(ms => list(type(ms[1]), '('), ms => type(ms[1]).charCodeAt(0) || 0, []))])));
|
|
5286
5287
|
|
|
5287
|
-
const list = (type, form) => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)((0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(heads[form], (0, combinator_1.subsequence)([ulist_1.checkbox, (0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))]), true)), (0, combinator_1.indent)((0, combinator_1.union)([ulist_1.ulist_, exports.olist_, ilist_1.ilist_]))]), exports.invalid), ns => [(0, dom_1.html)('li', {
|
|
5288
|
+
const list = (type, form) => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(heads[form], (0, combinator_1.subsequence)([ulist_1.checkbox, (0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))]), true)), (0, combinator_1.indent)((0, combinator_1.union)([ulist_1.ulist_, exports.olist_, ilist_1.ilist_]))]), exports.invalid), ns => [(0, dom_1.html)('li', {
|
|
5288
5289
|
'data-marker': ns[0] || global_1.undefined
|
|
5289
5290
|
}, (0, dom_1.defrag)((0, ulist_1.fillFirstLine)((0, array_1.shift)(ns)[1])))]), true)]))), es => [format((0, dom_1.html)('ol', es), type, form)]);
|
|
5290
5291
|
|
|
@@ -5477,7 +5478,7 @@ const source_1 = __webpack_require__(6743);
|
|
|
5477
5478
|
|
|
5478
5479
|
const dom_1 = __webpack_require__(3252);
|
|
5479
5480
|
|
|
5480
|
-
exports.cite = (0, combinator_1.creation)((0, combinator_1.line)((0, combinator_1.fmap)((0, combinator_1.validate)('>>', (0, combinator_1.reverse)((0, combinator_1.tails)([(0, source_1.str)(/^>*(?=>>[^>\s]+[^\S\n]*(?:$|\n))/), (0, combinator_1.union)([anchor_1.anchor, // Subject page representation.
|
|
5481
|
+
exports.cite = (0, combinator_1.creation)(1, false, (0, combinator_1.line)((0, combinator_1.fmap)((0, combinator_1.validate)('>>', (0, combinator_1.reverse)((0, combinator_1.tails)([(0, source_1.str)(/^>*(?=>>[^>\s]+[^\S\n]*(?:$|\n))/), (0, combinator_1.union)([anchor_1.anchor, // Subject page representation.
|
|
5481
5482
|
// リンクの実装は後で検討
|
|
5482
5483
|
(0, combinator_1.focus)(/^>>\.[^\S\n]*(?:$|\n)/, () => [[(0, dom_1.html)('a', {
|
|
5483
5484
|
class: 'anchor'
|
|
@@ -5523,7 +5524,7 @@ const autolink_1 = __webpack_require__(6578);
|
|
|
5523
5524
|
const dom_1 = __webpack_require__(3252);
|
|
5524
5525
|
|
|
5525
5526
|
exports.syntax = /^>+(?=[^\S\n])|^>(?=[^\s>])|^>+(?=[^\s>])(?![0-9a-z]+(?:-[0-9a-z]+)*(?![0-9A-Za-z@#:]))/;
|
|
5526
|
-
exports.quote = (0, combinator_1.lazy)(() => (0, combinator_1.creation)((0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)('>', (0, combinator_1.union)([(0, combinator_1.rewrite)((0, combinator_1.some)((0, combinator_1.validate)(new RegExp(exports.syntax.source.split('|')[0]), source_1.anyline)), qblock), (0, combinator_1.rewrite)((0, combinator_1.validate)(new RegExp(exports.syntax.source.split('|').slice(1).join('|')), source_1.anyline), (0, combinator_1.line)((0, combinator_1.union)([(0, source_1.str)(/^.+/)])))])), ns => [(0, dom_1.html)('span', ns.length > 1 ? {
|
|
5527
|
+
exports.quote = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(1, false, (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)('>', (0, combinator_1.union)([(0, combinator_1.rewrite)((0, combinator_1.some)((0, combinator_1.validate)(new RegExp(exports.syntax.source.split('|')[0]), source_1.anyline)), qblock), (0, combinator_1.rewrite)((0, combinator_1.validate)(new RegExp(exports.syntax.source.split('|').slice(1).join('|')), source_1.anyline), (0, combinator_1.line)((0, combinator_1.union)([(0, source_1.str)(/^.+/)])))])), ns => [(0, dom_1.html)('span', ns.length > 1 ? {
|
|
5527
5528
|
class: 'quote'
|
|
5528
5529
|
} : {
|
|
5529
5530
|
class: 'quote invalid',
|
|
@@ -5606,7 +5607,7 @@ const opener = /^(?=\|\|+(?:$|\s))/;
|
|
|
5606
5607
|
|
|
5607
5608
|
const unindent = source => source.replace(/(^|\n)\|(?:[^\S\n]|(?=\|*(?:$|\s)))|\n$/g, '$1');
|
|
5608
5609
|
|
|
5609
|
-
const source = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)((0, combinator_1.union)([(0, combinator_1.focus)(/^(?:\|\|+(?:[^\S\n][^\n]*)?(?:$|\n))+/, (0, combinator_1.convert)(unindent, source)), (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, (0, combinator_1.fmap)((0, combinator_1.some)(autolink_1.autolink), ns => [(0, dom_1.html)('pre', (0, dom_1.defrag)(ns))])))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
|
|
5610
|
+
const source = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, combinator_1.focus)(/^(?:\|\|+(?:[^\S\n][^\n]*)?(?:$|\n))+/, (0, combinator_1.convert)(unindent, source)), (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, (0, combinator_1.fmap)((0, combinator_1.some)(autolink_1.autolink), ns => [(0, dom_1.html)('pre', (0, dom_1.defrag)(ns))])))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
|
|
5610
5611
|
|
|
5611
5612
|
/***/ }),
|
|
5612
5613
|
|
|
@@ -5637,7 +5638,7 @@ const array_1 = __webpack_require__(8112);
|
|
|
5637
5638
|
|
|
5638
5639
|
exports.table = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^\|[^\n]*(?:\n\|[^\n]*){2}/, (0, combinator_1.sequence)([row((0, combinator_1.some)(head), true), row((0, combinator_1.some)(align), false), (0, combinator_1.some)(row((0, combinator_1.some)(data), true))])), rows => [(0, dom_1.html)('table', [(0, dom_1.html)('thead', [rows.shift()]), (0, dom_1.html)('tbody', format(rows))])])));
|
|
5639
5640
|
|
|
5640
|
-
const row = (parser, optional) => (0, combinator_1.creation)((0, combinator_1.fallback)((0, combinator_1.fmap)((0, combinator_1.line)((0, combinator_1.surround)(/^(?=\|)/, (0, combinator_1.some)((0, combinator_1.union)([parser])), /^[|\\]?\s*$/, optional)), es => [(0, dom_1.html)('tr', es)]), (0, combinator_1.rewrite)(source_1.contentline, ({
|
|
5641
|
+
const row = (parser, optional) => (0, combinator_1.creation)(1, false, (0, combinator_1.fallback)((0, combinator_1.fmap)((0, combinator_1.line)((0, combinator_1.surround)(/^(?=\|)/, (0, combinator_1.some)((0, combinator_1.union)([parser])), /^[|\\]?\s*$/, optional)), es => [(0, dom_1.html)('tr', es)]), (0, combinator_1.rewrite)(source_1.contentline, ({
|
|
5641
5642
|
source
|
|
5642
5643
|
}) => [[(0, dom_1.html)('tr', {
|
|
5643
5644
|
class: 'invalid',
|
|
@@ -5646,10 +5647,10 @@ const row = (parser, optional) => (0, combinator_1.creation)((0, combinator_1.fa
|
|
|
5646
5647
|
'data-invalid-message': 'Missing the start symbol of the table row'
|
|
5647
5648
|
}, [(0, dom_1.html)('td', source.replace('\n', ''))])], ''])));
|
|
5648
5649
|
|
|
5649
|
-
const align = (0, combinator_1.creation)((0, combinator_1.fmap)((0, combinator_1.open)('|', (0, combinator_1.union)([(0, combinator_1.focus)(/^:-+:/, () => [['center'], '']), (0, combinator_1.focus)(/^:-+/, () => [['start'], '']), (0, combinator_1.focus)(/^-+:/, () => [['end'], '']), (0, combinator_1.focus)(/^-+/, () => [[''], ''])])), ns => [(0, dom_1.html)('td', (0, dom_1.defrag)(ns))]));
|
|
5650
|
+
const align = (0, combinator_1.creation)(1, false, (0, combinator_1.fmap)((0, combinator_1.open)('|', (0, combinator_1.union)([(0, combinator_1.focus)(/^:-+:/, () => [['center'], '']), (0, combinator_1.focus)(/^:-+/, () => [['start'], '']), (0, combinator_1.focus)(/^-+:/, () => [['end'], '']), (0, combinator_1.focus)(/^-+/, () => [[''], ''])])), ns => [(0, dom_1.html)('td', (0, dom_1.defrag)(ns))]));
|
|
5650
5651
|
const cell = (0, combinator_1.surround)(/^\|\s*(?=\S)/, (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), /^\|/, [[/^[|\\]?\s*$/, 9]]), /^[^|]*/, true);
|
|
5651
|
-
const head = (0, combinator_1.creation)((0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('th', (0, visibility_1.trimNode)((0, dom_1.defrag)(ns)))]));
|
|
5652
|
-
const data = (0, combinator_1.creation)((0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('td', (0, visibility_1.trimNode)((0, dom_1.defrag)(ns)))]));
|
|
5652
|
+
const head = (0, combinator_1.creation)(1, false, (0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('th', (0, visibility_1.trimNode)((0, dom_1.defrag)(ns)))]));
|
|
5653
|
+
const data = (0, combinator_1.creation)(1, false, (0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('td', (0, visibility_1.trimNode)((0, dom_1.defrag)(ns)))]));
|
|
5653
5654
|
|
|
5654
5655
|
function format(rows) {
|
|
5655
5656
|
const aligns = rows[0].className === 'invalid' ? [] : (0, duff_1.duffReduce)(rows.shift().children, (acc, el) => (0, array_1.push)(acc, [el.textContent]), []);
|
|
@@ -5698,8 +5699,8 @@ const array_1 = __webpack_require__(8112);
|
|
|
5698
5699
|
exports.ulist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(/^-(?=[^\S\n]|\n[^\S\n]*\S)/, (0, combinator_1.state)(4
|
|
5699
5700
|
/* State.media */
|
|
5700
5701
|
, exports.ulist_))));
|
|
5701
|
-
exports.ulist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^-(?=$|\s)/, (0, combinator_1.some)((0, combinator_1.creation)((0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(/^-(?:$|\s)/, (0, combinator_1.subsequence)([exports.checkbox, (0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))]), true)), (0, combinator_1.indent)((0, combinator_1.union)([exports.ulist_, olist_1.olist_, ilist_1.ilist_]))]), olist_1.invalid), ns => [(0, dom_1.html)('li', (0, dom_1.defrag)(fillFirstLine(ns)))]), true)])))), es => [format((0, dom_1.html)('ul', es))])));
|
|
5702
|
-
exports.checkbox = (0, combinator_1.creation)((0, combinator_1.focus)(/^\[[xX ]\](?=$|\s)/, ({
|
|
5702
|
+
exports.ulist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^-(?=$|\s)/, (0, combinator_1.some)((0, combinator_1.creation)(1, false, (0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(/^-(?:$|\s)/, (0, combinator_1.subsequence)([exports.checkbox, (0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))]), true)), (0, combinator_1.indent)((0, combinator_1.union)([exports.ulist_, olist_1.olist_, ilist_1.ilist_]))]), olist_1.invalid), ns => [(0, dom_1.html)('li', (0, dom_1.defrag)(fillFirstLine(ns)))]), true)])))), es => [format((0, dom_1.html)('ul', es))])));
|
|
5703
|
+
exports.checkbox = (0, combinator_1.creation)(1, false, (0, combinator_1.focus)(/^\[[xX ]\](?=$|\s)/, ({
|
|
5703
5704
|
source
|
|
5704
5705
|
}) => [[(0, dom_1.html)('span', {
|
|
5705
5706
|
class: 'checkbox'
|
|
@@ -7340,7 +7341,7 @@ exports.ruby = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[', (0,
|
|
|
7340
7341
|
return [(0, dom_1.html)('ruby', attributes(texts, rubies), (0, dom_1.defrag)((0, array_1.unshift)([texts.join(' ')], [(0, dom_1.html)('rp', '('), (0, dom_1.html)('rt', rubies.join(' ').trim()), (0, dom_1.html)('rp', ')')])))];
|
|
7341
7342
|
}
|
|
7342
7343
|
}))));
|
|
7343
|
-
const text = (0, combinator_1.creation)(({
|
|
7344
|
+
const text = (0, combinator_1.creation)(1, false, ({
|
|
7344
7345
|
source,
|
|
7345
7346
|
context
|
|
7346
7347
|
}) => {
|
|
@@ -8151,7 +8152,7 @@ const combinator_1 = __webpack_require__(2087);
|
|
|
8151
8152
|
const text_1 = __webpack_require__(7763);
|
|
8152
8153
|
|
|
8153
8154
|
const delimiter = /[\s\x00-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]/;
|
|
8154
|
-
exports.escsource = (0, combinator_1.creation)(({
|
|
8155
|
+
exports.escsource = (0, combinator_1.creation)(1, false, ({
|
|
8155
8156
|
source
|
|
8156
8157
|
}) => {
|
|
8157
8158
|
if (source === '') return;
|
|
@@ -8219,12 +8220,12 @@ const global_1 = __webpack_require__(4128);
|
|
|
8219
8220
|
const combinator_1 = __webpack_require__(2087);
|
|
8220
8221
|
|
|
8221
8222
|
function str(pattern) {
|
|
8222
|
-
return typeof pattern === 'string' ? (0, combinator_1.creation)(({
|
|
8223
|
+
return typeof pattern === 'string' ? (0, combinator_1.creation)(1, false, ({
|
|
8223
8224
|
source
|
|
8224
8225
|
}) => {
|
|
8225
8226
|
if (source === '') return;
|
|
8226
8227
|
return source.slice(0, pattern.length) === pattern ? [[pattern], source.slice(pattern.length)] : global_1.undefined;
|
|
8227
|
-
}) : (0, combinator_1.creation)(({
|
|
8228
|
+
}) : (0, combinator_1.creation)(1, false, ({
|
|
8228
8229
|
source
|
|
8229
8230
|
}) => {
|
|
8230
8231
|
if (source === '') return;
|
|
@@ -8236,12 +8237,12 @@ function str(pattern) {
|
|
|
8236
8237
|
exports.str = str;
|
|
8237
8238
|
|
|
8238
8239
|
function stropt(pattern) {
|
|
8239
|
-
return typeof pattern === 'string' ? (0, combinator_1.creation)(({
|
|
8240
|
+
return typeof pattern === 'string' ? (0, combinator_1.creation)(1, false, ({
|
|
8240
8241
|
source
|
|
8241
8242
|
}) => {
|
|
8242
8243
|
if (source === '') return;
|
|
8243
8244
|
return source.slice(0, pattern.length) === pattern ? [[pattern], source.slice(pattern.length)] : global_1.undefined;
|
|
8244
|
-
}) : (0, combinator_1.creation)(({
|
|
8245
|
+
}) : (0, combinator_1.creation)(1, false, ({
|
|
8245
8246
|
source
|
|
8246
8247
|
}) => {
|
|
8247
8248
|
if (source === '') return;
|
|
@@ -8277,11 +8278,7 @@ exports.delimiter = /[\s\x00-\x7F]|\S[#>]|[()、。!?][^\S\n]*(?=\\\n)/;
|
|
|
8277
8278
|
exports.nonWhitespace = /[\S\n]|$/;
|
|
8278
8279
|
exports.nonAlphanumeric = /[^0-9A-Za-z]|\S[#>]|$/;
|
|
8279
8280
|
const repeat = (0, str_1.str)(/^(.)\1*/);
|
|
8280
|
-
exports.text = (0, combinator_1.
|
|
8281
|
-
/* Syntax.none */
|
|
8282
|
-
, 1, 1, 0
|
|
8283
|
-
/* State.none */
|
|
8284
|
-
, ({
|
|
8281
|
+
exports.text = (0, combinator_1.creation)(1, false, ({
|
|
8285
8282
|
source,
|
|
8286
8283
|
context
|
|
8287
8284
|
}) => {
|
|
@@ -8385,7 +8382,7 @@ const combinator_1 = __webpack_require__(2087);
|
|
|
8385
8382
|
|
|
8386
8383
|
const text_1 = __webpack_require__(7763);
|
|
8387
8384
|
|
|
8388
|
-
exports.unescsource = (0, combinator_1.creation)(({
|
|
8385
|
+
exports.unescsource = (0, combinator_1.creation)(1, false, ({
|
|
8389
8386
|
source
|
|
8390
8387
|
}) => {
|
|
8391
8388
|
if (source === '') return;
|
package/package.json
CHANGED
|
@@ -87,16 +87,18 @@ export function syntax<T>(syntax: number, prec: number, cost: number, state: num
|
|
|
87
87
|
|
|
88
88
|
export function creation<P extends Parser<unknown>>(parser: P): P;
|
|
89
89
|
export function creation<P extends Parser<unknown>>(cost: number, parser: P): P;
|
|
90
|
-
export function creation(cost: number
|
|
91
|
-
|
|
90
|
+
export function creation<P extends Parser<unknown>>(cost: number, recursion: boolean, parser: P): P;
|
|
91
|
+
export function creation(cost: number | Parser<unknown>, recursion?: boolean | Parser<unknown>, parser?: Parser<unknown>): Parser<unknown> {
|
|
92
|
+
if (typeof cost === 'function') return creation(1, true, cost);
|
|
93
|
+
if (typeof recursion === 'function') return creation(cost, true, recursion);
|
|
92
94
|
assert(cost > 0);
|
|
93
95
|
return ({ source, context }) => {
|
|
94
96
|
const resources = context.resources ?? { clock: 1, recursion: 1 };
|
|
95
97
|
if (resources.clock <= 0) throw new Error('Too many creations');
|
|
96
98
|
if (resources.recursion <= 0) throw new Error('Too much recursion');
|
|
97
|
-
--resources.recursion;
|
|
99
|
+
recursion && --resources.recursion;
|
|
98
100
|
const result = parser!({ source, context });
|
|
99
|
-
++resources.recursion;
|
|
101
|
+
recursion && ++resources.recursion;
|
|
100
102
|
if (result) {
|
|
101
103
|
resources.clock -= cost;
|
|
102
104
|
}
|
|
@@ -19,7 +19,7 @@ const indent = block(open(opener, some(contentline, /^>(?:$|\s)/)), false);
|
|
|
19
19
|
const unindent = (source: string) => source.replace(/(^|\n)>(?:[^\S\n]|(?=>*(?:$|\s)))|\n$/g, '$1');
|
|
20
20
|
|
|
21
21
|
const source: BlockquoteParser.SourceParser = lazy(() => fmap(
|
|
22
|
-
some(creation(union([
|
|
22
|
+
some(creation(1, false, union([
|
|
23
23
|
rewrite(
|
|
24
24
|
indent,
|
|
25
25
|
convert(unindent, source)),
|
|
@@ -30,11 +30,11 @@ const source: BlockquoteParser.SourceParser = lazy(() => fmap(
|
|
|
30
30
|
ns => [html('blockquote', ns)]));
|
|
31
31
|
|
|
32
32
|
const markdown: BlockquoteParser.MarkdownParser = lazy(() => fmap(
|
|
33
|
-
some(creation(union([
|
|
33
|
+
some(creation(1, false, union([
|
|
34
34
|
rewrite(
|
|
35
35
|
indent,
|
|
36
36
|
convert(unindent, markdown)),
|
|
37
|
-
creation(99,
|
|
37
|
+
creation(99, false,
|
|
38
38
|
rewrite(
|
|
39
39
|
some(contentline, opener),
|
|
40
40
|
convert(unindent, ({ source, context }) => {
|
|
@@ -17,13 +17,13 @@ export const dlist: DListParser = lazy(() => block(localize(fmap(validate(
|
|
|
17
17
|
]))),
|
|
18
18
|
es => [html('dl', fillTrailingDescription(es))]))));
|
|
19
19
|
|
|
20
|
-
const term: DListParser.TermParser = creation(line(indexee(fmap(open(
|
|
20
|
+
const term: DListParser.TermParser = creation(1, false, line(indexee(fmap(open(
|
|
21
21
|
/^~[^\S\n]+(?=\S)/,
|
|
22
22
|
visualize(trimBlank(some(union([indexer, inline])))),
|
|
23
23
|
true),
|
|
24
24
|
ns => [html('dt', defrag(ns))]))));
|
|
25
25
|
|
|
26
|
-
const desc: DListParser.DescriptionParser = creation(block(fmap(open(
|
|
26
|
+
const desc: DListParser.DescriptionParser = creation(1, false, block(fmap(open(
|
|
27
27
|
/^:[^\S\n]+(?=\S)|/,
|
|
28
28
|
rewrite(
|
|
29
29
|
some(anyline, /^[~:][^\S\n]+\S/),
|
|
@@ -79,7 +79,7 @@ const align: AlignParser = line(fmap(
|
|
|
79
79
|
|
|
80
80
|
const delimiter = /^[-=<>]+(?:\/[-=^v]*)?(?=[^\S\n]*\n)|^[#:](?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=\s)/;
|
|
81
81
|
|
|
82
|
-
const head: CellParser.HeadParser = creation(block(fmap(open(
|
|
82
|
+
const head: CellParser.HeadParser = creation(1, false, block(fmap(open(
|
|
83
83
|
str(/^#(?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=\s)/),
|
|
84
84
|
rewrite(
|
|
85
85
|
inits([
|
|
@@ -91,7 +91,7 @@ const head: CellParser.HeadParser = creation(block(fmap(open(
|
|
|
91
91
|
ns => [html('th', attributes(ns.shift()! as string), defrag(ns))]),
|
|
92
92
|
false));
|
|
93
93
|
|
|
94
|
-
const data: CellParser.DataParser = creation(block(fmap(open(
|
|
94
|
+
const data: CellParser.DataParser = creation(1, false, block(fmap(open(
|
|
95
95
|
str(/^:(?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=\s)/),
|
|
96
96
|
rewrite(
|
|
97
97
|
inits([
|
|
@@ -103,7 +103,7 @@ const data: CellParser.DataParser = creation(block(fmap(open(
|
|
|
103
103
|
ns => [html('td', attributes(ns.shift()! as string), defrag(ns))]),
|
|
104
104
|
false));
|
|
105
105
|
|
|
106
|
-
const dataline: CellParser.DatalineParser = creation(line(
|
|
106
|
+
const dataline: CellParser.DatalineParser = creation(1, false, line(
|
|
107
107
|
rewrite(
|
|
108
108
|
contentline,
|
|
109
109
|
union([
|
|
@@ -13,7 +13,7 @@ export const ilist: IListParser = lazy(() => block(validate(
|
|
|
13
13
|
|
|
14
14
|
export const ilist_: IListParser = lazy(() => block(fmap(validate(
|
|
15
15
|
/^[-+*](?:$|\s)/,
|
|
16
|
-
some(creation(union([
|
|
16
|
+
some(creation(1, false, union([
|
|
17
17
|
fmap(fallback(
|
|
18
18
|
inits([
|
|
19
19
|
line(open(/^[-+*](?:$|\s)/, some(inline), true)),
|
|
@@ -36,7 +36,7 @@ export const olist_: OListParser = lazy(() => block(union([
|
|
|
36
36
|
])));
|
|
37
37
|
|
|
38
38
|
const list = (type: string, form: string): OListParser.ListParser => fmap(
|
|
39
|
-
some(creation(union([
|
|
39
|
+
some(creation(1, false, union([
|
|
40
40
|
indexee(fmap(fallback(
|
|
41
41
|
inits([
|
|
42
42
|
line(open(heads[form], subsequence([checkbox, trimBlank(some(union([indexer, inline])))]), true)),
|
|
@@ -4,7 +4,7 @@ import { anchor } from '../../inline/autolink/anchor';
|
|
|
4
4
|
import { str } from '../../source';
|
|
5
5
|
import { html, define, defrag } from 'typed-dom/dom';
|
|
6
6
|
|
|
7
|
-
export const cite: ReplyParser.CiteParser = creation(line(fmap(validate(
|
|
7
|
+
export const cite: ReplyParser.CiteParser = creation(1, false, line(fmap(validate(
|
|
8
8
|
'>>',
|
|
9
9
|
reverse(tails([
|
|
10
10
|
str(/^>*(?=>>[^>\s]+[^\S\n]*(?:$|\n))/),
|
|
@@ -8,7 +8,7 @@ import { html, defrag } from 'typed-dom/dom';
|
|
|
8
8
|
|
|
9
9
|
export const syntax = /^>+(?=[^\S\n])|^>(?=[^\s>])|^>+(?=[^\s>])(?![0-9a-z]+(?:-[0-9a-z]+)*(?![0-9A-Za-z@#:]))/;
|
|
10
10
|
|
|
11
|
-
export const quote: ReplyParser.QuoteParser = lazy(() => creation(block(fmap(validate(
|
|
11
|
+
export const quote: ReplyParser.QuoteParser = lazy(() => creation(1, false, block(fmap(validate(
|
|
12
12
|
'>',
|
|
13
13
|
union([
|
|
14
14
|
rewrite(
|
|
@@ -20,7 +20,7 @@ const opener = /^(?=\|\|+(?:$|\s))/;
|
|
|
20
20
|
const unindent = (source: string) => source.replace(/(^|\n)\|(?:[^\S\n]|(?=\|*(?:$|\s)))|\n$/g, '$1');
|
|
21
21
|
|
|
22
22
|
const source: SidefenceParser.SourceParser = lazy(() => fmap(
|
|
23
|
-
some(creation(union([
|
|
23
|
+
some(creation(1, false, union([
|
|
24
24
|
focus(
|
|
25
25
|
/^(?:\|\|+(?:[^\S\n][^\n]*)?(?:$|\n))+/,
|
|
26
26
|
convert(unindent, source)),
|
|
@@ -25,7 +25,7 @@ export const table: TableParser = lazy(() => block(fmap(validate(
|
|
|
25
25
|
]),
|
|
26
26
|
])));
|
|
27
27
|
|
|
28
|
-
const row = <P extends CellParser | AlignParser>(parser: P, optional: boolean): RowParser<P> => creation(fallback(fmap(
|
|
28
|
+
const row = <P extends CellParser | AlignParser>(parser: P, optional: boolean): RowParser<P> => creation(1, false, fallback(fmap(
|
|
29
29
|
line(surround(/^(?=\|)/, some(union([parser])), /^[|\\]?\s*$/, optional)),
|
|
30
30
|
es => [html('tr', es)]),
|
|
31
31
|
rewrite(contentline, ({ source }) => [[
|
|
@@ -37,7 +37,7 @@ const row = <P extends CellParser | AlignParser>(parser: P, optional: boolean):
|
|
|
37
37
|
}, [html('td', source.replace('\n', ''))])
|
|
38
38
|
], ''])));
|
|
39
39
|
|
|
40
|
-
const align: AlignParser = creation(fmap(open(
|
|
40
|
+
const align: AlignParser = creation(1, false, fmap(open(
|
|
41
41
|
'|',
|
|
42
42
|
union([
|
|
43
43
|
focus(/^:-+:/, () => [['center'], '']),
|
|
@@ -52,11 +52,11 @@ const cell: CellParser = surround(
|
|
|
52
52
|
some(union([inline]), /^\|/, [[/^[|\\]?\s*$/, 9]]),
|
|
53
53
|
/^[^|]*/, true);
|
|
54
54
|
|
|
55
|
-
const head: CellParser.HeadParser = creation(fmap(
|
|
55
|
+
const head: CellParser.HeadParser = creation(1, false, fmap(
|
|
56
56
|
cell,
|
|
57
57
|
ns => [html('th', trimNode(defrag(ns)))]));
|
|
58
58
|
|
|
59
|
-
const data: CellParser.DataParser = creation(fmap(
|
|
59
|
+
const data: CellParser.DataParser = creation(1, false, fmap(
|
|
60
60
|
cell,
|
|
61
61
|
ns => [html('td', trimNode(defrag(ns)))]));
|
|
62
62
|
|
|
@@ -15,7 +15,7 @@ export const ulist: UListParser = lazy(() => block(validate(
|
|
|
15
15
|
|
|
16
16
|
export const ulist_: UListParser = lazy(() => block(fmap(validate(
|
|
17
17
|
/^-(?=$|\s)/,
|
|
18
|
-
some(creation(union([
|
|
18
|
+
some(creation(1, false, union([
|
|
19
19
|
indexee(fmap(fallback(
|
|
20
20
|
inits([
|
|
21
21
|
line(open(/^-(?:$|\s)/, subsequence([checkbox, trimBlank(some(union([indexer, inline])))]), true)),
|
|
@@ -26,7 +26,7 @@ export const ulist_: UListParser = lazy(() => block(fmap(validate(
|
|
|
26
26
|
])))),
|
|
27
27
|
es => [format(html('ul', es))])));
|
|
28
28
|
|
|
29
|
-
export const checkbox = creation(focus(
|
|
29
|
+
export const checkbox = creation(1, false, focus(
|
|
30
30
|
/^\[[xX ]\](?=$|\s)/,
|
|
31
31
|
({ source }) => [[
|
|
32
32
|
html('span', { class: 'checkbox' }, source[1].trimStart() ? '☑' : '☐'),
|
package/src/parser/block.ts
CHANGED
|
@@ -35,7 +35,7 @@ export import BlockquoteParser = BlockParser.BlockquoteParser;
|
|
|
35
35
|
export import ReplyParser = BlockParser.ReplyParser;
|
|
36
36
|
export import ParagraphParser = BlockParser.ParagraphParser;
|
|
37
37
|
|
|
38
|
-
export const block: BlockParser = creation(error(
|
|
38
|
+
export const block: BlockParser = creation(1, false, error(
|
|
39
39
|
reset({ resources: { clock: 50 * 1000, recursion: 20 } },
|
|
40
40
|
union([
|
|
41
41
|
emptyline,
|
|
@@ -48,7 +48,7 @@ export const ruby: RubyParser = lazy(() => validate('[', syntax(Syntax.none, 2,
|
|
|
48
48
|
}
|
|
49
49
|
}))));
|
|
50
50
|
|
|
51
|
-
const text: RubyParser.TextParser = creation(({ source, context }) => {
|
|
51
|
+
const text: RubyParser.TextParser = creation(1, false, ({ source, context }) => {
|
|
52
52
|
const acc = [''];
|
|
53
53
|
while (source !== '') {
|
|
54
54
|
assert(source[0] !== '\n');
|
|
@@ -4,7 +4,7 @@ import { nonWhitespace } from './text';
|
|
|
4
4
|
|
|
5
5
|
const delimiter = /[\s\x00-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]/;
|
|
6
6
|
|
|
7
|
-
export const escsource: EscapableSourceParser = creation(({ source }) => {
|
|
7
|
+
export const escsource: EscapableSourceParser = creation(1, false, ({ source }) => {
|
|
8
8
|
if (source === '') return;
|
|
9
9
|
const i = source.search(delimiter);
|
|
10
10
|
switch (i) {
|
package/src/parser/source/str.ts
CHANGED
|
@@ -7,13 +7,13 @@ export function str(pattern: string | RegExp): StrParser;
|
|
|
7
7
|
export function str(pattern: string | RegExp): Parser<string, Context<StrParser>, []> {
|
|
8
8
|
assert(pattern);
|
|
9
9
|
return typeof pattern === 'string'
|
|
10
|
-
? creation(({ source }) => {
|
|
10
|
+
? creation(1, false, ({ source }) => {
|
|
11
11
|
if (source === '') return;
|
|
12
12
|
return source.slice(0, pattern.length) === pattern
|
|
13
13
|
? [[pattern], source.slice(pattern.length)]
|
|
14
14
|
: undefined;
|
|
15
15
|
})
|
|
16
|
-
: creation(({ source }) => {
|
|
16
|
+
: creation(1, false, ({ source }) => {
|
|
17
17
|
if (source === '') return;
|
|
18
18
|
const m = source.match(pattern);
|
|
19
19
|
return m && m[0].length > 0
|
|
@@ -26,13 +26,13 @@ export function stropt(pattern: string | RegExp): StrParser;
|
|
|
26
26
|
export function stropt(pattern: string | RegExp): Parser<string, Context<StrParser>, []> {
|
|
27
27
|
assert(pattern);
|
|
28
28
|
return typeof pattern === 'string'
|
|
29
|
-
? creation(({ source }) => {
|
|
29
|
+
? creation(1, false, ({ source }) => {
|
|
30
30
|
if (source === '') return;
|
|
31
31
|
return source.slice(0, pattern.length) === pattern
|
|
32
32
|
? [[pattern], source.slice(pattern.length)]
|
|
33
33
|
: undefined;
|
|
34
34
|
})
|
|
35
|
-
: creation(({ source }) => {
|
|
35
|
+
: creation(1, false, ({ source }) => {
|
|
36
36
|
if (source === '') return;
|
|
37
37
|
const m = source.match(pattern);
|
|
38
38
|
return m
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { undefined } from 'spica/global';
|
|
2
2
|
import { TextParser, TxtParser, LinebreakParser } from '../source';
|
|
3
|
-
import { union,
|
|
3
|
+
import { union, creation, focus } from '../../combinator';
|
|
4
4
|
import { str } from './str';
|
|
5
|
-
import { Syntax, State } from '../context';
|
|
6
5
|
import { html } from 'typed-dom/dom';
|
|
7
6
|
|
|
8
7
|
export const delimiter = /[\s\x00-\x7F]|\S[#>]|[()、。!?][^\S\n]*(?=\\\n)/;
|
|
@@ -10,7 +9,7 @@ export const nonWhitespace = /[\S\n]|$/;
|
|
|
10
9
|
export const nonAlphanumeric = /[^0-9A-Za-z]|\S[#>]|$/;
|
|
11
10
|
const repeat = str(/^(.)\1*/);
|
|
12
11
|
|
|
13
|
-
export const text: TextParser =
|
|
12
|
+
export const text: TextParser = creation(1, false, ({ source, context }) => {
|
|
14
13
|
if (source === '') return;
|
|
15
14
|
const i = source.search(delimiter);
|
|
16
15
|
switch (i) {
|
|
@@ -2,7 +2,7 @@ import { UnescapableSourceParser } from '../source';
|
|
|
2
2
|
import { creation } from '../../combinator';
|
|
3
3
|
import { delimiter, nonWhitespace, nonAlphanumeric, isAlphanumeric } from './text';
|
|
4
4
|
|
|
5
|
-
export const unescsource: UnescapableSourceParser = creation(({ source }) => {
|
|
5
|
+
export const unescsource: UnescapableSourceParser = creation(1, false, ({ source }) => {
|
|
6
6
|
assert(source[0] !== '\x1B');
|
|
7
7
|
if (source === '') return;
|
|
8
8
|
const i = source.search(delimiter);
|