Only allow new style parameter values if the separator is an equals sign

This commit is contained in:
Jeremy Ruston
2026-01-25 20:21:39 +00:00
parent ff352d63da
commit a29ae908e2
3 changed files with 9 additions and 9 deletions

View File

@@ -286,13 +286,15 @@ exports.parseMacroParameterAsAttribute = function(source,pos) {
// Get the attribute name and the separator token
var nameToken = $tw.utils.parseTokenRegExp(source,pos,reAttributeName),
namePos = nameToken && $tw.utils.skipWhiteSpace(source,nameToken.end),
separatorToken = nameToken && $tw.utils.parseTokenRegExp(source,namePos,/=|:/g);
separatorToken = nameToken && $tw.utils.parseTokenRegExp(source,namePos,/=|:/g),
isNewStyleSeparator = true; // If there is no separator then we allow new style values
// If we have a name and a separator then we have a named attribute
if(nameToken && separatorToken) {
node.name = nameToken.match[1];
// key value separator is `=` or `:`
node.assignmentOperator = separatorToken.match[0];
pos = separatorToken.end;
isNewStyleSeparator = (node.assignmentOperator === "=");
}
// Skip whitespace
pos = $tw.utils.skipWhiteSpace(source,pos);
@@ -307,14 +309,14 @@ exports.parseMacroParameterAsAttribute = function(source,pos) {
} else {
// Look for a filtered value
var filteredValue = $tw.utils.parseTokenRegExp(source,pos,reFilteredValue);
if(filteredValue) {
if(filteredValue && isNewStyleSeparator) {
pos = filteredValue.end;
node.type = "filtered";
node.filter = filteredValue.match[1];
} else {
// Look for an indirect value
var indirectValue = $tw.utils.parseTokenRegExp(source,pos,reIndirectValue);
if(indirectValue) {
if(indirectValue && isNewStyleSeparator) {
pos = indirectValue.end;
node.type = "indirect";
node.textReference = indirectValue.match[1];
@@ -328,13 +330,13 @@ exports.parseMacroParameterAsAttribute = function(source,pos) {
} else {
// Look for a macro invocation value
var macroInvocation = $tw.utils.parseMacroInvocationAsTransclusion(source,pos);
if(macroInvocation) {
if(macroInvocation && isNewStyleSeparator) {
pos = macroInvocation.end;
node.type = "macro";
node.value = macroInvocation;
} else {
var substitutedValue = $tw.utils.parseTokenRegExp(source,pos,reSubstitutedValue);
if(substitutedValue) {
if(substitutedValue && isNewStyleSeparator) {
pos = substitutedValue.end;
node.type = "substituted";
node.rawValue = substitutedValue.match[1] || substitutedValue.match[2];

View File

@@ -11,7 +11,7 @@ It is $param$
<$text text=<<mamacromamacro>>/>
-
<$text text=<<mamacromamacro param:{{{ [[a]addprefix[b]] }}}>>/>
<$text text=<<mamacromamacro param={{{ [[a]addprefix[b]] }}}>>/>
-
<$text text=<<mamacromamacro param={{{ [[b]addprefix[a]] }}}>>/>
-

View File

@@ -13,8 +13,6 @@ It is $one$ and $two$ or <<__one__>> and <<__two__>>.
<<mamacro>>
<<mamacro one:{{{ [[a]addprefix[b]] }}}>>
<<mamacro one={{{ [[b]addprefix[a]] }}}>>
<<mamacro {{{ [[b]addprefix[a]] }}}>>
@@ -23,4 +21,4 @@ It is $one$ and $two$ or <<__one__>> and <<__two__>>.
+
title: ExpectedResult
<p>It is red and green or red and green.</p><p>It is ba and green or ba and green.</p><p>It is ab and green or ab and green.</p><p>It is ab and green or ab and green.</p><p>It is one and green or one and green.</p>
<p>It is red and green or red and green.</p><p>It is ab and green or ab and green.</p><p>It is ab and green or ab and green.</p><p>It is one and green or one and green.</p>