mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-12-16 21:58:06 +00:00
Adds Text substitution support in widget attributes and new operator (#7526)
* feat: new text substitution support, first pass * fix: use the widget method instead of evaluating a filter * revert to earlier implementation that emulates macro syntax * fix: capitalize comments * feat: add support for triple backticks for substituted attributes * docs: added docs for substitute operator * chore: more docs tweaks * docs: substituted attributes, refactored docs for widget attributes * docs: fixed typo * docs: more examples for substituted attributes * docs: updated prior documentation on concatenating text and variables * docs: documentation corrections * Update editions/tw5.com/tiddlers/filters/examples/substitute Operator (Examples).tid Co-authored-by: btheado <brian.theado@gmail.com> --------- Co-authored-by: btheado <brian.theado@gmail.com>
This commit is contained in:
@@ -305,10 +305,11 @@ exports.parseAttribute = function(source,pos) {
|
||||
start: pos
|
||||
};
|
||||
// Define our regexps
|
||||
var reAttributeName = /([^\/\s>"'=]+)/g,
|
||||
reUnquotedAttribute = /([^\/\s<>"'=]+)/g,
|
||||
var reAttributeName = /([^\/\s>"'`=]+)/g,
|
||||
reUnquotedAttribute = /([^\/\s<>"'`=]+)/g,
|
||||
reFilteredValue = /\{\{\{([\S\s]+?)\}\}\}/g,
|
||||
reIndirectValue = /\{\{([^\}]+)\}\}/g;
|
||||
reIndirectValue = /\{\{([^\}]+)\}\}/g,
|
||||
reSubstitutedValue = /(?:```([\s\S]*?)```|`([^`]|[\S\s]*?)`)/g;
|
||||
// Skip whitespace
|
||||
pos = $tw.utils.skipWhiteSpace(source,pos);
|
||||
// Get the attribute name
|
||||
@@ -361,8 +362,15 @@ exports.parseAttribute = function(source,pos) {
|
||||
node.type = "macro";
|
||||
node.value = macroInvocation;
|
||||
} else {
|
||||
node.type = "string";
|
||||
node.value = "true";
|
||||
var substitutedValue = $tw.utils.parseTokenRegExp(source,pos,reSubstitutedValue);
|
||||
if(substitutedValue) {
|
||||
pos = substitutedValue.end;
|
||||
node.type = "substituted";
|
||||
node.rawValue = substitutedValue.match[1] || substitutedValue.match[2];
|
||||
} else {
|
||||
node.type = "string";
|
||||
node.value = "true";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user