Library: fix handling of escapes
While they were detected just fine, thy were passed-through
unaltered, which subverts the purpose of such an escape,
which is to allow for the tag syntax to be present in the
processed, substituted document (e.g. when generating a
shell script)
thus `\${escaped}` becomes `${escaped}`
This commit is contained in:
parent
c09f44e20f
commit
9b6fc3ebe5
3 changed files with 20 additions and 13 deletions
|
|
@ -190,7 +190,9 @@ namespace lib {
|
|||
rest = rest.substr(tag.lead.length());
|
||||
if (mat[5].matched)
|
||||
tag.key = mat[5];
|
||||
if (not mat[1].matched)
|
||||
if (mat[1].matched)
|
||||
rest = rest.substr(1); // strip escape
|
||||
else
|
||||
{ // not escaped but indeed active field
|
||||
rest = rest.substr(mat.length());
|
||||
if (mat[4].matched)
|
||||
|
|
|
|||
|
|
@ -201,19 +201,19 @@ namespace test {
|
|||
CHECK (not isnil(parser));
|
||||
CHECK (parser->syntax == TagSyntax::KEYID);
|
||||
CHECK (parser->lead == "one "_expect);
|
||||
CHECK (parser->key == "two"_expect);
|
||||
CHECK (parser->key == "two"_expect); // extract "two" as key for data lookup
|
||||
++parser;
|
||||
CHECK (parser);
|
||||
CHECK (parser->syntax == TagSyntax::ESCAPE);
|
||||
CHECK (parser->lead == " three "_expect);
|
||||
CHECK (parser->key == ""_expect);
|
||||
CHECK (parser->key == ""_expect); // empty since this tag has been escaped
|
||||
++parser;
|
||||
CHECK (parser);
|
||||
CHECK (parser->syntax == TagSyntax::IF);
|
||||
CHECK (parser->lead == "\\${four} "_expect);
|
||||
CHECK (parser->key == "high"_expect);
|
||||
CHECK (parser->lead == "${four} "_expect); // note: leading escape sign removed
|
||||
CHECK (parser->key == "high"_expect); // key ≡ "high" used to evaluate conditional
|
||||
++parser;
|
||||
CHECK (isnil (parser));
|
||||
CHECK (isnil (parser)); // note: the /parser/ stops right behind last token
|
||||
VERIFY_ERROR (ITER_EXHAUST, *parser);
|
||||
VERIFY_ERROR (ITER_EXHAUST, ++parser);
|
||||
|
||||
|
|
@ -243,8 +243,8 @@ for} tail...
|
|||
CHECK (actions[ 2].code == TextTemplate::Code::TEXT); // static text between active fields
|
||||
CHECK (actions[ 2].val == " next one is "_expect);
|
||||
|
||||
CHECK (actions[ 3].code == TextTemplate::Code::TEXT); // since next tag was escaped, it appears in static segment
|
||||
CHECK (actions[ 3].val == "\\${escaped}\n Prefix-2 "_expect);
|
||||
CHECK (actions[ 3].code == TextTemplate::Code::TEXT); // since next tag was escaped, it appears in static segment,
|
||||
CHECK (actions[ 3].val == "${escaped}\n Prefix-2 "_expect); // yet without the leading escape, which has been absorbed.
|
||||
|
||||
CHECK (actions[ 4].code == TextTemplate::Code::COND); // start of an if-bracket construct
|
||||
CHECK (actions[ 4].val == "cond1"_expect); // data marked with "cond1" will be used to determine true/false
|
||||
|
|
|
|||
|
|
@ -113111,7 +113111,7 @@ std::cout << tmpl.render({"what", "World"}) << s
|
|||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1710856784967" FOLDED="true" ID="ID_201927694" MODIFIED="1711323978664" TEXT="Parsing soll eager sein (wegen Syntax-Fehlern)">
|
||||
<node COLOR="#338800" CREATED="1710856784967" ID="ID_201927694" MODIFIED="1711377572718" TEXT="Parsing soll eager sein (wegen Syntax-Fehlern)">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node COLOR="#435e98" CREATED="1711057133538" ID="ID_1870486170" MODIFIED="1711312266549" TEXT="versuche aber trotzdem ein Pipeline-Design">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
|
|
@ -113190,7 +113190,7 @@ std::cout << tmpl.render({"what", "World"}) << s
|
|||
<node CREATED="1711158230860" ID="ID_421709614" MODIFIED="1711158244517" TEXT="also dann halt gleich als String speichern"/>
|
||||
</node>
|
||||
<node COLOR="#435e98" CREATED="1711158258547" ID="ID_431240403" MODIFIED="1711237046365" TEXT="muß das letzte Postfix ohne Match finden">
|
||||
<linktarget COLOR="#b72676" DESTINATION="ID_431240403" ENDARROW="Default" ENDINCLINATION="-189;13;" ID="Arrow_ID_232745747" SOURCE="ID_1998845229" STARTARROW="None" STARTINCLINATION="170;-14;"/>
|
||||
<linktarget COLOR="#614070" DESTINATION="ID_431240403" ENDARROW="Default" ENDINCLINATION="-189;13;" ID="Arrow_ID_232745747" SOURCE="ID_1998845229" STARTARROW="None" STARTINCLINATION="170;-14;"/>
|
||||
<icon BUILTIN="yes"/>
|
||||
<node CREATED="1711206740722" ID="ID_669120425" MODIFIED="1711206968242" TEXT="gute Lösung hängt stark von der intendierten Verwendung ab">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
|
|
@ -113343,15 +113343,20 @@ std::cout << tmpl.render({"what", "World"}) << s
|
|||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1711158288320" ID="ID_309368656" MODIFIED="1711158292632" TEXT="Test....">
|
||||
<node COLOR="#338800" CREATED="1711158288320" ID="ID_309368656" MODIFIED="1711377686617" TEXT="Test....">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node CREATED="1711158297133" ID="ID_788373690" MODIFIED="1711158307246" TEXT="Iteration als Solche ist möglich"/>
|
||||
<node COLOR="#435e98" CREATED="1711158308121" ID="ID_1938624994" MODIFIED="1711237020411" TEXT="Kürzen des `lead` muß das Pattern selber überspringen">
|
||||
<icon BUILTIN="broken-line"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#c8c0b6" COLOR="#a50125" CREATED="1711158373801" ID="ID_1998845229" MODIFIED="1711237032425" TEXT="verliere das letzte Postfix">
|
||||
<arrowlink COLOR="#b72676" DESTINATION="ID_431240403" ENDARROW="Default" ENDINCLINATION="-189;13;" ID="Arrow_ID_232745747" STARTARROW="None" STARTINCLINATION="170;-14;"/>
|
||||
<node BACKGROUND_COLOR="#c8c0b6" COLOR="#6b2095" CREATED="1711158373801" ID="ID_1998845229" MODIFIED="1711377679216" TEXT="verliere das letzte Postfix">
|
||||
<arrowlink COLOR="#614070" DESTINATION="ID_431240403" ENDARROW="Default" ENDINCLINATION="-189;13;" ID="Arrow_ID_232745747" STARTARROW="None" STARTINCLINATION="170;-14;"/>
|
||||
<icon BUILTIN="messagebox_warning"/>
|
||||
</node>
|
||||
<node COLOR="#435e98" CREATED="1711377585280" ID="ID_30464860" MODIFIED="1711377646423" TEXT="Escape muß aber im output absorbiert werden">
|
||||
<icon BUILTIN="broken-line"/>
|
||||
<node CREATED="1711377613875" ID="ID_284276500" MODIFIED="1711377633540" TEXT="\${escaped} ⟼ ${escaped}"/>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1711312290872" ID="ID_473619294" MODIFIED="1711312308985" TEXT="Ausführliches Beispiel mit allen erwarteten Action-codes und Quer-Indices">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
|
|
|
|||
Loading…
Reference in a new issue