taggedjs 2.8.14 → 2.8.15
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/bundle.js +1 -1
- package/bundle.js.map +1 -1
- package/js/interpolations/optimizers/htmlInterpolationToDomMeta.function.d.ts +0 -1
- package/js/interpolations/optimizers/htmlInterpolationToDomMeta.function.js +1 -163
- package/js/interpolations/optimizers/htmlInterpolationToDomMeta.function.js.map +1 -1
- package/js/interpolations/optimizers/parseHTML.function.d.ts +3 -0
- package/js/interpolations/optimizers/parseHTML.function.js +166 -0
- package/js/interpolations/optimizers/parseHTML.function.js.map +1 -0
- package/package.json +1 -1
|
@@ -2,5 +2,4 @@ import { ParsedHtml } from "./types.js";
|
|
|
2
2
|
/** Run only during compile step OR when no compile step occurred at runtime */
|
|
3
3
|
export declare function htmlInterpolationToDomMeta(strings: string[], values: unknown[]): ParsedHtml;
|
|
4
4
|
export declare function htmlInterpolationToPlaceholders(strings: string[], values: unknown[]): string[];
|
|
5
|
-
export declare function parseHTML(html: string): ParsedHtml;
|
|
6
5
|
export declare function balanceArrayByArrays(results: unknown[], strings: string[], values: unknown[]): void;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { variablePrefix, variableSuffix } from "../../tag/getDomTag.function.js";
|
|
2
|
-
import {
|
|
3
|
-
const ondoubleclick = 'ondoubleclick';
|
|
4
|
-
const fragFindAny = /(:tagvar\d+:)/;
|
|
2
|
+
import { parseHTML } from "./parseHTML.function.js";
|
|
5
3
|
const fragReplacer = /(^:tagvar\d+:|:tagvar\d+:$)/g;
|
|
6
4
|
const safeVar = '__safeTagVar';
|
|
7
|
-
const regexAttr = /([:_a-zA-Z0-9\-.]+)\s*(?:=\s*"([^"]*)"|=\s*(\S+))?/g;
|
|
8
|
-
const regexTagOrg = /<\/?([a-zA-Z0-9-]+)((?:\s+[a-zA-Z_:][\w:.-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)+\s*|\s*)\/?>/g;
|
|
9
5
|
/** Run only during compile step OR when no compile step occurred at runtime */
|
|
10
6
|
export function htmlInterpolationToDomMeta(strings, values) {
|
|
11
7
|
htmlInterpolationToPlaceholders(strings, values);
|
|
@@ -33,114 +29,6 @@ function addPlaceholders(strings, values) {
|
|
|
33
29
|
balanceArrayByArrays(results, strings, values);
|
|
34
30
|
return results;
|
|
35
31
|
}
|
|
36
|
-
export function parseHTML(html) {
|
|
37
|
-
const valuePositions = [];
|
|
38
|
-
const elements = [];
|
|
39
|
-
const stack = [];
|
|
40
|
-
let currentElement = null;
|
|
41
|
-
let valueIndex = -1;
|
|
42
|
-
let position = 0;
|
|
43
|
-
const regexTag = new RegExp(regexTagOrg, 'g');
|
|
44
|
-
html = preprocessTagsInComments(html);
|
|
45
|
-
while (position < html.length) {
|
|
46
|
-
const tagMatch = regexTag.exec(html);
|
|
47
|
-
if (!tagMatch) {
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
const [fullMatch, tagName, attrString] = tagMatch;
|
|
51
|
-
const isClosingTag = fullMatch.startsWith('</');
|
|
52
|
-
const isSelfClosing = fullMatch.endsWith('/>');
|
|
53
|
-
if (position < tagMatch.index) {
|
|
54
|
-
const textContent = html.slice(position, tagMatch.index);
|
|
55
|
-
if (textContent.trim()) {
|
|
56
|
-
const textVarMatches = splitByTagVar(textContent);
|
|
57
|
-
textVarMatches.forEach(textContent => {
|
|
58
|
-
if (textContent.startsWith(variablePrefix)) {
|
|
59
|
-
textContent = variablePrefix + (++valueIndex) + variableSuffix;
|
|
60
|
-
}
|
|
61
|
-
pushTextTo(currentElement, elements, textContent);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
position = tagMatch.index + fullMatch.length;
|
|
66
|
-
if (isClosingTag) {
|
|
67
|
-
currentElement = stack.pop() || null;
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
const attributes = [];
|
|
71
|
-
let attrMatch;
|
|
72
|
-
while ((attrMatch = regexAttr.exec(attrString)) !== null) {
|
|
73
|
-
const attrName = attrMatch[1] || attrMatch[3] || attrMatch[5];
|
|
74
|
-
const attrChoice = attrMatch[2] || attrMatch[4] || attrMatch[6];
|
|
75
|
-
let attrValue = attrChoice;
|
|
76
|
-
if (attrName === undefined) {
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
const notEmpty = attrMatch[2] !== '';
|
|
80
|
-
const noValue = attrValue === undefined && notEmpty;
|
|
81
|
-
const lowerName = attrName.toLowerCase();
|
|
82
|
-
const fixedName = lowerName.startsWith('on') ? cleanEventName(lowerName) : lowerName;
|
|
83
|
-
if (noValue) {
|
|
84
|
-
const standAloneVar = attrName.slice(0, variablePrefix.length) === variablePrefix;
|
|
85
|
-
if (standAloneVar) {
|
|
86
|
-
const valueName = variablePrefix + (++valueIndex) + variableSuffix;
|
|
87
|
-
valuePositions.push(['at', valueName]);
|
|
88
|
-
attributes.push([valueName]); // the name itself is dynamic
|
|
89
|
-
continue;
|
|
90
|
-
}
|
|
91
|
-
const startMatched = attrMatch[0].startsWith(attrName);
|
|
92
|
-
const standAloneAttr = startMatched && attrMatch[0].slice(attrName.length, attrMatch[0].length).search(/\s+$/) >= 0;
|
|
93
|
-
if (standAloneAttr) {
|
|
94
|
-
attributes.push([fixedName]);
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
const valueName = variablePrefix + (++valueIndex) + variableSuffix;
|
|
98
|
-
attrValue = valueName;
|
|
99
|
-
}
|
|
100
|
-
if (!notEmpty) {
|
|
101
|
-
attrValue = attrMatch[2];
|
|
102
|
-
}
|
|
103
|
-
const attrSet = [fixedName, attrValue];
|
|
104
|
-
const isSpecial = isSpecialAttr(lowerName); // check original name for "oninit" or "autofocus"
|
|
105
|
-
if (isSpecial) {
|
|
106
|
-
attrSet.push(isSpecial);
|
|
107
|
-
}
|
|
108
|
-
attributes.push(attrSet);
|
|
109
|
-
}
|
|
110
|
-
const element = {
|
|
111
|
-
nn: tagName, // nodeName
|
|
112
|
-
};
|
|
113
|
-
if (attributes.length) {
|
|
114
|
-
element.at = attributes;
|
|
115
|
-
}
|
|
116
|
-
if (currentElement) {
|
|
117
|
-
if (!currentElement.ch) {
|
|
118
|
-
currentElement.ch = [];
|
|
119
|
-
}
|
|
120
|
-
currentElement.ch.push(element);
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
elements.push(element);
|
|
124
|
-
}
|
|
125
|
-
if (!isSelfClosing) {
|
|
126
|
-
stack.push(currentElement);
|
|
127
|
-
currentElement = element;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
if (position < html.length) {
|
|
131
|
-
const textContent = html.slice(position);
|
|
132
|
-
if (textContent.trim()) {
|
|
133
|
-
const textVarMatches = splitByTagVar(textContent);
|
|
134
|
-
textVarMatches.forEach(textContent => {
|
|
135
|
-
if (textContent.startsWith(variablePrefix)) {
|
|
136
|
-
++valueIndex;
|
|
137
|
-
}
|
|
138
|
-
return pushTextTo(currentElement, elements, textContent);
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return elements;
|
|
143
|
-
}
|
|
144
32
|
export function balanceArrayByArrays(results, strings, values) {
|
|
145
33
|
const diff = values.length - strings.length;
|
|
146
34
|
if (diff > 0) {
|
|
@@ -149,54 +37,4 @@ export function balanceArrayByArrays(results, strings, values) {
|
|
|
149
37
|
}
|
|
150
38
|
}
|
|
151
39
|
}
|
|
152
|
-
function splitByTagVar(inputString) {
|
|
153
|
-
// Split the string using the regular expression, keep delimiters in the output
|
|
154
|
-
const parts = inputString.split(fragFindAny);
|
|
155
|
-
// Filter out any empty strings from the results
|
|
156
|
-
const filteredParts = parts.filter(part => part !== '');
|
|
157
|
-
return filteredParts;
|
|
158
|
-
}
|
|
159
|
-
function pushTo(currentElement, elements, textNode) {
|
|
160
|
-
if (currentElement) {
|
|
161
|
-
if (!currentElement.ch) {
|
|
162
|
-
currentElement.ch = [];
|
|
163
|
-
}
|
|
164
|
-
currentElement.ch.push(textNode);
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
elements.push(textNode);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
function pushTextTo(currentElement, elements, textContent) {
|
|
171
|
-
const textNode = {
|
|
172
|
-
nn: 'text', // nodeName
|
|
173
|
-
tc: postprocessTagsInComments(textContent), // textContent
|
|
174
|
-
};
|
|
175
|
-
pushTo(currentElement, elements, textNode);
|
|
176
|
-
}
|
|
177
|
-
const removeCommentRegX = new RegExp('(<!--[\\s\\S]*?-->)', 'g');
|
|
178
|
-
function preprocessTagsInComments(html) {
|
|
179
|
-
// Use a regex to find all HTML comments
|
|
180
|
-
return html.replace(removeCommentRegX, function (match) {
|
|
181
|
-
// For each comment found, replace < and > inside it
|
|
182
|
-
return match.replace(/\[l t\]/g, '[l t]').replace(/\[g t\]/g, '[g t]').replace(/</g, '[l t]').replace(/>/g, '[g t]');
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
function postprocessTagsInComments(html) {
|
|
186
|
-
// Use a regex to find all segments that look like processed comments
|
|
187
|
-
return html.replace(/(\[l t\]!--[\s\S]*?--\[g t\])/g, function (match) {
|
|
188
|
-
// For each processed comment found, replace *lt* and *gt* back to < and >
|
|
189
|
-
return match.replace(/\[l t\]/g, '<').replace(/\[g t\]/g, '>').replace(/\[l t\]/g, '[l t]').replace(/\[g t\]/g, '[g t]');
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
function cleanEventName(eventName) {
|
|
193
|
-
if (eventName.startsWith('on')) {
|
|
194
|
-
const couldByDblClick = eventName.length === ondoubleclick.length && eventName === ondoubleclick;
|
|
195
|
-
if (couldByDblClick) {
|
|
196
|
-
return 'dblclick';
|
|
197
|
-
}
|
|
198
|
-
return eventName.slice(2, eventName.length);
|
|
199
|
-
}
|
|
200
|
-
return eventName;
|
|
201
|
-
}
|
|
202
40
|
//# sourceMappingURL=htmlInterpolationToDomMeta.function.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"htmlInterpolationToDomMeta.function.js","sourceRoot":"","sources":["../../../ts/interpolations/optimizers/htmlInterpolationToDomMeta.function.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAChF,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"htmlInterpolationToDomMeta.function.js","sourceRoot":"","sources":["../../../ts/interpolations/optimizers/htmlInterpolationToDomMeta.function.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAGnD,MAAM,YAAY,GAAG,8BAA8B,CAAA;AACnD,MAAM,OAAO,GAAG,cAAc,CAAA;AAE9B,+EAA+E;AAC/E,MAAM,UAAU,0BAA0B,CACxC,OAAiB,EACjB,MAAiB;IAEjB,+BAA+B,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IAEhD,+BAA+B;IAC/B,MAAM,UAAU,GAAG,+BAA+B,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC5E,MAAM,OAAO,GAAG,SAAS,CAAC,UAAU,CAAC,CAAA;IAErC,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,MAAM,UAAU,+BAA+B,CAC7C,OAAiB,EACjB,MAAiB;IAEjB,yCAAyC;IACzC,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAA;IAExD,oCAAoC;IACpC,OAAQ,eAAe,CACrB,kBAAkB,EAAE,MAAM,CAC3B,CAAA;AACH,CAAC;AAED,SAAS,oBAAoB,CAAC,SAAmB;IAC/C,OAAO,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAC9B,QAAQ,CAAC,OAAO,CACd,YAAY,EACZ,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,OAAO,GAAG,KAAK,CAAC,CACrC,CAAA;AACH,CAAC;AAED,SAAS,eAAe,CACtB,OAAiB,EACjB,MAAa;IAGb,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;QAC9C,IAAI,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;YAC1B,OAAO,QAAQ,GAAG,cAAc,GAAG,KAAK,GAAG,cAAc,CAAA;QAC3D,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC,CAAA;IAEF,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;IAE9C,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,OAAkB,EAClB,OAAiB,EACjB,MAAiB;IAEjB,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;IAC3C,IAAG,IAAI,GAAG,CAAC,EAAE,CAAC;QACZ,KAAK,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;YAC9B,OAAO,CAAC,IAAI,CAAE,cAAc,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,cAAc,CAAE,CAAA;QAC5E,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { variablePrefix, variableSuffix } from "../../tag/getDomTag.function.js";
|
|
2
|
+
import { isSpecialAttr } from "../attributes/isSpecialAttribute.function.js";
|
|
3
|
+
const fragFindAny = /(:tagvar\d+:)/;
|
|
4
|
+
const ondoubleclick = 'ondoubleclick';
|
|
5
|
+
const regexAttr = /([:_a-zA-Z0-9\-.]+)\s*(?:=\s*"([^"]*)"|=\s*(\S+))?/g;
|
|
6
|
+
const regexTagOrg = /<\/?([a-zA-Z0-9-]+)((?:\s+[a-zA-Z_:*][\w:.-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)+\s*|\s*)\/?>/g;
|
|
7
|
+
/** Main start of string parsing */
|
|
8
|
+
export function parseHTML(html) {
|
|
9
|
+
const valuePositions = [];
|
|
10
|
+
const elements = [];
|
|
11
|
+
const stack = [];
|
|
12
|
+
let currentElement = null;
|
|
13
|
+
let valueIndex = -1;
|
|
14
|
+
let position = 0;
|
|
15
|
+
const regexTag = new RegExp(regexTagOrg, 'g');
|
|
16
|
+
html = preprocessTagsInComments(html);
|
|
17
|
+
while (position < html.length) {
|
|
18
|
+
const tagMatch = regexTag.exec(html);
|
|
19
|
+
if (!tagMatch) {
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
const [fullMatch, tagName, attrString] = tagMatch;
|
|
23
|
+
const isClosingTag = fullMatch.startsWith('</');
|
|
24
|
+
const isSelfClosing = fullMatch.endsWith('/>');
|
|
25
|
+
if (position < tagMatch.index) {
|
|
26
|
+
const textContent = html.slice(position, tagMatch.index);
|
|
27
|
+
if (textContent.trim()) {
|
|
28
|
+
const textVarMatches = splitByTagVar(textContent);
|
|
29
|
+
textVarMatches.forEach(textContent => {
|
|
30
|
+
if (textContent.startsWith(variablePrefix)) {
|
|
31
|
+
textContent = variablePrefix + (++valueIndex) + variableSuffix;
|
|
32
|
+
}
|
|
33
|
+
pushTextTo(currentElement, elements, textContent);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
position = tagMatch.index + fullMatch.length;
|
|
38
|
+
if (isClosingTag) {
|
|
39
|
+
currentElement = stack.pop() || null;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const attributes = [];
|
|
43
|
+
let attrMatch;
|
|
44
|
+
while ((attrMatch = regexAttr.exec(attrString)) !== null) {
|
|
45
|
+
const attrName = attrMatch[1] || attrMatch[3] || attrMatch[5];
|
|
46
|
+
const attrChoice = attrMatch[2] || attrMatch[4] || attrMatch[6];
|
|
47
|
+
let attrValue = attrChoice;
|
|
48
|
+
if (attrName === undefined) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const notEmpty = attrMatch[2] !== '';
|
|
52
|
+
const noValue = attrValue === undefined && notEmpty;
|
|
53
|
+
const lowerName = attrName.toLowerCase();
|
|
54
|
+
const fixedName = lowerName.startsWith('on') ? cleanEventName(lowerName) : lowerName;
|
|
55
|
+
if (noValue) {
|
|
56
|
+
const standAloneVar = attrName.slice(0, variablePrefix.length) === variablePrefix;
|
|
57
|
+
if (standAloneVar) {
|
|
58
|
+
const valueName = variablePrefix + (++valueIndex) + variableSuffix;
|
|
59
|
+
valuePositions.push(['at', valueName]);
|
|
60
|
+
attributes.push([valueName]); // the name itself is dynamic
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const startMatched = attrMatch[0].startsWith(attrName);
|
|
64
|
+
const standAloneAttr = startMatched && attrMatch[0].slice(attrName.length, attrMatch[0].length).search(/\s+$/) >= 0;
|
|
65
|
+
if (standAloneAttr) {
|
|
66
|
+
attributes.push([fixedName]);
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const valueName = variablePrefix + (++valueIndex) + variableSuffix;
|
|
70
|
+
attrValue = valueName;
|
|
71
|
+
}
|
|
72
|
+
if (!notEmpty) {
|
|
73
|
+
attrValue = attrMatch[2];
|
|
74
|
+
}
|
|
75
|
+
const attrSet = [fixedName, attrValue];
|
|
76
|
+
const isSpecial = isSpecialAttr(lowerName); // check original name for "oninit" or "autofocus"
|
|
77
|
+
if (isSpecial) {
|
|
78
|
+
attrSet.push(isSpecial);
|
|
79
|
+
}
|
|
80
|
+
attributes.push(attrSet);
|
|
81
|
+
}
|
|
82
|
+
const element = {
|
|
83
|
+
nn: tagName, // nodeName
|
|
84
|
+
};
|
|
85
|
+
if (attributes.length) {
|
|
86
|
+
element.at = attributes;
|
|
87
|
+
}
|
|
88
|
+
if (currentElement) {
|
|
89
|
+
if (!currentElement.ch) {
|
|
90
|
+
currentElement.ch = [];
|
|
91
|
+
}
|
|
92
|
+
currentElement.ch.push(element);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
elements.push(element);
|
|
96
|
+
}
|
|
97
|
+
if (!isSelfClosing) {
|
|
98
|
+
stack.push(currentElement);
|
|
99
|
+
currentElement = element;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (position < html.length) {
|
|
103
|
+
const textContent = html.slice(position);
|
|
104
|
+
if (textContent.trim()) {
|
|
105
|
+
const textVarMatches = splitByTagVar(textContent);
|
|
106
|
+
textVarMatches.forEach(textContent => {
|
|
107
|
+
if (textContent.startsWith(variablePrefix)) {
|
|
108
|
+
++valueIndex;
|
|
109
|
+
}
|
|
110
|
+
return pushTextTo(currentElement, elements, textContent);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return elements;
|
|
115
|
+
}
|
|
116
|
+
const removeCommentRegX = new RegExp('(<!--[\\s\\S]*?-->)', 'g');
|
|
117
|
+
function preprocessTagsInComments(html) {
|
|
118
|
+
// Use a regex to find all HTML comments
|
|
119
|
+
return html.replace(removeCommentRegX, function (match) {
|
|
120
|
+
// For each comment found, replace < and > inside it
|
|
121
|
+
return match.replace(/\[l t\]/g, '[l t]').replace(/\[g t\]/g, '[g t]').replace(/</g, '[l t]').replace(/>/g, '[g t]');
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
function cleanEventName(eventName) {
|
|
125
|
+
if (eventName.startsWith('on')) {
|
|
126
|
+
const couldByDblClick = eventName.length === ondoubleclick.length && eventName === ondoubleclick;
|
|
127
|
+
if (couldByDblClick) {
|
|
128
|
+
return 'dblclick';
|
|
129
|
+
}
|
|
130
|
+
return eventName.slice(2, eventName.length);
|
|
131
|
+
}
|
|
132
|
+
return eventName;
|
|
133
|
+
}
|
|
134
|
+
function pushTextTo(currentElement, elements, textContent) {
|
|
135
|
+
const textNode = {
|
|
136
|
+
nn: 'text', // nodeName
|
|
137
|
+
tc: postprocessTagsInComments(textContent), // textContent
|
|
138
|
+
};
|
|
139
|
+
pushTo(currentElement, elements, textNode);
|
|
140
|
+
}
|
|
141
|
+
function postprocessTagsInComments(html) {
|
|
142
|
+
// Use a regex to find all segments that look like processed comments
|
|
143
|
+
return html.replace(/(\[l t\]!--[\s\S]*?--\[g t\])/g, function (match) {
|
|
144
|
+
// For each processed comment found, replace *lt* and *gt* back to < and >
|
|
145
|
+
return match.replace(/\[l t\]/g, '<').replace(/\[g t\]/g, '>').replace(/\[l t\]/g, '[l t]').replace(/\[g t\]/g, '[g t]');
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function pushTo(currentElement, elements, textNode) {
|
|
149
|
+
if (currentElement) {
|
|
150
|
+
if (!currentElement.ch) {
|
|
151
|
+
currentElement.ch = [];
|
|
152
|
+
}
|
|
153
|
+
currentElement.ch.push(textNode);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
elements.push(textNode);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function splitByTagVar(inputString) {
|
|
160
|
+
// Split the string using the regular expression, keep delimiters in the output
|
|
161
|
+
const parts = inputString.split(fragFindAny);
|
|
162
|
+
// Filter out any empty strings from the results
|
|
163
|
+
const filteredParts = parts.filter(part => part !== '');
|
|
164
|
+
return filteredParts;
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=parseHTML.function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseHTML.function.js","sourceRoot":"","sources":["../../../ts/interpolations/optimizers/parseHTML.function.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAA;AAG5E,MAAM,WAAW,GAAG,eAAe,CAAA;AACnC,MAAM,aAAa,GAAG,eAAe,CAAA;AACrC,MAAM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