mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-02-11 20:50:20 +00:00
Compare commits
5 Commits
fully-rend
...
nested-mac
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f823885d67 | ||
|
|
f23ae21260 | ||
|
|
b3982efcd6 | ||
|
|
24dbf69180 | ||
|
|
7b408c7adf |
@@ -19,13 +19,13 @@ exports.variable = function(source,prefix,options) {
|
||||
var results = [];
|
||||
if(prefix === "!") {
|
||||
source(function(tiddler,title) {
|
||||
if(!(title in options.widget.variables)) {
|
||||
if(options.widget.getVariable(title) === undefined) {
|
||||
results.push(title);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
source(function(tiddler,title) {
|
||||
if(title in options.widget.variables) {
|
||||
if(options.widget.getVariable(title) !== undefined) {
|
||||
results.push(title);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -16,9 +16,15 @@ Filter operator for returning the names of the active variables
|
||||
Export our filter function
|
||||
*/
|
||||
exports.variables = function(source,operator,options) {
|
||||
var names = [];
|
||||
for(var variable in options.widget.variables) {
|
||||
names.push(variable);
|
||||
var names = [],
|
||||
widget = options.widget;
|
||||
while(widget && !widget.hasOwnProperty("variables")) {
|
||||
widget = widget.parentWidget;
|
||||
}
|
||||
if(widget && widget.variables) {
|
||||
for(var variable in widget.variables) {
|
||||
names.push(variable);
|
||||
}
|
||||
}
|
||||
return names.sort();
|
||||
};
|
||||
|
||||
@@ -58,7 +58,7 @@ exports.parse = function() {
|
||||
var reEnd;
|
||||
if(this.match[3]) {
|
||||
// If so, the end of the body is marked with \end
|
||||
reEnd = /(\r?\n\\end[^\S\n\r]*(?:$|\r?\n))/mg;
|
||||
reEnd = new RegExp("(\\r?\\n\\\\end[^\\S\\n\\r]*(?:" + $tw.utils.escapeRegExp(this.match[1]) + ")?(?:$|\\r?\\n))","mg");
|
||||
} else {
|
||||
// Otherwise, the end of the definition is marked by the end of the line
|
||||
reEnd = /($|\r?\n)/mg;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
caption: 5.2.4
|
||||
created: 20220924141149286
|
||||
modified: 20220924141149286
|
||||
created: 20221017165036377
|
||||
modified: 20221017165036377
|
||||
tags: ReleaseNotes
|
||||
title: Release 5.2.4
|
||||
type: text/vnd.tiddlywiki
|
||||
@@ -16,6 +16,8 @@ type: text/vnd.tiddlywiki
|
||||
Improvements to the following translations:
|
||||
|
||||
* Chinese
|
||||
* Polish
|
||||
* Spanish
|
||||
* Japanese
|
||||
|
||||
Improvements to the translation features of TiddlyWiki:
|
||||
@@ -32,6 +34,9 @@ Improvements to the translation features of TiddlyWiki:
|
||||
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/commit/d62a16ee464fb9984b766b48504829a1a3eb143b">> problem with long presses on tiddler links triggering a preview on iOS/iPadOS
|
||||
* <<.link-badge-improved "https://github.com/Jermolene/TiddlyWiki5/pull/6910">> consistency of button and input elements across browsers
|
||||
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/commit/d825f1c875f5e46158c9c41c8c66471138c162d1">> edit preview to use the [[View Template Body Cascade]]
|
||||
* <<.link-badge-improved "https://github.com/Jermolene/TiddlyWiki5/pull/6970">> detection of infinite recursion errors in widgets and filters
|
||||
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/commit/36896c3db8c9678c0385a561996248a6f00a45ff">> opening a tiddler in a new window to use the [[View Template Body Cascade]]
|
||||
* <<.link-badge-extended "https://github.com/Jermolene/TiddlyWiki5/pull/6877">> default styles for [[styled runs|Styles and Classes in WikiText]]
|
||||
|
||||
! Widget Improvements
|
||||
|
||||
@@ -47,12 +52,14 @@ Improvements to the translation features of TiddlyWiki:
|
||||
* <<.link-badge-added "https://github.com/Jermolene/TiddlyWiki5/pull/6936">> new operators for reading and formatting JSON data: [[jsonget Operator]], [[jsonindexes Operator]], [[jsontype Operator]] and [[format Operator]]
|
||||
* <<.link-badge-improved "https://github.com/Jermolene/TiddlyWiki5/commit/c5d3d4c26e8fe27f272dda004aec27d6b66c4f60">> safe mode to disable wiki store indexers
|
||||
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/commit/166a1565843878083fb1eba47c73b8e67b78400d">> safe mode to prevent globally disabling parser rules
|
||||
|
||||
* <<.link-badge-removed "https://github.com/Jermolene/TiddlyWiki5/commit/1df4c29d73073788ba3859668112e8bb46171a6c">> restriction of the LetWidget being unable to create variables whose names begin with a dollar sign
|
||||
* <<.link-badge-extended "https://github.com/Jermolene/TiddlyWiki5/pull/6735">> keyboard shortcut handling to allow to global shortcuts to override all other shortcuts
|
||||
|
||||
|
||||
! Bug Fixes
|
||||
|
||||
*
|
||||
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/commit/fb34df84ed41882c1c2a6ff54f0e908b43ef95a3">> "new image" keyboard shortcut not to assign journal tags
|
||||
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/pull/6987">> SelectWidget class to update if it uses a filter
|
||||
|
||||
! Developer Improvements
|
||||
|
||||
|
||||
27
editions/test/tiddlers/tests/data/filters/fake-variables.tid
Normal file
27
editions/test/tiddlers/tests/data/filters/fake-variables.tid
Normal file
@@ -0,0 +1,27 @@
|
||||
title: Filters/FakeVariables
|
||||
description: Test for https://github.com/Jermolene/TiddlyWiki5/issues/6303
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
<$list variable="var" filter="[[existing variable should have output]] :filter[[..currentTiddler]is[variable]]">
|
||||
<p><<var>></p>
|
||||
</$list>
|
||||
|
||||
<$list variable="var" filter="[[non-existing variable should not have output]] :filter[[nonExistingVariable]is[variable]]">
|
||||
<p><<var>></p>
|
||||
</$list>
|
||||
|
||||
<$list variable="var" filter="[[existing variable negated should not have output]] :filter[[..currentTiddler]!is[variable]]">
|
||||
<p><<var>></p>
|
||||
</$list>
|
||||
|
||||
<$list variable="var" filter="[[non-existing variable negated should have output]] :filter[[nonExistingVariable]!is[variable]]">
|
||||
<p><<var>></p>
|
||||
</$list>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p><p>existing variable should have output</p></p><p></p><p></p><p><p>non-existing variable negated should have output</p></p>
|
||||
36
editions/test/tiddlers/tests/data/macros/NestedMacros.tid
Normal file
36
editions/test/tiddlers/tests/data/macros/NestedMacros.tid
Normal file
@@ -0,0 +1,36 @@
|
||||
title: Macros/NestedMacros
|
||||
description: Nested Macros
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
|
||||
\define outer()
|
||||
\whitespace trim
|
||||
|
||||
\define middle()
|
||||
\whitespace trim
|
||||
|
||||
\define inner()
|
||||
\whitespace trim
|
||||
|
||||
Jaguar
|
||||
|
||||
\end inner
|
||||
|
||||
<<inner>>
|
||||
|
||||
\end middle
|
||||
|
||||
<<middle>>
|
||||
|
||||
\end outer
|
||||
|
||||
<<outer>>
|
||||
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>Jaguar</p>
|
||||
@@ -1,13 +1,15 @@
|
||||
caption: Macro Definitions
|
||||
created: 20150220181617000
|
||||
modified: 20180820165115455
|
||||
modified: 20221022135909352
|
||||
tags: WikiText
|
||||
title: Macro Definitions in WikiText
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
A [[macro|Macros]] is defined using a `\define` [[pragma|Pragma]]. Like any pragma, this can only appear at the start of a tiddler.
|
||||
|
||||
The first line of the definition specifies the macro name and any parameters. Each parameter has a name and, optionally, a default value that is used if no value is supplied on a particular call to the macro. The lines that follow contain the text of the macro text (i.e. the snippet represented by the macro name), until `\end` appears on a line by itself:
|
||||
The first line of the definition specifies the macro name and any parameters. Each parameter has a name and, optionally, a default value that is used if no value is supplied on a particular call to the macro.
|
||||
|
||||
The lines that follow contain the text of the macro text (i.e. the snippet represented by the macro name), until `\end` appears on a line by itself:
|
||||
|
||||
<$codeblock code={{$:/editions/tw5.com/macro-examples/say-hi}}/>
|
||||
|
||||
@@ -17,6 +19,20 @@ Alternatively, the entire definition can be presented on a single line without a
|
||||
\define sayhi(name:"Bugs Bunny") Hi, I'm $name$.
|
||||
```
|
||||
|
||||
Macro definitions can be nested by specifying the name of the macro in the `\end` marker. For example:
|
||||
|
||||
<<wikitext-example-without-html src:"""\define special-button(caption:"Click me")
|
||||
\define actions()
|
||||
<$action-sendmessage $message="tm-notify" $param="HelloThere"/>
|
||||
\end actions
|
||||
<$button actions=<<actions>>>
|
||||
$caption$
|
||||
</$button>
|
||||
\end special-button
|
||||
|
||||
<<special-button>>
|
||||
""">>
|
||||
|
||||
A more formal [[presentation|Macro Definition Syntax]] of this syntax is also available.
|
||||
|
||||
!! Accessing variables and parameters
|
||||
|
||||
Reference in New Issue
Block a user