securemark 0.276.0 → 0.276.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/index.js +31 -44
- package/markdown.d.ts +0 -1
- package/package.json +1 -1
- package/src/combinator/control/manipulation/convert.ts +3 -3
- package/src/combinator/data/parser/context.ts +3 -3
- package/src/combinator/data/parser/inits.ts +1 -1
- package/src/combinator/data/parser/sequence.ts +1 -1
- package/src/parser/block/blockquote.ts +4 -4
- package/src/parser/block/extension/table.test.ts +38 -2
- package/src/parser/block/extension/table.ts +6 -6
- package/src/parser/block/olist.ts +6 -8
- package/src/parser/block/sidefence.ts +2 -2
- package/src/parser/block/table.ts +4 -4
- package/src/parser/block/ulist.ts +5 -5
- package/src/parser/inline/annotation.ts +3 -4
- package/src/parser/inline/html.ts +1 -2
- package/src/parser/inline/reference.ts +10 -10
- package/src/parser/visibility.ts +22 -18
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.276.
|
|
1
|
+
/*! securemark v0.276.1 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
|
|
2
2
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
3
3
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
4
4
|
module.exports = factory(require("Prism"), require("DOMPurify"));
|
|
@@ -2782,14 +2782,14 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
2782
2782
|
}));
|
|
2783
2783
|
exports.convert = void 0;
|
|
2784
2784
|
const parser_1 = __webpack_require__(6728);
|
|
2785
|
-
function convert(conv, parser) {
|
|
2785
|
+
function convert(conv, parser, empty = false) {
|
|
2786
2786
|
return ({
|
|
2787
2787
|
source,
|
|
2788
2788
|
context
|
|
2789
2789
|
}) => {
|
|
2790
2790
|
if (source === '') return;
|
|
2791
2791
|
const src = conv(source, context);
|
|
2792
|
-
if (src === '') return [[], ''];
|
|
2792
|
+
if (src === '') return empty ? [[], ''] : undefined;
|
|
2793
2793
|
context.offset ??= 0;
|
|
2794
2794
|
context.offset += source.length - src.length;
|
|
2795
2795
|
const result = parser({
|
|
@@ -4365,8 +4365,8 @@ exports.blockquote = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, co
|
|
|
4365
4365
|
const opener = /^(?=>>+(?:$|\s))/;
|
|
4366
4366
|
const indent = (0, combinator_1.block)((0, combinator_1.open)(opener, (0, combinator_1.some)(source_1.contentline, /^>(?:$|\s)/)), false);
|
|
4367
4367
|
const unindent = source => source.replace(/(?<=^|\n)>(?:[^\S\n]|(?=>*(?:$|\s)))|\n$/g, '');
|
|
4368
|
-
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)(autolink_1.autolink, ns => [(0, dom_1.html)('pre', (0, dom_1.defrag)(ns))])))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
|
|
4369
|
-
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, ({
|
|
4368
|
+
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, true)), (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, (0, combinator_1.fmap)(autolink_1.autolink, ns => [(0, dom_1.html)('pre', (0, dom_1.defrag)(ns))]), true))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
|
|
4369
|
+
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, true)), (0, combinator_1.creation)(99, false, (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, ({
|
|
4370
4370
|
source,
|
|
4371
4371
|
context
|
|
4372
4372
|
}) => {
|
|
@@ -4380,7 +4380,7 @@ const markdown = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combina
|
|
|
4380
4380
|
}
|
|
4381
4381
|
}, context);
|
|
4382
4382
|
return [[(0, dom_1.html)('section', [document, (0, dom_1.html)('h2', 'References'), references])], ''];
|
|
4383
|
-
})))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
|
|
4383
|
+
}, true)))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
|
|
4384
4384
|
|
|
4385
4385
|
/***/ }),
|
|
4386
4386
|
|
|
@@ -4949,8 +4949,8 @@ const row = (0, combinator_1.lazy)(() => (0, combinator_1.dup)((0, combinator_1.
|
|
|
4949
4949
|
const alignment = /^[-=<>]+(?:\/[-=^v]*)?(?=[^\S\n]*\n)/;
|
|
4950
4950
|
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(''))));
|
|
4951
4951
|
const delimiter = /^[-=<>]+(?:\/[-=^v]*)?(?=[^\S\n]*\n)|^[#:](?:(?!:\D|0)\d*:(?!0)\d*)?(?:!+[+]?)?(?=\s)/;
|
|
4952
|
-
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.
|
|
4953
|
-
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.
|
|
4952
|
+
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.open)(/^(?:\s*\n|\s)/, (0, visibility_1.visualize)((0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline])))), true)), true), ns => [(0, dom_1.html)('th', attributes(ns.shift()), (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))]), false));
|
|
4953
|
+
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.open)(/^(?:\s*\n|\s)/, (0, visibility_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))), true)), true), ns => [(0, dom_1.html)('td', attributes(ns.shift()), (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))]), false));
|
|
4954
4954
|
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)]))));
|
|
4955
4955
|
function attributes(source) {
|
|
4956
4956
|
let [, rowspan = undefined, colspan = undefined, highlight = undefined, extension = undefined] = source.match(/^[#:](?:(\d+)?:(\d+)?)?(?:(!+)([+]?))?$/) ?? [];
|
|
@@ -5263,7 +5263,6 @@ const index_1 = __webpack_require__(4479);
|
|
|
5263
5263
|
const source_1 = __webpack_require__(6743);
|
|
5264
5264
|
const visibility_1 = __webpack_require__(7618);
|
|
5265
5265
|
const memoize_1 = __webpack_require__(1808);
|
|
5266
|
-
const array_1 = __webpack_require__(8112);
|
|
5267
5266
|
const dom_1 = __webpack_require__(3252);
|
|
5268
5267
|
const openers = {
|
|
5269
5268
|
'.': /^([0-9]+|[a-z]+|[A-Z]+)(?:-(?!-)[0-9]*)*(?![^\S\n])\.?(?:$|\s)/,
|
|
@@ -5271,12 +5270,12 @@ const openers = {
|
|
|
5271
5270
|
};
|
|
5272
5271
|
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('|')), (0, combinator_1.state)(8 /* State.media */, exports.olist_))));
|
|
5273
5272
|
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]), []))])));
|
|
5274
|
-
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.
|
|
5273
|
+
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, combinator_1.union)([(0, combinator_1.fmap)((0, combinator_1.close)((0, combinator_1.union)([index_1.index]), /^$/), ([el]) => [(0, dom_1.define)(el, {
|
|
5275
5274
|
class: void el.classList.add('indexer'),
|
|
5276
5275
|
'data-index': ''
|
|
5277
|
-
})])
|
|
5278
|
-
'data-marker': ns
|
|
5279
|
-
}, (0, dom_1.defrag)((0, ulist_1.fillFirstLine)(
|
|
5276
|
+
})]), (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_]))]), exports.invalid), ns => [(0, dom_1.html)('li', {
|
|
5277
|
+
'data-marker': ns.shift() || undefined
|
|
5278
|
+
}, (0, dom_1.defrag)((0, ulist_1.fillFirstLine)(ns)))]), true)]))), es => [format((0, dom_1.html)('ol', es), type, form)]);
|
|
5280
5279
|
const heads = {
|
|
5281
5280
|
'.': (0, combinator_1.focus)(openers['.'], ({
|
|
5282
5281
|
source
|
|
@@ -5572,7 +5571,7 @@ exports.sidefence = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, com
|
|
|
5572
5571
|
})])));
|
|
5573
5572
|
const opener = /^(?=\|\|+(?:$|\s))/;
|
|
5574
5573
|
const unindent = source => source.replace(/(?<=^|\n)\|(?:[^\S\n]|(?=\|*(?:$|\s)))|\n$/g, '');
|
|
5575
|
-
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)(autolink_1.autolink, ns => [(0, dom_1.html)('pre', (0, dom_1.defrag)(ns))])))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
|
|
5574
|
+
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, true)), (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, (0, combinator_1.fmap)(autolink_1.autolink, ns => [(0, dom_1.html)('pre', (0, dom_1.defrag)(ns))]), true))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
|
|
5576
5575
|
|
|
5577
5576
|
/***/ }),
|
|
5578
5577
|
|
|
@@ -5603,9 +5602,9 @@ const row = (parser, optional) => (0, combinator_1.creation)(1, false, (0, combi
|
|
|
5603
5602
|
'data-invalid-message': 'Missing the start symbol of the table row'
|
|
5604
5603
|
}, [(0, dom_1.html)('td', source.replace('\n', ''))])], ''])));
|
|
5605
5604
|
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))]));
|
|
5606
|
-
const cell = (0, combinator_1.surround)(/^\|\s*(?=\S)/, (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), /^\|/, [[/^[|\\]?\s*$/, 9]]), /^[^|]*/, true);
|
|
5607
|
-
const head = (0, combinator_1.creation)(1, false, (0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('th', (0, visibility_1.
|
|
5608
|
-
const data = (0, combinator_1.creation)(1, false, (0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('td', (0, visibility_1.
|
|
5605
|
+
const cell = (0, combinator_1.surround)(/^\|\s*(?=\S)/, (0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), /^\|/, [[/^[|\\]?\s*$/, 9]])), /^[^|]*/, true);
|
|
5606
|
+
const head = (0, combinator_1.creation)(1, false, (0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('th', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))]));
|
|
5607
|
+
const data = (0, combinator_1.creation)(1, false, (0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('td', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))]));
|
|
5609
5608
|
function format(rows) {
|
|
5610
5609
|
const aligns = rows[0].className === 'invalid' ? [] : (0, duff_1.duffReduce)(rows.shift().children, (acc, el) => (0, array_1.push)(acc, [el.textContent]), []);
|
|
5611
5610
|
for (let i = 0; i < rows.length; ++i) {
|
|
@@ -5641,10 +5640,10 @@ const visibility_1 = __webpack_require__(7618);
|
|
|
5641
5640
|
const array_1 = __webpack_require__(8112);
|
|
5642
5641
|
const dom_1 = __webpack_require__(3252);
|
|
5643
5642
|
exports.ulist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(/^-(?=[^\S\n]|\n[^\S\n]*\S)/, (0, combinator_1.state)(8 /* State.media */, exports.ulist_))));
|
|
5644
|
-
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.
|
|
5643
|
+
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.union)([(0, combinator_1.fmap)((0, combinator_1.close)((0, combinator_1.union)([index_1.index]), /^$/), ([el]) => [(0, dom_1.define)(el, {
|
|
5645
5644
|
class: void el.classList.add('indexer'),
|
|
5646
5645
|
'data-index': ''
|
|
5647
|
-
})])
|
|
5646
|
+
})]), (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_]))]), olist_1.invalid), ns => [(0, dom_1.html)('li', (0, dom_1.defrag)(fillFirstLine(ns)))]), true)])))), es => [format((0, dom_1.html)('ul', es))])));
|
|
5648
5647
|
exports.checkbox = (0, combinator_1.creation)(1, false, (0, combinator_1.focus)(/^\[[xX ]\](?=$|\s)/, ({
|
|
5649
5648
|
source
|
|
5650
5649
|
}) => [[(0, dom_1.html)('span', {
|
|
@@ -5790,9 +5789,9 @@ const combinator_1 = __webpack_require__(2087);
|
|
|
5790
5789
|
const inline_1 = __webpack_require__(1160);
|
|
5791
5790
|
const visibility_1 = __webpack_require__(7618);
|
|
5792
5791
|
const dom_1 = __webpack_require__(3252);
|
|
5793
|
-
exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.surround)('((', (0, combinator_1.constraint)(256 /* State.annotation */, false, (0, combinator_1.syntax)(0 /* Syntax.none */, 6, 1, 256 /* State.annotation */ | 8 /* State.media */, (0, visibility_1.
|
|
5792
|
+
exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.surround)('((', (0, combinator_1.constraint)(256 /* State.annotation */, false, (0, combinator_1.syntax)(0 /* Syntax.none */, 6, 1, 256 /* State.annotation */ | 8 /* State.media */, (0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ')', [[/^\\?\n/, 9], [')', 2], ['))', 6]])))), '))', false, ([, ns], rest) => [[(0, dom_1.html)('sup', {
|
|
5794
5793
|
class: 'annotation'
|
|
5795
|
-
}, [(0, dom_1.html)('span', (0, visibility_1.
|
|
5794
|
+
}, [(0, dom_1.html)('span', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))])], rest]));
|
|
5796
5795
|
|
|
5797
5796
|
/***/ }),
|
|
5798
5797
|
|
|
@@ -6390,7 +6389,7 @@ exports.html = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('<', (0,
|
|
|
6390
6389
|
exports.attribute = (0, combinator_1.union)([(0, source_1.str)(/^[^\S\n]+[a-z]+(?:-[a-z]+)*(?:="[^"\n]*")?(?=[^\S\n]|>)/i)]);
|
|
6391
6390
|
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element
|
|
6392
6391
|
// [...document.querySelectorAll('tbody > tr > td:first-child')].map(el => el.textContent.slice(1, -1))
|
|
6393
|
-
const TAGS = Object.freeze(["html", "base", "head", "link", "meta", "style", "title", "body", "address", "article", "aside", "footer", "header", "h1", "h2", "h3", "h4", "h5", "h6", "main", "nav", "section", "blockquote", "dd", "div", "dl", "dt", "figcaption", "figure", "hr", "li", "menu", "ol", "p", "pre", "ul", "a", "abbr", "b", "bdi", "bdo", "br", "cite", "code", "data", "dfn", "em", "i", "kbd", "mark", "q", "rp", "rt", "ruby", "s", "samp", "small", "span", "strong", "sub", "sup", "time", "u", "var", "wbr", "area", "audio", "img", "map", "track", "video", "embed", "iframe", "object", "picture", "portal", "source", "svg", "math", "canvas", "noscript", "script", "del", "ins", "caption", "col", "colgroup", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "button", "datalist", "fieldset", "form", "input", "label", "legend", "meter", "optgroup", "option", "output", "progress", "select", "textarea", "details", "dialog", "summary", "slot", "template", "acronym", "applet", "
|
|
6392
|
+
const TAGS = Object.freeze(["html", "base", "head", "link", "meta", "style", "title", "body", "address", "article", "aside", "footer", "header", "h1", "h2", "h3", "h4", "h5", "h6", "hgroup", "main", "nav", "section", "blockquote", "dd", "div", "dl", "dt", "figcaption", "figure", "hr", "li", "menu", "ol", "p", "pre", "ul", "a", "abbr", "b", "bdi", "bdo", "br", "cite", "code", "data", "dfn", "em", "i", "kbd", "mark", "q", "rp", "rt", "ruby", "s", "samp", "small", "span", "strong", "sub", "sup", "time", "u", "var", "wbr", "area", "audio", "img", "map", "track", "video", "embed", "iframe", "object", "picture", "portal", "source", "svg", "math", "canvas", "noscript", "script", "del", "ins", "caption", "col", "colgroup", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "button", "datalist", "fieldset", "form", "input", "label", "legend", "meter", "optgroup", "option", "output", "progress", "select", "textarea", "details", "dialog", "summary", "slot", "template", "acronym", "applet", "bgsound", "big", "blink", "center", "content", "dir", "font", "frame", "frameset", "image", "keygen", "marquee", "menuitem", "nobr", "noembed", "noframes", "param", "plaintext", "rb", "rtc", "shadow", "spacer", "strike", "tt", "xmp"]);
|
|
6394
6393
|
function elem(tag, as, bs, cs) {
|
|
6395
6394
|
if (!tags.includes(tag)) return invalid('tag', `Invalid HTML tag name "${tag}"`, as, bs, cs);
|
|
6396
6395
|
if (cs.length === 0) return invalid('tag', `Missing the closing HTML tag "</${tag}>"`, as, bs, cs);
|
|
@@ -6765,9 +6764,9 @@ const inline_1 = __webpack_require__(1160);
|
|
|
6765
6764
|
const source_1 = __webpack_require__(6743);
|
|
6766
6765
|
const visibility_1 = __webpack_require__(7618);
|
|
6767
6766
|
const dom_1 = __webpack_require__(3252);
|
|
6768
|
-
exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.surround)('[[', (0, combinator_1.constraint)(128 /* State.reference */, false, (0, combinator_1.syntax)(256 /* Syntax.reference */, 6, 1, 256 /* State.annotation */ | 128 /* State.reference */ | 8 /* State.media */, (0,
|
|
6767
|
+
exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.surround)('[[', (0, combinator_1.constraint)(128 /* State.reference */, false, (0, combinator_1.syntax)(256 /* Syntax.reference */, 6, 1, 256 /* State.annotation */ | 128 /* State.reference */ | 8 /* State.media */, (0, combinator_1.subsequence)([abbr, (0, visibility_1.trimBlankStart)((0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]]))]))), ']]', false, ([, ns], rest) => [[(0, dom_1.html)('sup', attributes(ns), [(0, dom_1.html)('span', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))])], rest]));
|
|
6769
6768
|
// Chicago-Style
|
|
6770
|
-
const abbr = (0, combinator_1.creation)((0, combinator_1.
|
|
6769
|
+
const abbr = (0, combinator_1.creation)((0, combinator_1.surround)('^', (0, combinator_1.union)([(0, source_1.str)(/^(?=[A-Z])(?:[0-9A-Za-z]'?|(?:[-.:]|\.?\??,? ?)(?!['\-.:?, ]))+/)]), /^\|?(?=]])|^\|[^\S\n]*/, true, ([, ns], rest) => ns ? [['\n', ns[0].trimEnd()], rest.replace(visibility_1.blank.start, '')] : [[''], `^${rest}`], ([,, rest]) => [[''], `^${rest}`]));
|
|
6771
6770
|
function attributes(ns) {
|
|
6772
6771
|
switch (ns[0]) {
|
|
6773
6772
|
case '':
|
|
@@ -7630,7 +7629,7 @@ exports.stringify = stringify;
|
|
|
7630
7629
|
Object.defineProperty(exports, "__esModule", ({
|
|
7631
7630
|
value: true
|
|
7632
7631
|
}));
|
|
7633
|
-
exports.trimNodeEnd = exports.trimNode = exports.trimBlankStart = exports.trimBlank = exports.isStartTightNodes = exports.isStartLooseNodes = exports.startTight = exports.
|
|
7632
|
+
exports.trimNodeEnd = exports.trimNode = exports.trimBlankStart = exports.trimBlank = exports.isStartTightNodes = exports.isStartLooseNodes = exports.startTight = exports.blankWith = exports.visualize = exports.blank = void 0;
|
|
7634
7633
|
const parser_1 = __webpack_require__(6728);
|
|
7635
7634
|
const combinator_1 = __webpack_require__(2087);
|
|
7636
7635
|
const htmlentity_1 = __webpack_require__(1562);
|
|
@@ -7638,9 +7637,13 @@ const source_1 = __webpack_require__(6743);
|
|
|
7638
7637
|
const normalize_1 = __webpack_require__(185);
|
|
7639
7638
|
const memoize_1 = __webpack_require__(1808);
|
|
7640
7639
|
const array_1 = __webpack_require__(8112);
|
|
7640
|
+
var blank;
|
|
7641
|
+
(function (blank) {
|
|
7642
|
+
blank.line = new RegExp(/^(?:\\?[^\S\n]|&IHN;|<wbr[^\S\n]*>|\\$)+$/.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`), 'gm');
|
|
7643
|
+
blank.start = new RegExp(/^(?:\\?[^\S\n]|&IHN;|<wbr[^\S\n]*>)+/.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`));
|
|
7644
|
+
})(blank = exports.blank || (exports.blank = {}));
|
|
7641
7645
|
function visualize(parser) {
|
|
7642
|
-
|
|
7643
|
-
return (0, combinator_1.union)([(0, combinator_1.convert)(source => source.replace(blankline, line => line.replace(/[\\&<]/g, '\x1B$&')), (0, combinator_1.verify)(parser, (ns, rest, context) => !rest && hasVisible(ns, context))), (0, combinator_1.some)((0, combinator_1.union)([source_1.linebreak, source_1.unescsource]))]);
|
|
7646
|
+
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, context) => !rest && hasVisible(ns, context))), (0, combinator_1.some)((0, combinator_1.union)([source_1.linebreak, source_1.unescsource]))]);
|
|
7644
7647
|
}
|
|
7645
7648
|
exports.visualize = visualize;
|
|
7646
7649
|
function hasVisible(nodes, {
|
|
@@ -7657,27 +7660,11 @@ function hasVisible(nodes, {
|
|
|
7657
7660
|
}
|
|
7658
7661
|
return false;
|
|
7659
7662
|
}
|
|
7660
|
-
exports.regBlankStart = new RegExp(/^(?:\\?[^\S\n]|&IHN;|<wbr[^\S\n]*>)+/.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`));
|
|
7661
7663
|
function blankWith(starting, delimiter) {
|
|
7662
7664
|
if (delimiter === undefined) return blankWith('', starting);
|
|
7663
7665
|
return new RegExp(String.raw`^(?:(?=${starting})(?:\\?\s|&(?:${normalize_1.invisibleHTMLEntityNames.join('|')});|<wbr[^\S\n]*>)${starting && '+'})?${typeof delimiter === 'string' ? delimiter.replace(/[*+()\[\]]/g, '\\$&') : delimiter.source}`);
|
|
7664
7666
|
}
|
|
7665
7667
|
exports.blankWith = blankWith;
|
|
7666
|
-
function startLoose(parser, except) {
|
|
7667
|
-
return input => isStartLoose(input, except) ? parser(input) : undefined;
|
|
7668
|
-
}
|
|
7669
|
-
exports.startLoose = startLoose;
|
|
7670
|
-
const isStartLoose = (0, memoize_1.reduce)(({
|
|
7671
|
-
source,
|
|
7672
|
-
context
|
|
7673
|
-
}, except) => {
|
|
7674
|
-
return isStartTight({
|
|
7675
|
-
source: source.replace(exports.regBlankStart, ''),
|
|
7676
|
-
context
|
|
7677
|
-
}, except);
|
|
7678
|
-
}, ({
|
|
7679
|
-
source
|
|
7680
|
-
}, except = '') => `${source}\x1E${except}`);
|
|
7681
7668
|
function startTight(parser, except) {
|
|
7682
7669
|
return input => isStartTight(input, except) ? parser(input) : undefined;
|
|
7683
7670
|
}
|
|
@@ -7764,7 +7751,7 @@ function trimBlank(parser) {
|
|
|
7764
7751
|
}
|
|
7765
7752
|
exports.trimBlank = trimBlank;
|
|
7766
7753
|
function trimBlankStart(parser) {
|
|
7767
|
-
return (0, combinator_1.convert)(
|
|
7754
|
+
return (0, combinator_1.convert)(source => source.replace(blank.start, ''), parser);
|
|
7768
7755
|
}
|
|
7769
7756
|
exports.trimBlankStart = trimBlankStart;
|
|
7770
7757
|
function trimBlankEnd(parser) {
|
package/markdown.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Parser, Ctx, Context, check } from '../../data/parser';
|
|
2
2
|
|
|
3
|
-
export function convert<P extends Parser<unknown>>(conv: (source: string, context: Context<P>) => string, parser: P): P;
|
|
4
|
-
export function convert<T>(conv: (source: string, context: Ctx) => string, parser: Parser<T
|
|
3
|
+
export function convert<P extends Parser<unknown>>(conv: (source: string, context: Context<P>) => string, parser: P, empty?: boolean): P;
|
|
4
|
+
export function convert<T>(conv: (source: string, context: Ctx) => string, parser: Parser<T>, empty = false): Parser<T> {
|
|
5
5
|
assert(parser);
|
|
6
6
|
return ({ source, context }) => {
|
|
7
7
|
if (source === '') return;
|
|
8
8
|
const src = conv(source, context);
|
|
9
|
-
if (src === '') return [[], ''];
|
|
9
|
+
if (src === '') return empty ? [[], ''] : undefined;
|
|
10
10
|
context.offset ??= 0;
|
|
11
11
|
context.offset += source.length - src.length;
|
|
12
12
|
const result = parser({ source: src, context });
|
|
@@ -25,8 +25,8 @@ export function context<T>(base: Ctx, parser: Parser<T>): Parser<T> {
|
|
|
25
25
|
apply(parser, source, context, changes, values);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
function apply<P extends Parser<unknown>>(parser: P, source: string, context: Context<P>, changes: [string,
|
|
29
|
-
function apply<T>(parser: Parser<T>, source: string, context: Ctx, changes: [string,
|
|
28
|
+
function apply<P extends Parser<unknown>>(parser: P, source: string, context: Context<P>, changes: readonly [string, unknown][], values: unknown[], reset?: boolean): Result<Tree<P>>;
|
|
29
|
+
function apply<T>(parser: Parser<T>, source: string, context: Ctx, changes: readonly [string, unknown][], values: unknown[], reset = false): Result<T> {
|
|
30
30
|
if (context) for (let i = 0; i < changes.length; ++i) {
|
|
31
31
|
const change = changes[i];
|
|
32
32
|
const prop = change[0];
|
|
@@ -36,7 +36,7 @@ function apply<T>(parser: Parser<T>, source: string, context: Ctx, changes: [str
|
|
|
36
36
|
assert(typeof change[1] === 'object');
|
|
37
37
|
assert(context[prop] || !(prop in context));
|
|
38
38
|
if (prop in context && !hasOwnProperty(context, prop)) break;
|
|
39
|
-
context[prop as string] = ObjectCreate(change[1]);
|
|
39
|
+
context[prop as string] = ObjectCreate(change[1] as object);
|
|
40
40
|
break;
|
|
41
41
|
// @ts-expect-error
|
|
42
42
|
case 'memo':
|
|
@@ -12,7 +12,7 @@ export function inits<T, D extends Parser<T>[]>(parsers: D, resume?: (nodes: T[]
|
|
|
12
12
|
if (rest === '') break;
|
|
13
13
|
if (context.delimiters?.match(rest, context.precedence)) break;
|
|
14
14
|
const result = parsers[i]({ source: rest, context });
|
|
15
|
-
assert(check(rest, result));
|
|
15
|
+
assert(check(rest, result, false));
|
|
16
16
|
if (result === undefined) break;
|
|
17
17
|
nodes = nodes
|
|
18
18
|
? push(nodes, eval(result))
|
|
@@ -12,7 +12,7 @@ export function sequence<T, D extends Parser<T>[]>(parsers: D, resume?: (nodes:
|
|
|
12
12
|
if (rest === '') return;
|
|
13
13
|
if (context.delimiters?.match(rest, context.precedence)) return;
|
|
14
14
|
const result = parsers[i]({ source: rest, context });
|
|
15
|
-
assert(check(rest, result));
|
|
15
|
+
assert(check(rest, result, false));
|
|
16
16
|
if (result === undefined) return;
|
|
17
17
|
nodes = nodes
|
|
18
18
|
? push(nodes, eval(result))
|
|
@@ -22,10 +22,10 @@ const source: BlockquoteParser.SourceParser = lazy(() => fmap(
|
|
|
22
22
|
some(creation(1, false, union([
|
|
23
23
|
rewrite(
|
|
24
24
|
indent,
|
|
25
|
-
convert(unindent, source)),
|
|
25
|
+
convert(unindent, source, true)),
|
|
26
26
|
rewrite(
|
|
27
27
|
some(contentline, opener),
|
|
28
|
-
convert(unindent, fmap(autolink, ns => [html('pre', defrag(ns))]))),
|
|
28
|
+
convert(unindent, fmap(autolink, ns => [html('pre', defrag(ns))]), true)),
|
|
29
29
|
]))),
|
|
30
30
|
ns => [html('blockquote', ns)]));
|
|
31
31
|
|
|
@@ -33,7 +33,7 @@ const markdown: BlockquoteParser.MarkdownParser = lazy(() => fmap(
|
|
|
33
33
|
some(creation(1, false, union([
|
|
34
34
|
rewrite(
|
|
35
35
|
indent,
|
|
36
|
-
convert(unindent, markdown)),
|
|
36
|
+
convert(unindent, markdown, true)),
|
|
37
37
|
creation(99, false,
|
|
38
38
|
rewrite(
|
|
39
39
|
some(contentline, opener),
|
|
@@ -46,6 +46,6 @@ const markdown: BlockquoteParser.MarkdownParser = lazy(() => fmap(
|
|
|
46
46
|
},
|
|
47
47
|
}, context);
|
|
48
48
|
return [[html('section', [document, html('h2', 'References'), references])], ''];
|
|
49
|
-
}))),
|
|
49
|
+
}, true))),
|
|
50
50
|
]))),
|
|
51
51
|
ns => [html('blockquote', ns)]));
|
|
@@ -95,6 +95,42 @@ describe('Unit: parser/block/extension/table', () => {
|
|
|
95
95
|
]),
|
|
96
96
|
html('tfoot'),
|
|
97
97
|
]).outerHTML], '']);
|
|
98
|
+
assert.deepStrictEqual(
|
|
99
|
+
inspect(parser('~~~table\n:\n1\n~~~')),
|
|
100
|
+
[[html('table', [
|
|
101
|
+
html('thead'),
|
|
102
|
+
html('tbody', [
|
|
103
|
+
html('tr', [html('td', '1')]),
|
|
104
|
+
]),
|
|
105
|
+
html('tfoot'),
|
|
106
|
+
]).outerHTML], '']);
|
|
107
|
+
assert.deepStrictEqual(
|
|
108
|
+
inspect(parser('~~~table\n: \n1\n~~~')),
|
|
109
|
+
[[html('table', [
|
|
110
|
+
html('thead'),
|
|
111
|
+
html('tbody', [
|
|
112
|
+
html('tr', [html('td', '1')]),
|
|
113
|
+
]),
|
|
114
|
+
html('tfoot'),
|
|
115
|
+
]).outerHTML], '']);
|
|
116
|
+
assert.deepStrictEqual(
|
|
117
|
+
inspect(parser('~~~table\n: \n 1\n~~~')),
|
|
118
|
+
[[html('table', [
|
|
119
|
+
html('thead'),
|
|
120
|
+
html('tbody', [
|
|
121
|
+
html('tr', [html('td', ' 1')]),
|
|
122
|
+
]),
|
|
123
|
+
html('tfoot'),
|
|
124
|
+
]).outerHTML], '']);
|
|
125
|
+
assert.deepStrictEqual(
|
|
126
|
+
inspect(parser('~~~table\n: \n\n1\n~~~')),
|
|
127
|
+
[[html('table', [
|
|
128
|
+
html('thead'),
|
|
129
|
+
html('tbody', [
|
|
130
|
+
html('tr', [html('td'), html('td', '1')]),
|
|
131
|
+
]),
|
|
132
|
+
html('tfoot'),
|
|
133
|
+
]).outerHTML], '']);
|
|
98
134
|
assert.deepStrictEqual(
|
|
99
135
|
inspect(parser('~~~table\n\\ \n\\ \n~~~')),
|
|
100
136
|
[[html('table', [
|
|
@@ -491,7 +527,7 @@ describe('Unit: parser/block/extension/table', () => {
|
|
|
491
527
|
assert.deepStrictEqual(
|
|
492
528
|
inspect(parser([
|
|
493
529
|
'~~~table',
|
|
494
|
-
`-\n#
|
|
530
|
+
`-\n# 1\n${[...Array(32)].map((_, i) => `: ${i + 2}`).join('\n')}`,
|
|
495
531
|
`-\n#!+ 1\n${[...Array(32)].map((_, i) => `: ${i + 2}`).join('\n')}`,
|
|
496
532
|
'~~~'
|
|
497
533
|
].join('\n'))),
|
|
@@ -511,7 +547,7 @@ describe('Unit: parser/block/extension/table', () => {
|
|
|
511
547
|
assert.deepStrictEqual(
|
|
512
548
|
inspect(parser([
|
|
513
549
|
'~~~table',
|
|
514
|
-
`-\n${[...Array(32)].map((_, i) => `: ${i + 1}`).join('\n')}\n#
|
|
550
|
+
`-\n${[...Array(32)].map((_, i) => `: ${i + 1}`).join('\n')}\n# 33`,
|
|
515
551
|
`-\n${[...Array(32)].map((_, i) => `: ${i + 1}`).join('\n')}\n#!+ 33`,
|
|
516
552
|
'~~~'
|
|
517
553
|
].join('\n'))),
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { max, min, isArray } from 'spica/alias';
|
|
2
2
|
import { ExtensionParser } from '../../block';
|
|
3
3
|
import { Tree, eval } from '../../../combinator/data/parser';
|
|
4
|
-
import { union, subsequence, inits, some, creation, block, line, validate, fence, rewrite, open, clear, convert,
|
|
4
|
+
import { union, subsequence, inits, some, creation, block, line, validate, fence, rewrite, open, clear, convert, dup, lazy, fmap } from '../../../combinator';
|
|
5
5
|
import { inline } from '../../inline';
|
|
6
6
|
import { str, anyline, emptyline, contentline } from '../../source';
|
|
7
|
-
import { visualize } from '../../visibility';
|
|
7
|
+
import { visualize, trimBlankStart, trimNodeEnd } from '../../visibility';
|
|
8
8
|
import { unshift, splice } from 'spica/array';
|
|
9
9
|
import { html, define, defrag } from 'typed-dom/dom';
|
|
10
10
|
|
|
@@ -84,9 +84,9 @@ const head: CellParser.HeadParser = creation(1, false, block(fmap(open(
|
|
|
84
84
|
anyline,
|
|
85
85
|
some(contentline, delimiter),
|
|
86
86
|
]),
|
|
87
|
-
|
|
87
|
+
open(/^(?:\s*\n|\s)/, visualize(trimBlankStart(some(union([inline])))), true)),
|
|
88
88
|
true),
|
|
89
|
-
ns => [html('th', attributes(ns.shift()! as string), defrag(ns))]),
|
|
89
|
+
ns => [html('th', attributes(ns.shift()! as string), trimNodeEnd(defrag(ns)))]),
|
|
90
90
|
false));
|
|
91
91
|
|
|
92
92
|
const data: CellParser.DataParser = creation(1, false, block(fmap(open(
|
|
@@ -96,9 +96,9 @@ const data: CellParser.DataParser = creation(1, false, block(fmap(open(
|
|
|
96
96
|
anyline,
|
|
97
97
|
some(contentline, delimiter),
|
|
98
98
|
]),
|
|
99
|
-
|
|
99
|
+
open(/^(?:\s*\n|\s)/, visualize(some(union([inline]))), true)),
|
|
100
100
|
true),
|
|
101
|
-
ns => [html('td', attributes(ns.shift()! as string), defrag(ns))]),
|
|
101
|
+
ns => [html('td', attributes(ns.shift()! as string), trimNodeEnd(defrag(ns)))]),
|
|
102
102
|
false));
|
|
103
103
|
|
|
104
104
|
const dataline: CellParser.DatalineParser = creation(1, false, line(
|
|
@@ -9,7 +9,6 @@ import { contentline } from '../source';
|
|
|
9
9
|
import { State } from '../context';
|
|
10
10
|
import { visualize, trimBlank } from '../visibility';
|
|
11
11
|
import { memoize } from 'spica/memoize';
|
|
12
|
-
import { shift } from 'spica/array';
|
|
13
12
|
import { html, define, defrag } from 'typed-dom/dom';
|
|
14
13
|
|
|
15
14
|
const openers = {
|
|
@@ -38,17 +37,16 @@ const list = (type: string, form: string): OListParser.ListParser => fmap(
|
|
|
38
37
|
some(creation(1, false, union([
|
|
39
38
|
indexee(fmap(fallback(
|
|
40
39
|
inits([
|
|
41
|
-
line(open(heads[form], subsequence([checkbox, union([
|
|
42
|
-
|
|
40
|
+
line(open(heads[form], subsequence([checkbox, trim(union([
|
|
41
|
+
fmap(close(union([index]), /^$/), ([el]) => [
|
|
43
42
|
define(el, { class: void el.classList.add('indexer'), 'data-index': '' })
|
|
44
|
-
])
|
|
45
|
-
trimBlank(
|
|
46
|
-
])]), true)),
|
|
43
|
+
]),
|
|
44
|
+
visualize(trimBlank(some(union([indexer, inline])))),
|
|
45
|
+
]))]), true)),
|
|
47
46
|
indent(union([ulist_, olist_, ilist_])),
|
|
48
47
|
]),
|
|
49
48
|
invalid),
|
|
50
|
-
|
|
51
|
-
[html('li', { 'data-marker': ns[0] || undefined }, defrag(fillFirstLine(shift(ns)[1])))]), true),
|
|
49
|
+
ns => [html('li', { 'data-marker': ns.shift() as string || undefined }, defrag(fillFirstLine(ns)))]), true),
|
|
52
50
|
]))),
|
|
53
51
|
es => [format(html('ol', es), type, form)]);
|
|
54
52
|
|
|
@@ -23,9 +23,9 @@ const source: SidefenceParser.SourceParser = lazy(() => fmap(
|
|
|
23
23
|
some(creation(1, false, union([
|
|
24
24
|
focus(
|
|
25
25
|
/^(?:\|\|+(?:[^\S\n][^\n]*)?(?:$|\n))+/,
|
|
26
|
-
convert(unindent, source)),
|
|
26
|
+
convert(unindent, source, true)),
|
|
27
27
|
rewrite(
|
|
28
28
|
some(contentline, opener),
|
|
29
|
-
convert(unindent, fmap(autolink, ns => [html('pre', defrag(ns))]))),
|
|
29
|
+
convert(unindent, fmap(autolink, ns => [html('pre', defrag(ns))]), true)),
|
|
30
30
|
]))),
|
|
31
31
|
ns => [html('blockquote', ns)]));
|
|
@@ -2,7 +2,7 @@ import { TableParser } from '../block';
|
|
|
2
2
|
import { union, sequence, some, creation, block, line, validate, focus, rewrite, surround, open, fallback, lazy, fmap } from '../../combinator';
|
|
3
3
|
import { inline } from '../inline';
|
|
4
4
|
import { contentline } from '../source';
|
|
5
|
-
import {
|
|
5
|
+
import { trimBlankStart, trimNodeEnd } from '../visibility';
|
|
6
6
|
import { duffReduce } from 'spica/duff';
|
|
7
7
|
import { push } from 'spica/array';
|
|
8
8
|
import { html, defrag } from 'typed-dom/dom';
|
|
@@ -49,16 +49,16 @@ const align: AlignParser = creation(1, false, fmap(open(
|
|
|
49
49
|
|
|
50
50
|
const cell: CellParser = surround(
|
|
51
51
|
/^\|\s*(?=\S)/,
|
|
52
|
-
some(union([inline]), /^\|/, [[/^[|\\]?\s*$/, 9]]),
|
|
52
|
+
trimBlankStart(some(union([inline]), /^\|/, [[/^[|\\]?\s*$/, 9]])),
|
|
53
53
|
/^[^|]*/, true);
|
|
54
54
|
|
|
55
55
|
const head: CellParser.HeadParser = creation(1, false, fmap(
|
|
56
56
|
cell,
|
|
57
|
-
ns => [html('th',
|
|
57
|
+
ns => [html('th', trimNodeEnd(defrag(ns)))]));
|
|
58
58
|
|
|
59
59
|
const data: CellParser.DataParser = creation(1, false, fmap(
|
|
60
60
|
cell,
|
|
61
|
-
ns => [html('td',
|
|
61
|
+
ns => [html('td', trimNodeEnd(defrag(ns)))]));
|
|
62
62
|
|
|
63
63
|
function format(rows: HTMLTableRowElement[]): HTMLTableRowElement[] {
|
|
64
64
|
const aligns = rows[0].className === 'invalid'
|
|
@@ -19,12 +19,12 @@ 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([checkbox, union([
|
|
23
|
-
|
|
22
|
+
line(open(/^-(?:$|\s)/, subsequence([checkbox, trim(union([
|
|
23
|
+
fmap(close(union([index]), /^$/), ([el]) => [
|
|
24
24
|
define(el, { class: void el.classList.add('indexer'), 'data-index': '' })
|
|
25
|
-
])
|
|
26
|
-
trimBlank(
|
|
27
|
-
])]), true)),
|
|
25
|
+
]),
|
|
26
|
+
visualize(trimBlank(some(union([indexer, inline])))),
|
|
27
|
+
]))]), true)),
|
|
28
28
|
indent(union([ulist_, olist_, ilist_])),
|
|
29
29
|
]),
|
|
30
30
|
invalid),
|
|
@@ -2,15 +2,14 @@ import { AnnotationParser } from '../inline';
|
|
|
2
2
|
import { union, some, syntax, constraint, surround, lazy } from '../../combinator';
|
|
3
3
|
import { inline } from '../inline';
|
|
4
4
|
import { Syntax, State } from '../context';
|
|
5
|
-
import {
|
|
5
|
+
import { trimBlankStart, trimNodeEnd } from '../visibility';
|
|
6
6
|
import { html, defrag } from 'typed-dom/dom';
|
|
7
7
|
|
|
8
8
|
export const annotation: AnnotationParser = lazy(() => surround(
|
|
9
9
|
'((',
|
|
10
10
|
constraint(State.annotation, false,
|
|
11
11
|
syntax(Syntax.none, 6, 1, State.annotation | State.media,
|
|
12
|
-
|
|
13
|
-
some(union([inline]), ')', [[/^\\?\n/, 9], [')', 2], ['))', 6]]), ')'))),
|
|
12
|
+
trimBlankStart(some(union([inline]), ')', [[/^\\?\n/, 9], [')', 2], ['))', 6]])))),
|
|
14
13
|
'))',
|
|
15
14
|
false,
|
|
16
|
-
([, ns], rest) => [[html('sup', { class: 'annotation' }, [html('span',
|
|
15
|
+
([, ns], rest) => [[html('sup', { class: 'annotation' }, [html('span', trimNodeEnd(defrag(ns)))])], rest]));
|
|
@@ -83,6 +83,7 @@ const TAGS = Object.freeze([
|
|
|
83
83
|
"footer",
|
|
84
84
|
"header",
|
|
85
85
|
"h1", "h2", "h3", "h4", "h5", "h6",
|
|
86
|
+
"hgroup",
|
|
86
87
|
"main",
|
|
87
88
|
"nav",
|
|
88
89
|
"section",
|
|
@@ -179,7 +180,6 @@ const TAGS = Object.freeze([
|
|
|
179
180
|
"template",
|
|
180
181
|
"acronym",
|
|
181
182
|
"applet",
|
|
182
|
-
"basefont",
|
|
183
183
|
"bgsound",
|
|
184
184
|
"big",
|
|
185
185
|
"blink",
|
|
@@ -189,7 +189,6 @@ const TAGS = Object.freeze([
|
|
|
189
189
|
"font",
|
|
190
190
|
"frame",
|
|
191
191
|
"frameset",
|
|
192
|
-
"hgroup",
|
|
193
192
|
"image",
|
|
194
193
|
"keygen",
|
|
195
194
|
"marquee",
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import { ReferenceParser } from '../inline';
|
|
2
|
-
import { union, subsequence, some, syntax, creation, constraint, surround, lazy
|
|
2
|
+
import { union, subsequence, some, syntax, creation, constraint, surround, lazy } from '../../combinator';
|
|
3
3
|
import { inline } from '../inline';
|
|
4
4
|
import { str } from '../source';
|
|
5
5
|
import { Syntax, State } from '../context';
|
|
6
|
-
import {
|
|
6
|
+
import { blank, trimBlankStart, trimNodeEnd } from '../visibility';
|
|
7
7
|
import { html, defrag } from 'typed-dom/dom';
|
|
8
8
|
|
|
9
9
|
export const reference: ReferenceParser = lazy(() => surround(
|
|
10
10
|
'[[',
|
|
11
11
|
constraint(State.reference, false,
|
|
12
12
|
syntax(Syntax.reference, 6, 1, State.annotation | State.reference | State.media,
|
|
13
|
-
startLoose(
|
|
14
13
|
subsequence([
|
|
15
14
|
abbr,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
]), ']'))),
|
|
15
|
+
trimBlankStart(some(inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]])),
|
|
16
|
+
]))),
|
|
19
17
|
']]',
|
|
20
18
|
false,
|
|
21
|
-
([, ns], rest) => [[html('sup', attributes(ns), [html('span',
|
|
19
|
+
([, ns], rest) => [[html('sup', attributes(ns), [html('span', trimNodeEnd(defrag(ns)))])], rest]));
|
|
22
20
|
|
|
23
21
|
// Chicago-Style
|
|
24
|
-
const abbr: ReferenceParser.AbbrParser = creation(
|
|
22
|
+
const abbr: ReferenceParser.AbbrParser = creation(surround(
|
|
25
23
|
'^',
|
|
26
24
|
union([str(/^(?=[A-Z])(?:[0-9A-Za-z]'?|(?:[-.:]|\.?\??,? ?)(?!['\-.:?, ]))+/)]),
|
|
27
|
-
/^\|?(?=]])|^\|[^\S\n]
|
|
28
|
-
|
|
25
|
+
/^\|?(?=]])|^\|[^\S\n]*/,
|
|
26
|
+
true,
|
|
27
|
+
([, ns], rest) => ns ? [['\n', ns[0].trimEnd()], rest.replace(blank.start, '')] : [[''], `^${rest}`],
|
|
28
|
+
([, , rest]) => [[''], `^${rest}`]));
|
|
29
29
|
|
|
30
30
|
function attributes(ns: (string | HTMLElement)[]): Record<string, string | undefined> {
|
|
31
31
|
switch (ns[0]) {
|
package/src/parser/visibility.ts
CHANGED
|
@@ -8,14 +8,21 @@ import { invisibleHTMLEntityNames } from './api/normalize';
|
|
|
8
8
|
import { reduce } from 'spica/memoize';
|
|
9
9
|
import { push } from 'spica/array';
|
|
10
10
|
|
|
11
|
+
export namespace blank {
|
|
12
|
+
export const line = new RegExp(
|
|
13
|
+
/^(?:\\?[^\S\n]|&IHN;|<wbr[^\S\n]*>|\\$)+$/.source
|
|
14
|
+
.replace('IHN', `(?:${invisibleHTMLEntityNames.join('|')})`),
|
|
15
|
+
'gm');
|
|
16
|
+
export const start = new RegExp(
|
|
17
|
+
/^(?:\\?[^\S\n]|&IHN;|<wbr[^\S\n]*>)+/.source
|
|
18
|
+
.replace('IHN', `(?:${invisibleHTMLEntityNames.join('|')})`));
|
|
19
|
+
}
|
|
20
|
+
|
|
11
21
|
export function visualize<P extends Parser<HTMLElement | string>>(parser: P): P;
|
|
12
22
|
export function visualize<T extends HTMLElement | string>(parser: Parser<T>): Parser<T> {
|
|
13
|
-
const blankline = new RegExp(
|
|
14
|
-
/^(?:\\$|\\?[^\S\n]|&IHN;|<wbr[^\S\n]*>)+$/.source.replace('IHN', `(?:${invisibleHTMLEntityNames.join('|')})`),
|
|
15
|
-
'gm');
|
|
16
23
|
return union([
|
|
17
24
|
convert(
|
|
18
|
-
source => source.replace(
|
|
25
|
+
source => source.replace(blank.line, line => line.replace(/[\\&<]/g, '\x1B$&')),
|
|
19
26
|
verify(parser, (ns, rest, context) => !rest && hasVisible(ns, context))),
|
|
20
27
|
some(union([linebreak, unescsource])),
|
|
21
28
|
]);
|
|
@@ -38,9 +45,6 @@ function hasVisible(
|
|
|
38
45
|
return false;
|
|
39
46
|
}
|
|
40
47
|
|
|
41
|
-
export const regBlankStart = new RegExp(
|
|
42
|
-
/^(?:\\?[^\S\n]|&IHN;|<wbr[^\S\n]*>)+/.source.replace('IHN', `(?:${invisibleHTMLEntityNames.join('|')})`));
|
|
43
|
-
|
|
44
48
|
export function blankWith(delimiter: string | RegExp): RegExp;
|
|
45
49
|
export function blankWith(starting: '' | '\n', delimiter: string | RegExp): RegExp;
|
|
46
50
|
export function blankWith(starting: '' | '\n', delimiter?: string | RegExp): RegExp {
|
|
@@ -53,16 +57,16 @@ export function blankWith(starting: '' | '\n', delimiter?: string | RegExp): Reg
|
|
|
53
57
|
}`);
|
|
54
58
|
}
|
|
55
59
|
|
|
56
|
-
export function startLoose<P extends Parser<HTMLElement | string>>(parser: P, except?: string): P;
|
|
57
|
-
export function startLoose<T extends HTMLElement | string>(parser: Parser<T>, except?: string): Parser<T> {
|
|
58
|
-
return input =>
|
|
59
|
-
isStartLoose(input, except)
|
|
60
|
-
? parser(input)
|
|
61
|
-
: undefined;
|
|
62
|
-
}
|
|
63
|
-
const isStartLoose = reduce(({ source, context }: Input<MarkdownParser.Context>, except?: string): boolean => {
|
|
64
|
-
return isStartTight({ source: source.replace(
|
|
65
|
-
}, ({ source }, except = '') => `${source}\x1E${except}`);
|
|
60
|
+
//export function startLoose<P extends Parser<HTMLElement | string>>(parser: P, except?: string): P;
|
|
61
|
+
//export function startLoose<T extends HTMLElement | string>(parser: Parser<T>, except?: string): Parser<T> {
|
|
62
|
+
// return input =>
|
|
63
|
+
// isStartLoose(input, except)
|
|
64
|
+
// ? parser(input)
|
|
65
|
+
// : undefined;
|
|
66
|
+
//}
|
|
67
|
+
//const isStartLoose = reduce(({ source, context }: Input<MarkdownParser.Context>, except?: string): boolean => {
|
|
68
|
+
// return isStartTight({ source: source.replace(blank.start, ''), context }, except);
|
|
69
|
+
//}, ({ source }, except = '') => `${source}\x1E${except}`);
|
|
66
70
|
|
|
67
71
|
export function startTight<P extends Parser<unknown>>(parser: P, except?: string): P;
|
|
68
72
|
export function startTight<T>(parser: Parser<T>, except?: string): Parser<T> {
|
|
@@ -154,7 +158,7 @@ export function trimBlank<T extends HTMLElement | string>(parser: Parser<T>): Pa
|
|
|
154
158
|
export function trimBlankStart<P extends Parser<unknown>>(parser: P): P;
|
|
155
159
|
export function trimBlankStart<T>(parser: Parser<T>): Parser<T> {
|
|
156
160
|
return convert(
|
|
157
|
-
|
|
161
|
+
source => source.replace(blank.start, ''),
|
|
158
162
|
parser);
|
|
159
163
|
}
|
|
160
164
|
function trimBlankEnd<P extends Parser<HTMLElement | string>>(parser: P): P;
|