securemark 0.276.1 → 0.276.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 +39 -42
- package/package.json +4 -4
- package/src/combinator/control/manipulation/fence.ts +1 -1
- package/src/parser/inline/link.ts +13 -13
- package/src/parser/inline/ruby.ts +1 -1
- package/src/parser/visibility.ts +17 -17
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.276.
|
|
1
|
+
/*! securemark v0.276.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("Prism"), require("DOMPurify"));
|
|
@@ -2860,7 +2860,7 @@ function fence(opener, limit, separation = true) {
|
|
|
2860
2860
|
const matches = source.match(opener);
|
|
2861
2861
|
if (!matches) return;
|
|
2862
2862
|
const delim = matches[1];
|
|
2863
|
-
if (matches[0].
|
|
2863
|
+
if (matches[0].includes(delim, delim.length)) return;
|
|
2864
2864
|
let rest = source.slice(matches[0].length);
|
|
2865
2865
|
// Prevent annoying parsing in editing.
|
|
2866
2866
|
if ((0, line_1.isBlank)((0, line_1.firstline)(rest)) && (0, line_1.firstline)(rest.slice((0, line_1.firstline)(rest).length)).trimEnd() !== delim) return;
|
|
@@ -6506,21 +6506,20 @@ const optspec = {
|
|
|
6506
6506
|
};
|
|
6507
6507
|
Object.setPrototypeOf(optspec, null);
|
|
6508
6508
|
exports.link = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['[', '{'], (0, combinator_1.union)([exports.medialink, exports.textlink])));
|
|
6509
|
-
exports.textlink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(16 /* State.link */, false, (0, combinator_1.syntax)(16 /* Syntax.link */, 2, 10, 502 /* State.linkers */ | 8 /* State.media */, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [[/^\\?\n/, 9], [']', 2]]), ']', true)), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])), ([params, content = []], rest, context) => {
|
|
6510
|
-
|
|
6509
|
+
exports.textlink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(16 /* State.link */, false, (0, combinator_1.syntax)(16 /* Syntax.link */, 2, 10, 502 /* State.linkers */ | 8 /* State.media */, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [[/^\\?\n/, 9], [']', 2]])), ']', true)), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])), ([params, content = []], rest, context) => {
|
|
6510
|
+
if (content.length !== 0 && (0, visibility_1.trimNodeEnd)(content = (0, dom_1.defrag)(content)).length === 0) return;
|
|
6511
|
+
return [[parse(content, params, context)], rest];
|
|
6511
6512
|
}))));
|
|
6512
|
-
exports.medialink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(16 /* State.link */ | 8 /* State.media */, false, (0, combinator_1.syntax)(16 /* Syntax.link */, 2, 10, 502 /* State.linkers */, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.sequence)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.union)([inline_1.media, inline_1.shortmedia]), ']')), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])), ([params, content = []], rest, context) => parse(content, params,
|
|
6513
|
+
exports.medialink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(16 /* State.link */ | 8 /* State.media */, false, (0, combinator_1.syntax)(16 /* Syntax.link */, 2, 10, 502 /* State.linkers */, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.sequence)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.union)([inline_1.media, inline_1.shortmedia]), ']')), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])), ([params, content = []], rest, context) => [[parse((0, dom_1.defrag)(content), params, context)], rest]))));
|
|
6513
6514
|
exports.linemedialink = (0, combinator_1.surround)(source_1.linebreak, (0, combinator_1.union)([exports.medialink]), /^(?=[^\S\n]*(?:$|\n))/);
|
|
6514
|
-
exports.unsafelink = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(10, (0, combinator_1.precedence)(2, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.some)((0, combinator_1.union)([source_1.unescsource]), ']'), ']')), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])), ([params, content = []], rest, context) => parse(content, params,
|
|
6515
|
+
exports.unsafelink = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(10, (0, combinator_1.precedence)(2, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.some)((0, combinator_1.union)([source_1.unescsource]), ']'), ']')), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])), ([params, content = []], rest, context) => [[parse((0, dom_1.defrag)(content), params, context)], rest]))));
|
|
6515
6516
|
exports.uri = (0, combinator_1.union)([(0, combinator_1.open)(/^[^\S\n]+/, (0, source_1.str)(/^\S+/)), (0, source_1.str)(/^[^\s{}]+/)]);
|
|
6516
6517
|
exports.option = (0, combinator_1.union)([(0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+nofollow(?=[^\S\n]|})/), () => [` rel="nofollow"`]), (0, source_1.str)(/^[^\S\n]+[a-z]+(?:-[a-z]+)*(?:="(?:\\[^\n]|[^\\\n"])*")?(?=[^\S\n]|})/), (0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+[^\s{}]+/), opt => [` \\${opt.slice(1)}`])]);
|
|
6517
|
-
function parse(content, params,
|
|
6518
|
-
if (content.length !== 0 && (0, visibility_1.trimNode)(content).length === 0) return;
|
|
6518
|
+
function parse(content, params, context) {
|
|
6519
6519
|
const INSECURE_URI = params.shift();
|
|
6520
6520
|
const uri = new url_1.ReadonlyURL(resolve(INSECURE_URI, context.host ?? location, context.url ?? context.host ?? location), context.host?.href || location.href);
|
|
6521
|
-
const el = elem(INSECURE_URI,
|
|
6522
|
-
|
|
6523
|
-
return [[(0, dom_1.define)(el, (0, html_1.attributes)('link', [], optspec, params))], rest];
|
|
6521
|
+
const el = elem(INSECURE_URI, content, uri, context.host?.origin || location.origin);
|
|
6522
|
+
return el.className === 'invalid' ? el : (0, dom_1.define)(el, (0, html_1.attributes)('link', [], optspec, params));
|
|
6524
6523
|
}
|
|
6525
6524
|
function elem(INSECURE_URI, content, uri, origin) {
|
|
6526
6525
|
let type;
|
|
@@ -6871,7 +6870,7 @@ function attributes(texts, rubies) {
|
|
|
6871
6870
|
let attrs;
|
|
6872
6871
|
for (const ss of [texts, rubies]) {
|
|
6873
6872
|
for (let i = 0; i < ss.length; ++i) {
|
|
6874
|
-
if (ss[i].
|
|
6873
|
+
if (!ss[i].includes('\x1B')) continue;
|
|
6875
6874
|
ss[i] = ss[i].replace(/\x1B/g, '');
|
|
6876
6875
|
attrs ??= {
|
|
6877
6876
|
class: 'invalid',
|
|
@@ -7629,7 +7628,7 @@ exports.stringify = stringify;
|
|
|
7629
7628
|
Object.defineProperty(exports, "__esModule", ({
|
|
7630
7629
|
value: true
|
|
7631
7630
|
}));
|
|
7632
|
-
exports.trimNodeEnd = exports.
|
|
7631
|
+
exports.trimNodeEnd = exports.trimBlankStart = exports.trimBlank = exports.isStartTightNodes = exports.isStartLooseNodes = exports.startTight = exports.blankWith = exports.visualize = exports.blank = void 0;
|
|
7633
7632
|
const parser_1 = __webpack_require__(6728);
|
|
7634
7633
|
const combinator_1 = __webpack_require__(2087);
|
|
7635
7634
|
const htmlentity_1 = __webpack_require__(1562);
|
|
@@ -7757,24 +7756,23 @@ exports.trimBlankStart = trimBlankStart;
|
|
|
7757
7756
|
function trimBlankEnd(parser) {
|
|
7758
7757
|
return (0, combinator_1.fmap)(parser, trimNodeEnd);
|
|
7759
7758
|
}
|
|
7760
|
-
function trimNode(nodes) {
|
|
7761
|
-
return trimNodeStart(trimNodeEnd(nodes));
|
|
7762
|
-
}
|
|
7763
|
-
|
|
7764
|
-
|
|
7765
|
-
|
|
7766
|
-
if (
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
|
|
7777
|
-
}
|
|
7759
|
+
//export function trimNode<T extends HTMLElement | string>(nodes: T[]): T[] {
|
|
7760
|
+
// return trimNodeStart(trimNodeEnd(nodes));
|
|
7761
|
+
//}
|
|
7762
|
+
//function trimNodeStart<T extends HTMLElement | string>(nodes: T[]): T[] {
|
|
7763
|
+
// for (let node = nodes[0]; nodes.length > 0 && !isVisible(node = nodes[0], 0);) {
|
|
7764
|
+
// if (nodes.length === 1 && typeof node === 'object' && node.className === 'indexer') break;
|
|
7765
|
+
// if (typeof node === 'string') {
|
|
7766
|
+
// const pos = node.trimStart().length;
|
|
7767
|
+
// if (pos > 0) {
|
|
7768
|
+
// nodes[0] = node.slice(-pos) as T;
|
|
7769
|
+
// break;
|
|
7770
|
+
// }
|
|
7771
|
+
// }
|
|
7772
|
+
// nodes.shift();
|
|
7773
|
+
// }
|
|
7774
|
+
// return nodes;
|
|
7775
|
+
//}
|
|
7778
7776
|
function trimNodeEnd(nodes) {
|
|
7779
7777
|
const skip = nodes.length > 0 && typeof nodes[nodes.length - 1] === 'object' && nodes[nodes.length - 1]['className'] === 'indexer' ? [nodes.pop()] : [];
|
|
7780
7778
|
for (let node = nodes[0]; nodes.length > 0 && !isVisible(node = nodes[nodes.length - 1], -1);) {
|
|
@@ -8433,7 +8431,7 @@ function unlink(h) {
|
|
|
8433
8431
|
/***/ 3252:
|
|
8434
8432
|
/***/ (function(module) {
|
|
8435
8433
|
|
|
8436
|
-
/*! typed-dom v0.0.
|
|
8434
|
+
/*! typed-dom v0.0.334 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
|
|
8437
8435
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
8438
8436
|
if(true)
|
|
8439
8437
|
module.exports = factory();
|
|
@@ -8710,15 +8708,14 @@ exports.prepend = prepend;
|
|
|
8710
8708
|
function defrag(nodes) {
|
|
8711
8709
|
const acc = [];
|
|
8712
8710
|
let appendable = false;
|
|
8713
|
-
for (let i = 0
|
|
8711
|
+
for (let i = 0, len = nodes.length; i < len; ++i) {
|
|
8714
8712
|
const node = nodes[i];
|
|
8715
|
-
if (node === '')
|
|
8716
|
-
if (typeof node === 'string') {
|
|
8717
|
-
appendable ? acc[acc.length - 1] += node : acc.push(node);
|
|
8718
|
-
appendable = true;
|
|
8719
|
-
} else {
|
|
8713
|
+
if (typeof node === 'object') {
|
|
8720
8714
|
acc.push(node);
|
|
8721
8715
|
appendable = false;
|
|
8716
|
+
} else if (node !== '') {
|
|
8717
|
+
appendable ? acc[acc.length - 1] += node : acc.push(node);
|
|
8718
|
+
appendable = true;
|
|
8722
8719
|
}
|
|
8723
8720
|
}
|
|
8724
8721
|
return acc;
|
|
@@ -8733,7 +8730,7 @@ exports.defrag = defrag;
|
|
|
8733
8730
|
/******/ var __webpack_module_cache__ = {};
|
|
8734
8731
|
/******/
|
|
8735
8732
|
/******/ // The require function
|
|
8736
|
-
/******/ function
|
|
8733
|
+
/******/ function __nested_webpack_require_11654__(moduleId) {
|
|
8737
8734
|
/******/ // Check if module is in cache
|
|
8738
8735
|
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
8739
8736
|
/******/ if (cachedModule !== undefined) {
|
|
@@ -8747,7 +8744,7 @@ exports.defrag = defrag;
|
|
|
8747
8744
|
/******/ };
|
|
8748
8745
|
/******/
|
|
8749
8746
|
/******/ // Execute the module function
|
|
8750
|
-
/******/ __webpack_modules__[moduleId](module, module.exports,
|
|
8747
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_11654__);
|
|
8751
8748
|
/******/
|
|
8752
8749
|
/******/ // Return the exports of the module
|
|
8753
8750
|
/******/ return module.exports;
|
|
@@ -8758,7 +8755,7 @@ exports.defrag = defrag;
|
|
|
8758
8755
|
/******/ // startup
|
|
8759
8756
|
/******/ // Load entry module and return exports
|
|
8760
8757
|
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
8761
|
-
/******/ var __nested_webpack_exports__ =
|
|
8758
|
+
/******/ var __nested_webpack_exports__ = __nested_webpack_require_11654__(7521);
|
|
8762
8759
|
/******/
|
|
8763
8760
|
/******/ return __nested_webpack_exports__;
|
|
8764
8761
|
/******/ })()
|
|
@@ -8770,7 +8767,7 @@ exports.defrag = defrag;
|
|
|
8770
8767
|
/***/ 6120:
|
|
8771
8768
|
/***/ (function(module) {
|
|
8772
8769
|
|
|
8773
|
-
/*! typed-dom v0.0.
|
|
8770
|
+
/*! typed-dom v0.0.334 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
|
|
8774
8771
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
8775
8772
|
if(true)
|
|
8776
8773
|
module.exports = factory();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "securemark",
|
|
3
|
-
"version": "0.276.
|
|
3
|
+
"version": "0.276.2",
|
|
4
4
|
"description": "Secure markdown renderer working on browsers for user input data.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://github.com/falsandtru/securemark",
|
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
"karma-power-assert": "^1.0.0",
|
|
51
51
|
"mocha": "^10.2.0",
|
|
52
52
|
"npm-check-updates": "^16.10.12",
|
|
53
|
-
"semver": "^7.5.
|
|
53
|
+
"semver": "^7.5.1",
|
|
54
54
|
"spica": "0.0.721",
|
|
55
55
|
"ts-loader": "^9.4.2",
|
|
56
|
-
"typed-dom": "
|
|
56
|
+
"typed-dom": "0.0.334",
|
|
57
57
|
"typescript": "5.0.4",
|
|
58
|
-
"webpack": "^5.82.
|
|
58
|
+
"webpack": "^5.82.1",
|
|
59
59
|
"webpack-cli": "^5.1.1",
|
|
60
60
|
"webpack-merge": "^5.8.0"
|
|
61
61
|
},
|
|
@@ -10,7 +10,7 @@ export function fence<C extends Ctx, D extends Parser<unknown, C>[]>(opener: Reg
|
|
|
10
10
|
assert(matches[0] === firstline(source));
|
|
11
11
|
const delim = matches[1];
|
|
12
12
|
assert(delim && delim === delim.trim());
|
|
13
|
-
if (matches[0].
|
|
13
|
+
if (matches[0].includes(delim, delim.length)) return;
|
|
14
14
|
let rest = source.slice(matches[0].length);
|
|
15
15
|
// Prevent annoying parsing in editing.
|
|
16
16
|
if (isBlank(firstline(rest)) && firstline(rest.slice(firstline(rest).length)).trimEnd() !== delim) return;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { MarkdownParser } from '../../../markdown';
|
|
2
2
|
import { LinkParser } from '../inline';
|
|
3
|
-
import { Result } from '../../combinator/data/parser';
|
|
4
3
|
import { union, inits, tails, sequence, some, constraint, syntax, creation, precedence, validate, surround, open, dup, reverse, lazy, fmap, bind } from '../../combinator';
|
|
5
4
|
import { inline, media, shortmedia } from '../inline';
|
|
6
5
|
import { attributes } from './html';
|
|
7
6
|
import { linebreak, unescsource, str } from '../source';
|
|
8
7
|
import { Syntax, State } from '../context';
|
|
9
|
-
import {
|
|
8
|
+
import { trimBlankStart, trimNodeEnd } from '../visibility';
|
|
10
9
|
import { stringify } from '../util';
|
|
11
10
|
import { ReadonlyURL } from 'spica/url';
|
|
12
11
|
import { html, define, defrag } from 'typed-dom/dom';
|
|
@@ -27,14 +26,16 @@ export const textlink: LinkParser.TextLinkParser = lazy(() =>
|
|
|
27
26
|
bind(reverse(tails([
|
|
28
27
|
dup(surround(
|
|
29
28
|
'[',
|
|
30
|
-
some(union([inline]), ']', [[/^\\?\n/, 9], [']', 2]]),
|
|
29
|
+
trimBlankStart(some(union([inline]), ']', [[/^\\?\n/, 9], [']', 2]])),
|
|
31
30
|
']',
|
|
32
31
|
true)),
|
|
33
32
|
dup(surround(/^{(?![{}])/, inits([uri, some(option)]), /^[^\S\n]*}/)),
|
|
34
33
|
])),
|
|
35
34
|
([params, content = []]: [string[], (HTMLElement | string)[]], rest, context) => {
|
|
36
35
|
assert(!html('div', content).querySelector('a, .media, .annotation, .reference'));
|
|
37
|
-
|
|
36
|
+
assert(content[0] !== '');
|
|
37
|
+
if (content.length !== 0 && trimNodeEnd(content = defrag(content)).length === 0) return;
|
|
38
|
+
return [[parse(content, params, context)], rest];
|
|
38
39
|
}))));
|
|
39
40
|
|
|
40
41
|
export const medialink: LinkParser.MediaLinkParser = lazy(() =>
|
|
@@ -48,7 +49,7 @@ export const medialink: LinkParser.MediaLinkParser = lazy(() =>
|
|
|
48
49
|
dup(surround(/^{(?![{}])/, inits([uri, some(option)]), /^[^\S\n]*}/)),
|
|
49
50
|
])),
|
|
50
51
|
([params, content = []]: [string[], (HTMLElement | string)[]], rest, context) =>
|
|
51
|
-
parse(content, params,
|
|
52
|
+
[[parse(defrag(content), params, context)], rest]))));
|
|
52
53
|
|
|
53
54
|
export const linemedialink: LinkParser.LineMediaLinkParser = surround(
|
|
54
55
|
linebreak,
|
|
@@ -65,7 +66,7 @@ export const unsafelink: LinkParser.UnsafeLinkParser = lazy(() =>
|
|
|
65
66
|
dup(surround(/^{(?![{}])/, inits([uri, some(option)]), /^[^\S\n]*}/)),
|
|
66
67
|
])),
|
|
67
68
|
([params, content = []], rest, context) =>
|
|
68
|
-
parse(content, params,
|
|
69
|
+
[[parse(defrag(content), params, context)], rest]))));
|
|
69
70
|
|
|
70
71
|
export const uri: LinkParser.ParameterParser.UriParser = union([
|
|
71
72
|
open(/^[^\S\n]+/, str(/^\S+/)),
|
|
@@ -79,14 +80,12 @@ export const option: LinkParser.ParameterParser.OptionParser = union([
|
|
|
79
80
|
]);
|
|
80
81
|
|
|
81
82
|
function parse(
|
|
82
|
-
content: (string | HTMLElement)[],
|
|
83
|
+
content: readonly (string | HTMLElement)[],
|
|
83
84
|
params: string[],
|
|
84
|
-
rest: string,
|
|
85
85
|
context: MarkdownParser.Context,
|
|
86
|
-
):
|
|
86
|
+
): HTMLAnchorElement {
|
|
87
87
|
assert(params.length > 0);
|
|
88
88
|
assert(params.every(p => typeof p === 'string'));
|
|
89
|
-
if (content.length !== 0 && trimNode(content).length === 0) return;
|
|
90
89
|
const INSECURE_URI = params.shift()!;
|
|
91
90
|
assert(INSECURE_URI === INSECURE_URI.trim());
|
|
92
91
|
assert(!INSECURE_URI.match(/\s/));
|
|
@@ -95,11 +94,12 @@ function parse(
|
|
|
95
94
|
context.host?.href || location.href);
|
|
96
95
|
const el = elem(
|
|
97
96
|
INSECURE_URI,
|
|
98
|
-
|
|
97
|
+
content,
|
|
99
98
|
uri,
|
|
100
99
|
context.host?.origin || location.origin);
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
return el.className === 'invalid'
|
|
101
|
+
? el
|
|
102
|
+
: define(el, attributes('link', [], optspec, params));
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
function elem(
|
|
@@ -89,7 +89,7 @@ function attributes(texts: string[], rubies: string[]): Record<string, string> {
|
|
|
89
89
|
let attrs: Record<string, string> | undefined;
|
|
90
90
|
for (const ss of [texts, rubies]) {
|
|
91
91
|
for (let i = 0; i < ss.length; ++i) {
|
|
92
|
-
if (ss[i].
|
|
92
|
+
if (!ss[i].includes('\x1B')) continue;
|
|
93
93
|
ss[i] = ss[i].replace(/\x1B/g, '');
|
|
94
94
|
attrs ??= {
|
|
95
95
|
class: 'invalid',
|
package/src/parser/visibility.ts
CHANGED
|
@@ -167,23 +167,23 @@ function trimBlankEnd<T extends HTMLElement | string>(parser: Parser<T>): Parser
|
|
|
167
167
|
parser,
|
|
168
168
|
trimNodeEnd);
|
|
169
169
|
}
|
|
170
|
-
export function trimNode<T extends HTMLElement | string>(nodes: T[]): T[] {
|
|
171
|
-
return trimNodeStart(trimNodeEnd(nodes));
|
|
172
|
-
}
|
|
173
|
-
function trimNodeStart<T extends HTMLElement | string>(nodes: T[]): T[] {
|
|
174
|
-
for (let node = nodes[0]; nodes.length > 0 && !isVisible(node = nodes[0], 0);) {
|
|
175
|
-
if (nodes.length === 1 && typeof node === 'object' && node.className === 'indexer') break;
|
|
176
|
-
if (typeof node === 'string') {
|
|
177
|
-
const pos = node.trimStart().length;
|
|
178
|
-
if (pos > 0) {
|
|
179
|
-
nodes[0] = node.slice(-pos) as T;
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
nodes.shift();
|
|
184
|
-
}
|
|
185
|
-
return nodes;
|
|
186
|
-
}
|
|
170
|
+
//export function trimNode<T extends HTMLElement | string>(nodes: T[]): T[] {
|
|
171
|
+
// return trimNodeStart(trimNodeEnd(nodes));
|
|
172
|
+
//}
|
|
173
|
+
//function trimNodeStart<T extends HTMLElement | string>(nodes: T[]): T[] {
|
|
174
|
+
// for (let node = nodes[0]; nodes.length > 0 && !isVisible(node = nodes[0], 0);) {
|
|
175
|
+
// if (nodes.length === 1 && typeof node === 'object' && node.className === 'indexer') break;
|
|
176
|
+
// if (typeof node === 'string') {
|
|
177
|
+
// const pos = node.trimStart().length;
|
|
178
|
+
// if (pos > 0) {
|
|
179
|
+
// nodes[0] = node.slice(-pos) as T;
|
|
180
|
+
// break;
|
|
181
|
+
// }
|
|
182
|
+
// }
|
|
183
|
+
// nodes.shift();
|
|
184
|
+
// }
|
|
185
|
+
// return nodes;
|
|
186
|
+
//}
|
|
187
187
|
export function trimNodeEnd<T extends HTMLElement | string>(nodes: T[]): T[] {
|
|
188
188
|
const skip = nodes.length > 0 &&
|
|
189
189
|
typeof nodes[nodes.length - 1] === 'object' &&
|