@diplodoc/transform 4.57.7 → 4.58.0
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/dist/css/_yfm-only.css.map +1 -1
- package/dist/css/_yfm-only.min.css.map +1 -1
- package/dist/css/base.css.map +1 -1
- package/dist/css/base.min.css.map +1 -1
- package/dist/css/print.css.map +1 -1
- package/dist/css/yfm.css.map +1 -1
- package/dist/css/yfm.min.css.map +1 -1
- package/lib/constants.d.ts +1 -1
- package/lib/headings.d.ts +2 -2
- package/lib/headings.js.map +1 -1
- package/lib/highlight.d.ts +1 -1
- package/lib/highlight.js.map +1 -1
- package/lib/liquid/conditions.js.map +1 -1
- package/lib/liquid/index.d.ts +1 -1
- package/lib/liquid/index.js.map +1 -1
- package/lib/plugins/anchors/collect.d.ts +1 -1
- package/lib/plugins/anchors/collect.js.map +1 -1
- package/lib/plugins/anchors/constants.d.ts +1 -1
- package/lib/plugins/anchors/index.d.ts +1 -1
- package/lib/plugins/anchors/index.js.map +1 -1
- package/lib/plugins/block-anchor/block-anchor.d.ts +2 -2
- package/lib/plugins/block-anchor/index.d.ts +1 -1
- package/lib/plugins/changelog/collect.d.ts +2 -2
- package/lib/plugins/changelog/collect.js.map +1 -1
- package/lib/plugins/changelog/index.d.ts +1 -1
- package/lib/plugins/changelog/index.js.map +1 -1
- package/lib/plugins/checkbox/index.d.ts +1 -1
- package/lib/plugins/checkbox/index.js.map +1 -1
- package/lib/plugins/code.d.ts +1 -1
- package/lib/plugins/code.js +1 -1
- package/lib/plugins/code.js.map +1 -1
- package/lib/plugins/deflist.d.ts +1 -1
- package/lib/plugins/deflist.js.map +1 -1
- package/lib/plugins/images/collect.d.ts +1 -1
- package/lib/plugins/images/collect.js.map +1 -1
- package/lib/plugins/images/index.d.ts +1 -1
- package/lib/plugins/images/index.js.map +1 -1
- package/lib/plugins/imsize/index.d.ts +2 -2
- package/lib/plugins/imsize/index.js.map +1 -1
- package/lib/plugins/includes/collect.d.ts +1 -1
- package/lib/plugins/includes/collect.js.map +1 -1
- package/lib/plugins/includes/index.d.ts +2 -2
- package/lib/plugins/includes/index.js +1 -1
- package/lib/plugins/includes/index.js.map +1 -1
- package/lib/plugins/includes/types.d.ts +2 -2
- package/lib/plugins/links/index.d.ts +4 -4
- package/lib/plugins/links/index.js.map +1 -1
- package/lib/plugins/meta.d.ts +1 -1
- package/lib/plugins/meta.js.map +1 -1
- package/lib/plugins/monospace.d.ts +1 -1
- package/lib/plugins/notes/constants.d.ts +1 -1
- package/lib/plugins/notes/index.d.ts +1 -1
- package/lib/plugins/notes/index.js.map +1 -1
- package/lib/plugins/ol-attr-conversion.d.ts +1 -1
- package/lib/plugins/sup.d.ts +1 -1
- package/lib/plugins/sup.js.map +1 -1
- package/lib/plugins/table/index.d.ts +3 -2
- package/lib/plugins/table/index.js +152 -28
- package/lib/plugins/table/index.js.map +1 -1
- package/lib/plugins/table/types.d.ts +34 -0
- package/lib/plugins/table/types.js +3 -0
- package/lib/plugins/table/types.js.map +1 -0
- package/lib/plugins/term/index.d.ts +1 -1
- package/lib/plugins/term/termDefinitions.d.ts +3 -3
- package/lib/plugins/term/termDefinitions.js.map +1 -1
- package/lib/plugins/utils.d.ts +2 -2
- package/lib/plugins/utils.js.map +1 -1
- package/lib/preprocessors/included/index.d.ts +1 -1
- package/lib/preprocessors/included/index.js.map +1 -1
- package/lib/sanitize.d.ts +1 -1
- package/lib/sanitize.js.map +1 -1
- package/lib/title.d.ts +1 -1
- package/lib/typings.d.ts +7 -6
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js.map +1 -1
- package/lib/utilsFS.d.ts +1 -1
- package/lib/utilsFS.js.map +1 -1
- package/lib/yfmlint/index.d.ts +3 -3
- package/lib/yfmlint/index.js.map +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm001.d.ts +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm001.js.map +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm002.d.ts +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm003.d.ts +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm004.d.ts +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm005.d.ts +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm006.d.ts +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm007.d.ts +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm008.d.ts +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm009.d.ts +1 -1
- package/lib/yfmlint/typings.d.ts +3 -3
- package/lib/yfmlint/utils.d.ts +2 -2
- package/lib/yfmlint/utils.js.map +1 -1
- package/lib/yfmlint/yfmlint.d.ts +1 -1
- package/lib/yfmlint/yfmlint.js.map +1 -1
- package/package.json +2 -1
- package/src/transform/constants.ts +1 -1
- package/src/transform/headings.ts +2 -3
- package/src/transform/highlight.ts +2 -2
- package/src/transform/liquid/conditions.ts +3 -1
- package/src/transform/liquid/index.ts +2 -1
- package/src/transform/plugins/anchors/collect.ts +2 -1
- package/src/transform/plugins/anchors/constants.ts +1 -1
- package/src/transform/plugins/anchors/index.ts +4 -3
- package/src/transform/plugins/block-anchor/block-anchor.ts +2 -2
- package/src/transform/plugins/block-anchor/index.ts +1 -1
- package/src/transform/plugins/changelog/collect.ts +3 -3
- package/src/transform/plugins/changelog/index.ts +5 -5
- package/src/transform/plugins/checkbox/index.ts +2 -1
- package/src/transform/plugins/code.ts +3 -2
- package/src/transform/plugins/deflist.ts +2 -2
- package/src/transform/plugins/images/collect.ts +2 -1
- package/src/transform/plugins/images/index.ts +4 -3
- package/src/transform/plugins/imsize/index.ts +3 -2
- package/src/transform/plugins/includes/collect.ts +2 -2
- package/src/transform/plugins/includes/index.ts +8 -13
- package/src/transform/plugins/includes/types.ts +2 -2
- package/src/transform/plugins/links/index.ts +6 -6
- package/src/transform/plugins/meta.ts +2 -2
- package/src/transform/plugins/monospace.ts +3 -3
- package/src/transform/plugins/notes/constants.ts +1 -1
- package/src/transform/plugins/notes/index.ts +6 -4
- package/src/transform/plugins/ol-attr-conversion.ts +1 -1
- package/src/transform/plugins/sup.ts +2 -2
- package/src/transform/plugins/table/index.ts +190 -31
- package/src/transform/plugins/table/types.ts +35 -0
- package/src/transform/plugins/term/index.ts +3 -3
- package/src/transform/plugins/term/termDefinitions.ts +3 -4
- package/src/transform/plugins/utils.ts +3 -3
- package/src/transform/plugins/video/parsers.ts +2 -2
- package/src/transform/preprocessors/included/index.ts +3 -2
- package/src/transform/sanitize.ts +4 -2
- package/src/transform/title.ts +1 -1
- package/src/transform/typings.ts +7 -7
- package/src/transform/utils.ts +2 -1
- package/src/transform/utilsFS.ts +1 -1
- package/src/transform/yfmlint/index.ts +4 -3
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm001.ts +2 -1
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm002.ts +1 -1
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm003.ts +1 -1
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm004.ts +1 -1
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm005.ts +1 -1
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm006.ts +1 -1
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm007.ts +1 -1
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm008.ts +1 -1
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm009.ts +1 -1
- package/src/transform/yfmlint/typings.ts +3 -6
- package/src/transform/yfmlint/utils.ts +2 -3
- package/src/transform/yfmlint/yfmlint.ts +2 -2
- package/lib/plugins/table/attrs.d.ts +0 -18
- package/lib/plugins/table/attrs.js +0 -172
- package/lib/plugins/table/attrs.js.map +0 -1
- package/src/transform/plugins/table/attrs.ts +0 -199
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
8
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
11
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
12
|
-
};
|
|
13
|
-
var _AttrsParser_key, _AttrsParser_pending, _AttrsParser_isInsideQuotation, _AttrsParser_didQuotationClosed, _AttrsParser_currentKeyType, _AttrsParser_selectors, _AttrsParser_handlers, _AttrsParser_state;
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.AttrsParser = void 0;
|
|
16
|
-
class AttrsParser {
|
|
17
|
-
constructor() {
|
|
18
|
-
this.DELIMITER = '=';
|
|
19
|
-
this.SEPARATOR = ' ';
|
|
20
|
-
this.QUOTATION = '"';
|
|
21
|
-
/* allowed in keys / values chars */
|
|
22
|
-
this.ALLOWED_CHARS = /[a-zA-Z0-9_\- {}.|/]/;
|
|
23
|
-
/* allowed in all query chars */
|
|
24
|
-
this.VALIDATION_CHARS = /[a-zA-Z0-9_\- {}.#="|/]/;
|
|
25
|
-
_AttrsParser_key.set(this, '');
|
|
26
|
-
_AttrsParser_pending.set(this, '');
|
|
27
|
-
_AttrsParser_isInsideQuotation.set(this, false);
|
|
28
|
-
_AttrsParser_didQuotationClosed.set(this, false);
|
|
29
|
-
_AttrsParser_currentKeyType.set(this, void 0);
|
|
30
|
-
_AttrsParser_selectors.set(this, {
|
|
31
|
-
id: /#/,
|
|
32
|
-
class: /\./,
|
|
33
|
-
attr: /[a-zA-Z-_]/,
|
|
34
|
-
});
|
|
35
|
-
_AttrsParser_handlers.set(this, Object.entries(__classPrivateFieldGet(this, _AttrsParser_selectors, "f")));
|
|
36
|
-
_AttrsParser_state.set(this, {});
|
|
37
|
-
}
|
|
38
|
-
parse(target) {
|
|
39
|
-
/* escape from {} */
|
|
40
|
-
const content = this.extract(target);
|
|
41
|
-
if (!content) {
|
|
42
|
-
return {};
|
|
43
|
-
}
|
|
44
|
-
for (const char of content) {
|
|
45
|
-
this.next(char);
|
|
46
|
-
}
|
|
47
|
-
/* end-of-content mark */
|
|
48
|
-
this.next(this.SEPARATOR);
|
|
49
|
-
this.clear();
|
|
50
|
-
return __classPrivateFieldGet(this, _AttrsParser_state, "f");
|
|
51
|
-
}
|
|
52
|
-
extract(target) {
|
|
53
|
-
if (!target.startsWith('{')) {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
let balance = 1;
|
|
57
|
-
for (let i = 1; i < target.length; i++) {
|
|
58
|
-
const char = target[i];
|
|
59
|
-
if (char === '}') {
|
|
60
|
-
balance--;
|
|
61
|
-
}
|
|
62
|
-
if (char === '{') {
|
|
63
|
-
balance++;
|
|
64
|
-
}
|
|
65
|
-
if (balance === 0) {
|
|
66
|
-
const contentInside = target.slice(1, i).trim();
|
|
67
|
-
return contentInside;
|
|
68
|
-
}
|
|
69
|
-
if (balance < 0) {
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
if (!this.VALIDATION_CHARS.test(char)) {
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
next(value) {
|
|
79
|
-
if (!__classPrivateFieldGet(this, _AttrsParser_currentKeyType, "f")) {
|
|
80
|
-
__classPrivateFieldSet(this, _AttrsParser_currentKeyType, this.type(value), "f");
|
|
81
|
-
if (__classPrivateFieldGet(this, _AttrsParser_currentKeyType, "f") === 'attr') {
|
|
82
|
-
__classPrivateFieldSet(this, _AttrsParser_pending, value, "f");
|
|
83
|
-
}
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
if (this.isSeparator(value)) {
|
|
87
|
-
if (!__classPrivateFieldGet(this, _AttrsParser_pending, "f")) {
|
|
88
|
-
/* (name= ) construction */
|
|
89
|
-
if (!__classPrivateFieldGet(this, _AttrsParser_isInsideQuotation, "f")) {
|
|
90
|
-
this.append(__classPrivateFieldGet(this, _AttrsParser_key, "f"), ' ');
|
|
91
|
-
this.clear();
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
/* single key (.name #id contenteditable) */
|
|
96
|
-
if (!__classPrivateFieldGet(this, _AttrsParser_key, "f") && __classPrivateFieldGet(this, _AttrsParser_pending, "f")) {
|
|
97
|
-
this.append();
|
|
98
|
-
this.clear();
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
/* trying to find close quotation */
|
|
102
|
-
if (__classPrivateFieldGet(this, _AttrsParser_isInsideQuotation, "f") && !__classPrivateFieldGet(this, _AttrsParser_didQuotationClosed, "f")) {
|
|
103
|
-
__classPrivateFieldSet(this, _AttrsParser_pending, __classPrivateFieldGet(this, _AttrsParser_pending, "f") + value, "f");
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
if (__classPrivateFieldGet(this, _AttrsParser_isInsideQuotation, "f") && __classPrivateFieldGet(this, _AttrsParser_didQuotationClosed, "f")) {
|
|
107
|
-
this.append(__classPrivateFieldGet(this, _AttrsParser_key, "f"), __classPrivateFieldGet(this, _AttrsParser_pending, "f"));
|
|
108
|
-
}
|
|
109
|
-
if (!__classPrivateFieldGet(this, _AttrsParser_isInsideQuotation, "f") && !__classPrivateFieldGet(this, _AttrsParser_didQuotationClosed, "f")) {
|
|
110
|
-
this.append(__classPrivateFieldGet(this, _AttrsParser_key, "f"), __classPrivateFieldGet(this, _AttrsParser_pending, "f"));
|
|
111
|
-
}
|
|
112
|
-
this.clear();
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
if (this.isAllowedChar(value)) {
|
|
116
|
-
__classPrivateFieldSet(this, _AttrsParser_pending, __classPrivateFieldGet(this, _AttrsParser_pending, "f") + value, "f");
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
if (this.isQuotation(value)) {
|
|
120
|
-
if (__classPrivateFieldGet(this, _AttrsParser_isInsideQuotation, "f")) {
|
|
121
|
-
__classPrivateFieldSet(this, _AttrsParser_didQuotationClosed, true, "f");
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
__classPrivateFieldSet(this, _AttrsParser_isInsideQuotation, true, "f");
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
if (this.isDelimiter(value)) {
|
|
128
|
-
/* symbol is not delimiter, adding it to value */
|
|
129
|
-
if (__classPrivateFieldGet(this, _AttrsParser_key, "f")) {
|
|
130
|
-
__classPrivateFieldSet(this, _AttrsParser_pending, __classPrivateFieldGet(this, _AttrsParser_pending, "f") + value, "f");
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
__classPrivateFieldSet(this, _AttrsParser_key, __classPrivateFieldGet(this, _AttrsParser_pending, "f"), "f");
|
|
134
|
-
__classPrivateFieldSet(this, _AttrsParser_pending, '', "f");
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
type(of) {
|
|
138
|
-
var _a;
|
|
139
|
-
return (_a = __classPrivateFieldGet(this, _AttrsParser_handlers, "f").find(([_, regex]) => regex.test(of))) === null || _a === void 0 ? void 0 : _a[0];
|
|
140
|
-
}
|
|
141
|
-
append(key = __classPrivateFieldGet(this, _AttrsParser_currentKeyType, "f"), value = __classPrivateFieldGet(this, _AttrsParser_pending, "f")) {
|
|
142
|
-
if (!key) {
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
if (!__classPrivateFieldGet(this, _AttrsParser_state, "f")[key]) {
|
|
146
|
-
__classPrivateFieldGet(this, _AttrsParser_state, "f")[key] = [];
|
|
147
|
-
}
|
|
148
|
-
__classPrivateFieldGet(this, _AttrsParser_state, "f")[key].push(value);
|
|
149
|
-
}
|
|
150
|
-
clear() {
|
|
151
|
-
__classPrivateFieldSet(this, _AttrsParser_key, '', "f");
|
|
152
|
-
__classPrivateFieldSet(this, _AttrsParser_pending, '', "f");
|
|
153
|
-
__classPrivateFieldSet(this, _AttrsParser_isInsideQuotation, false, "f");
|
|
154
|
-
__classPrivateFieldSet(this, _AttrsParser_didQuotationClosed, false, "f");
|
|
155
|
-
__classPrivateFieldSet(this, _AttrsParser_currentKeyType, undefined, "f");
|
|
156
|
-
}
|
|
157
|
-
isDelimiter(target) {
|
|
158
|
-
return target === this.DELIMITER;
|
|
159
|
-
}
|
|
160
|
-
isSeparator(target) {
|
|
161
|
-
return target === this.SEPARATOR;
|
|
162
|
-
}
|
|
163
|
-
isQuotation(target) {
|
|
164
|
-
return target === this.QUOTATION;
|
|
165
|
-
}
|
|
166
|
-
isAllowedChar(target) {
|
|
167
|
-
return this.ALLOWED_CHARS.test(target);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
exports.AttrsParser = AttrsParser;
|
|
171
|
-
_AttrsParser_key = new WeakMap(), _AttrsParser_pending = new WeakMap(), _AttrsParser_isInsideQuotation = new WeakMap(), _AttrsParser_didQuotationClosed = new WeakMap(), _AttrsParser_currentKeyType = new WeakMap(), _AttrsParser_selectors = new WeakMap(), _AttrsParser_handlers = new WeakMap(), _AttrsParser_state = new WeakMap();
|
|
172
|
-
//# sourceMappingURL=attrs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attrs.js","sourceRoot":"","sources":["../../../src/transform/plugins/table/attrs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,MAAa,WAAW;IAAxB;QACI,cAAS,GAAG,GAAG,CAAC;QAChB,cAAS,GA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UOTATION = '"';
|
|
7
|
-
/* allowed in keys / values chars */
|
|
8
|
-
ALLOWED_CHARS = /[a-zA-Z0-9_\- {}.|/]/;
|
|
9
|
-
/* allowed in all query chars */
|
|
10
|
-
VALIDATION_CHARS = /[a-zA-Z0-9_\- {}.#="|/]/;
|
|
11
|
-
|
|
12
|
-
#key = '';
|
|
13
|
-
#pending = '';
|
|
14
|
-
#isInsideQuotation = false;
|
|
15
|
-
#didQuotationClosed = false;
|
|
16
|
-
#currentKeyType: Attrs | undefined;
|
|
17
|
-
|
|
18
|
-
#selectors: Record<Attrs, RegExp> = {
|
|
19
|
-
id: /#/,
|
|
20
|
-
class: /\./,
|
|
21
|
-
attr: /[a-zA-Z-_]/,
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
#handlers = Object.entries(this.#selectors) as [Attrs, RegExp][];
|
|
25
|
-
#state: Record<string, string[]> = {};
|
|
26
|
-
|
|
27
|
-
parse(target: string): Record<string, string[]> {
|
|
28
|
-
/* escape from {} */
|
|
29
|
-
const content = this.extract(target);
|
|
30
|
-
|
|
31
|
-
if (!content) {
|
|
32
|
-
return {};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
for (const char of content) {
|
|
36
|
-
this.next(char);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/* end-of-content mark */
|
|
40
|
-
this.next(this.SEPARATOR);
|
|
41
|
-
|
|
42
|
-
this.clear();
|
|
43
|
-
|
|
44
|
-
return this.#state;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
private extract(target: string): string | false {
|
|
48
|
-
if (!target.startsWith('{')) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
let balance = 1;
|
|
52
|
-
|
|
53
|
-
for (let i = 1; i < target.length; i++) {
|
|
54
|
-
const char = target[i];
|
|
55
|
-
|
|
56
|
-
if (char === '}') {
|
|
57
|
-
balance--;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (char === '{') {
|
|
61
|
-
balance++;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (balance === 0) {
|
|
65
|
-
const contentInside = target.slice(1, i).trim();
|
|
66
|
-
|
|
67
|
-
return contentInside;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (balance < 0) {
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (!this.VALIDATION_CHARS.test(char)) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
private next(value: string) {
|
|
83
|
-
if (!this.#currentKeyType) {
|
|
84
|
-
this.#currentKeyType = this.type(value);
|
|
85
|
-
|
|
86
|
-
if (this.#currentKeyType === 'attr') {
|
|
87
|
-
this.#pending = value;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (this.isSeparator(value)) {
|
|
94
|
-
if (!this.#pending) {
|
|
95
|
-
/* (name= ) construction */
|
|
96
|
-
if (!this.#isInsideQuotation) {
|
|
97
|
-
this.append(this.#key, ' ');
|
|
98
|
-
this.clear();
|
|
99
|
-
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/* single key (.name #id contenteditable) */
|
|
105
|
-
if (!this.#key && this.#pending) {
|
|
106
|
-
this.append();
|
|
107
|
-
this.clear();
|
|
108
|
-
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/* trying to find close quotation */
|
|
113
|
-
if (this.#isInsideQuotation && !this.#didQuotationClosed) {
|
|
114
|
-
this.#pending += value;
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (this.#isInsideQuotation && this.#didQuotationClosed) {
|
|
119
|
-
this.append(this.#key, this.#pending);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (!this.#isInsideQuotation && !this.#didQuotationClosed) {
|
|
123
|
-
this.append(this.#key, this.#pending);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
this.clear();
|
|
127
|
-
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (this.isAllowedChar(value)) {
|
|
132
|
-
this.#pending += value;
|
|
133
|
-
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (this.isQuotation(value)) {
|
|
138
|
-
if (this.#isInsideQuotation) {
|
|
139
|
-
this.#didQuotationClosed = true;
|
|
140
|
-
} else {
|
|
141
|
-
this.#isInsideQuotation = true;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (this.isDelimiter(value)) {
|
|
146
|
-
/* symbol is not delimiter, adding it to value */
|
|
147
|
-
if (this.#key) {
|
|
148
|
-
this.#pending += value;
|
|
149
|
-
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
this.#key = this.#pending;
|
|
154
|
-
this.#pending = '';
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
private type(of: string): Attrs | undefined {
|
|
159
|
-
return this.#handlers.find(([_, regex]) => regex.test(of))?.[0];
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
private append(key: string | undefined = this.#currentKeyType, value: string = this.#pending) {
|
|
163
|
-
if (!key) {
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if (!this.#state[key]) {
|
|
168
|
-
this.#state[key] = [];
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
this.#state[key].push(value);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
private clear() {
|
|
175
|
-
this.#key = '';
|
|
176
|
-
this.#pending = '';
|
|
177
|
-
|
|
178
|
-
this.#isInsideQuotation = false;
|
|
179
|
-
this.#didQuotationClosed = false;
|
|
180
|
-
|
|
181
|
-
this.#currentKeyType = undefined;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
private isDelimiter(target: string) {
|
|
185
|
-
return target === this.DELIMITER;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
private isSeparator(target: string) {
|
|
189
|
-
return target === this.SEPARATOR;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
private isQuotation(target: string) {
|
|
193
|
-
return target === this.QUOTATION;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
private isAllowedChar(target: string) {
|
|
197
|
-
return this.ALLOWED_CHARS.test(target);
|
|
198
|
-
}
|
|
199
|
-
}
|