From 4d6b1e80b35f73cc9cc7caac92fbf632d7d20f15 Mon Sep 17 00:00:00 2001 From: Brad Arant Date: Mon, 25 Nov 2024 13:57:35 -0800 Subject: [PATCH] fixed tag to process containers in appropriate order instead of inline. --- Tag.cpp | 12 +++++++----- Tag.h | 5 +++-- __dotag.cpp | 7 +++++-- tests/testjet.jet | 2 +- tests/testtag.jet | 21 +++++++++++---------- 5 files changed, 27 insertions(+), 20 deletions(-) diff --git a/Tag.cpp b/Tag.cpp index 81b22c1..9b459f5 100644 --- a/Tag.cpp +++ b/Tag.cpp @@ -97,7 +97,7 @@ namespace jet { } } } else - parseContainer(in); + parseContainer(in, out); } Tag::~Tag() { @@ -112,12 +112,12 @@ namespace jet { variables[keyword] = KeywordValue(variables[keyword], global, parent->variables); } - void Tag::processContainer(coreutils::ZString &container, coreutils::ZString container2) { + void Tag::processContainer(coreutils::ZString &container) { if(hasContainer && evaluate) - parseContainer(container, container2); + parseContainer(container, out); } - void Tag::parseContainer(coreutils::ZString &in, coreutils::ZString container2) { + void Tag::parseContainer(coreutils::ZString &in, coreutils::MString &out) { coreutils::ZString tag; char *start = in.getCursor(); while(!in.eod()) { @@ -189,7 +189,8 @@ namespace jet { __dotag _dotag(in, out, global, this); continue; } else if(ifTagName(in, "container")) { - processContainer(container2); + while(!containerOut.eod()) + out.write(containerOut.nextChar()); in.ifNext(""); @@ -197,6 +198,7 @@ namespace jet { } else { out.write(in.charAt(0)); in.nextChar(); + continue; } } else if(in.startsWith("$[") || in.startsWith("#[")) { out.write(global.getVariable(in, variables)); diff --git a/Tag.h b/Tag.h index 4108356..cd2ed97 100644 --- a/Tag.h +++ b/Tag.h @@ -25,14 +25,15 @@ namespace jet { bool hasContainer; bool hasContainer2; bool variableDefined(coreutils::ZString variable); - void parseContainer(coreutils::ZString &in, coreutils::ZString container2 = NULL); - void processContainer(coreutils::ZString &container, coreutils::ZString container2 = NULL); + void parseContainer(coreutils::ZString &in, coreutils::MString &out); + void processContainer(coreutils::ZString &container); void copyContainer(coreutils::ZString &in, coreutils::MString &out); Global &global; coreutils::MString &parentOut; coreutils::MString out; + coreutils::MString containerOut; bool output = true; bool evaluate = true; diff --git a/__dotag.cpp b/__dotag.cpp index 909fd13..6899807 100644 --- a/__dotag.cpp +++ b/__dotag.cpp @@ -4,9 +4,12 @@ namespace jet { __dotag::__dotag(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent) : Tag(in, parentOut, global, parent) { - hasContainer = true; + if(hasContainer) + parseContainer(container, containerOut); + containerOut.reset(); coreutils::ZString container3 = global.tags[name]; - processContainer(container3, container); + hasContainer = true; + processContainer(container3); } } diff --git a/tests/testjet.jet b/tests/testjet.jet index fa9822f..c70bf61 100755 --- a/tests/testjet.jet +++ b/tests/testjet.jet @@ -21,7 +21,7 @@ - $[$nested] + $[nested] 0123456789 lefty=[$[lefty]] diff --git a/tests/testtag.jet b/tests/testtag.jet index 578376b..6c4b362 100755 --- a/tests/testtag.jet +++ b/tests/testtag.jet @@ -1,16 +1,17 @@ #!../jet-2.0 - - x - + +
+ 1-$[test] - $[ix] - z + 2-$[test] +
- - y - - - + + a + + + b +
\ No newline at end of file