fixed Text parsing issue

This commit is contained in:
kree 2026-08-06 10:29:11 -04:00
parent b81ac470c5
commit 10003a1167

View file

@ -74,7 +74,11 @@ function _parse(text: string, root: Node): Node {
if (text.substring(i, i+2) == '}}') {
textNode.parent = scope;
const j = open.pop()!;
textNode.endIndex = j;
textNode.text = text.substring(textNode.startIndex!, textNode.endIndex!)
switch (scope.type) {
case 'Container':
scope.placeholders!.push(textNode)
@ -84,14 +88,13 @@ function _parse(text: string, root: Node): Node {
placeholders.push(textNode);
}
const j = open.pop()!;
textNode = {
type: 'Text',
startIndex: j+2,
startIndex: i+2,
endIndex: i
};
const command = parseCommand(text, j+2, i);
command.parent = scope;
@ -242,6 +245,7 @@ function printNode(node: Node, offset='') {
break;
case 'Text':
console.log(`${offset}${node.type} [text=${JSON.stringify(node.text)}]`);
break;
default:
console.log(`${offset}${node.type}`);
}