1
0
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:
Saq Imtiaz
2023-06-24 15:57:15 +02:00
committed by GitHub
parent e5566543c9
commit 3825e2579f
17 changed files with 361 additions and 66 deletions

View File

@@ -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";
}
}
}
}