From 69637640d2eb0cd062b18a453d27f45e0f748d4c Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Mon, 2 Sep 2024 16:51:15 +0100 Subject: [PATCH] Standardise whitespace in conditional shortcut syntax (#8583) --- .../parsers/wikiparser/rules/conditional.js | 4 +-- core/ui/AdvancedSearch/Shadows.tid | 6 ++-- core/ui/AdvancedSearch/System.tid | 6 ++-- core/wiki/macros/tag-picker.tid | 20 ++++++------ .../tests/data/conditionals/Basic.tid | 2 +- .../tests/data/conditionals/BlockMode.tid | 12 +++---- .../tiddlers/tests/data/conditionals/Else.tid | 2 +- .../tests/data/conditionals/Elseif.tid | 2 +- .../tests/data/conditionals/MissingEndIf.tid | 2 +- .../data/conditionals/MultipleResults.tid | 2 +- .../tests/data/conditionals/Nested.tid | 12 +++---- .../tests/data/conditionals/NestedElseif.tid | 16 +++++----- .../tiddlers/empty-tag-node-template.tid | 4 +-- .../tiddlers/releasenotes/Release 5.3.2.tid | 8 ++--- .../tw5.com/tiddlers/system/doc-macros.tid | 2 +- .../tiddlers/system/filter-run-template.tid | 8 ++--- .../tiddlers/system/operator-macros.tid | 4 +-- .../tiddlers/system/operator-template.tid | 8 ++--- .../tiddlers/system/version-macros.tid | 6 ++-- .../tiddlers/widgets/EditTextWidget.tid | 2 +- .../tw5.com/tiddlers/widgets/EditWidget.tid | 2 +- .../wikitext/Conditional Shortcut Syntax.tid | 32 +++++++++---------- .../tiddlywiki/github-fork-ribbon/usage.tid | 8 ++--- 23 files changed, 85 insertions(+), 85 deletions(-) diff --git a/core/modules/parsers/wikiparser/rules/conditional.js b/core/modules/parsers/wikiparser/rules/conditional.js index 23940fd88..c2d6a43b8 100644 --- a/core/modules/parsers/wikiparser/rules/conditional.js +++ b/core/modules/parsers/wikiparser/rules/conditional.js @@ -6,7 +6,7 @@ module-type: wikirule Conditional shortcut syntax ``` -This is a <% if [{something}] %>Elephant<% elseif [{else}] %>Pelican<% else %>Crocodile<% endif %> +This is a <%if [{something}] %>Elephant<%elseif [{else}] %>Pelican<%else%>Crocodile<%endif%> ``` \*/ @@ -27,7 +27,7 @@ exports.init = function(parser) { }; exports.findNextMatch = function(startPos) { - // Look for the next <% if shortcut + // Look for the next <%if shortcut this.matchRegExp.lastIndex = startPos; this.match = this.matchRegExp.exec(this.parser.source); // If not found then return no match diff --git a/core/ui/AdvancedSearch/Shadows.tid b/core/ui/AdvancedSearch/Shadows.tid index daa8e6c2c..043aee590 100644 --- a/core/ui/AdvancedSearch/Shadows.tid +++ b/core/ui/AdvancedSearch/Shadows.tid @@ -83,11 +83,11 @@ first-search-filter: [all[shadows]searchsort[title]limit[250]] -[[$:/
-<% if [match[0]] %> +<%if [match[0]] %> {{$:/language/Search/Matches/NoMatch}} -<% else %> +<%else%> <> -<% endif %> +<%endif%> <$list filter="[all[shadows]search{$:/temp/advancedsearch}sort[title]limit[250]] -[[$:/temp/advancedsearch]] -[[$:/temp/advancedsearch/input]]"> addsuffix[-primaryList]] -[[$:/temp/advancedsearch/selected-item]get[text]] +[then[]else[tc-list-item-selected]] }}}> diff --git a/core/ui/AdvancedSearch/System.tid b/core/ui/AdvancedSearch/System.tid index ca9584ed7..5e1ec0254 100644 --- a/core/ui/AdvancedSearch/System.tid +++ b/core/ui/AdvancedSearch/System.tid @@ -82,11 +82,11 @@ first-search-filter: [is[system]searchsort[title]limit[250]] -[[$:/te
-<% if [match[0]] %> +<%if [match[0]] %> {{$:/language/Search/Matches/NoMatch}} -<% else %> +<%else%> <> -<% endif %> +<%endif%> <$list filter="[is[system]search{$:/temp/advancedsearch}sort[title]limit[250]] -[[$:/temp/advancedsearch]] -[[$:/temp/advancedsearch/input]] -[[$:/temp/advancedsearch/selected-item]]"> addsuffix[-primaryList]] -[[$:/temp/advancedsearch/selected-item]get[text]] +[then[]else[tc-list-item-selected]] }}}> diff --git a/core/wiki/macros/tag-picker.tid b/core/wiki/macros/tag-picker.tid index 697ac777e..4186f4138 100644 --- a/core/wiki/macros/tag-picker.tid +++ b/core/wiki/macros/tag-picker.tid @@ -31,11 +31,11 @@ second-search-filter: [subfilteris[system]search:title \procedure add-tag-actions() <$let tag=<<_tf.getTag>> > <$action-listops $tiddler=<> $field=<> $subfilter='+[toggletrim[]]'/> - <% if [] :intersection[getenlist-input[]] %> + <%if [] :intersection[getenlist-input[]] %> - <% else %> + <%else%> <> - <% endif %> + <%endif%> <> <$action-setfield $tiddler=<> text="yes"/> @@ -46,11 +46,11 @@ second-search-filter: [subfilteris[system]search:title The second ESC tries to close the "draft tiddler" --> \procedure clear-tags-actions-inner() -<% if [has[text]] ~[has[text]] %> +<%if [has[text]] ~[has[text]] %> <> -<% else %> +<%else%> <> -<% endif %> +<%endif%> \end @@ -128,13 +128,13 @@ The second ESC tries to close the "draft tiddler" > {{$:/core/images/down-arrow}} - <% if [has[text]] %> + <%if [has[text]] %> <$button actions=<> class="tc-btn-invisible tc-small-gap tc-btn-dropdown" tooltip={{$:/language/EditTemplate/Tags/ClearInput/Hint}} aria-label={{$:/language/EditTemplate/Tags/ClearInput/Caption}} > {{$:/core/images/close-button}} - <% endif %> + <%endif%> <$let tag=<<_tf.getTag>>> <$button set=<> actions=<> > @@ -144,13 +144,13 @@ The second ESC tries to close the "draft tiddler"
- <% if [has[text]] %> + <%if [has[text]] %>
<$macrocall $name="tag-picker-listTags" filter=<> suffix="-primaryList" />
<$macrocall $name="tag-picker-listTags" filter=<> suffix="-secondaryList" />
- <% endif %> + <%endif%>
\end diff --git a/editions/test/tiddlers/tests/data/conditionals/Basic.tid b/editions/test/tiddlers/tests/data/conditionals/Basic.tid index ff2d2df4d..6e5046f56 100644 --- a/editions/test/tiddlers/tests/data/conditionals/Basic.tid +++ b/editions/test/tiddlers/tests/data/conditionals/Basic.tid @@ -5,7 +5,7 @@ tags: [[$:/tags/wiki-test-spec]] title: Text -This is a <% if [match[one]] %>Elephant<% endif %>, I think. +This is a <%if [match[one]] %>Elephant<%endif%>, I think. + title: Output diff --git a/editions/test/tiddlers/tests/data/conditionals/BlockMode.tid b/editions/test/tiddlers/tests/data/conditionals/BlockMode.tid index 45233baa4..c41b34563 100644 --- a/editions/test/tiddlers/tests/data/conditionals/BlockMode.tid +++ b/editions/test/tiddlers/tests/data/conditionals/BlockMode.tid @@ -6,23 +6,23 @@ tags: [[$:/tags/wiki-test-spec]] title: Output \procedure test(animal) -<% if [match[Elephant]] %> +<%if [match[Elephant]] %> ! It is an elephant -<% else %> +<%else%> -<% if [match[Giraffe]] %> +<%if [match[Giraffe]] %> ! It is a giraffe -<% else %> +<%else%> ! It is completely unknown -<% endif %> +<%endif%> -<% endif %> +<%endif%> \end diff --git a/editions/test/tiddlers/tests/data/conditionals/Else.tid b/editions/test/tiddlers/tests/data/conditionals/Else.tid index 7bc32b34e..ef42f198c 100644 --- a/editions/test/tiddlers/tests/data/conditionals/Else.tid +++ b/editions/test/tiddlers/tests/data/conditionals/Else.tid @@ -5,7 +5,7 @@ tags: [[$:/tags/wiki-test-spec]] title: Text -This is a <% if [match[one]] %>Elephant<% else %>Crocodile<% endif %>, I think. +This is a <%if [match[one]] %>Elephant<%else%>Crocodile<%endif%>, I think. + title: Output diff --git a/editions/test/tiddlers/tests/data/conditionals/Elseif.tid b/editions/test/tiddlers/tests/data/conditionals/Elseif.tid index d37f3380c..068ac31c9 100644 --- a/editions/test/tiddlers/tests/data/conditionals/Elseif.tid +++ b/editions/test/tiddlers/tests/data/conditionals/Elseif.tid @@ -5,7 +5,7 @@ tags: [[$:/tags/wiki-test-spec]] title: Text -This is a <% if [match[one]] %>Elephant<% elseif [match[two]] %>Antelope<% else %>Crocodile<% endif %>, I think. +This is a <%if [match[one]] %>Elephant<%elseif [match[two]] %>Antelope<%else%>Crocodile<%endif%>, I think. + title: Output diff --git a/editions/test/tiddlers/tests/data/conditionals/MissingEndIf.tid b/editions/test/tiddlers/tests/data/conditionals/MissingEndIf.tid index cacaf9869..ff01ca959 100644 --- a/editions/test/tiddlers/tests/data/conditionals/MissingEndIf.tid +++ b/editions/test/tiddlers/tests/data/conditionals/MissingEndIf.tid @@ -5,7 +5,7 @@ tags: [[$:/tags/wiki-test-spec]] title: Text -This is a <% if [match[one]] %>Elephant +This is a <%if [match[one]] %>Elephant + title: Output diff --git a/editions/test/tiddlers/tests/data/conditionals/MultipleResults.tid b/editions/test/tiddlers/tests/data/conditionals/MultipleResults.tid index baa966ed5..866c6d8f5 100644 --- a/editions/test/tiddlers/tests/data/conditionals/MultipleResults.tid +++ b/editions/test/tiddlers/tests/data/conditionals/MultipleResults.tid @@ -5,7 +5,7 @@ tags: [[$:/tags/wiki-test-spec]] title: Output -This is a <% if 1 2 3 4 5 6 %>Elephant<% endif %>, I think. +This is a <%if 1 2 3 4 5 6 %>Elephant<%endif%>, I think. + title: ExpectedResult diff --git a/editions/test/tiddlers/tests/data/conditionals/Nested.tid b/editions/test/tiddlers/tests/data/conditionals/Nested.tid index dffa791fc..e5ea9fc40 100644 --- a/editions/test/tiddlers/tests/data/conditionals/Nested.tid +++ b/editions/test/tiddlers/tests/data/conditionals/Nested.tid @@ -6,15 +6,15 @@ tags: [[$:/tags/wiki-test-spec]] title: Output \procedure test(animal) -<% if [match[Elephant]] %> +<%if [match[Elephant]] %> It is an elephant -<% else %> -<% if [match[Giraffe]] %> +<%else%> +<%if [match[Giraffe]] %> It is a giraffe -<% else %> +<%else%> It is completely unknown -<% endif %> -<% endif %> +<%endif%> +<%endif%> \end <> diff --git a/editions/test/tiddlers/tests/data/conditionals/NestedElseif.tid b/editions/test/tiddlers/tests/data/conditionals/NestedElseif.tid index 6fba8cac8..bfc3e085c 100644 --- a/editions/test/tiddlers/tests/data/conditionals/NestedElseif.tid +++ b/editions/test/tiddlers/tests/data/conditionals/NestedElseif.tid @@ -7,20 +7,20 @@ title: Text \whitespace trim This is a - <% if [match[one]] %> - <% if [match[one]] %> + <%if [match[one]] %> + <%if [match[one]] %> Indian - <% elseif [match[two]] %> + <%elseif [match[two]] %> African - <% else %> + <%else%> Unknown - <% endif %> + <%endif%> Elephant - <% elseif [match[two]] %> + <%elseif [match[two]] %> Antelope - <% else %> + <%else%> Crocodile - <% endif %> + <%endif%> , I think. + title: Output diff --git a/editions/tw5.com/tiddlers/empty-tag-node-template.tid b/editions/tw5.com/tiddlers/empty-tag-node-template.tid index 79905b77c..96c77e76b 100644 --- a/editions/tw5.com/tiddlers/empty-tag-node-template.tid +++ b/editions/tw5.com/tiddlers/empty-tag-node-template.tid @@ -5,8 +5,8 @@ tags: $:/tags/ViewTemplate title: $:/editions/tw5.com/empty-tag-node-template type: -<% if [!has[text]!has[tags]tagging[]] %> +<%if [!has[text]!has[tags]tagging[]] %> The following tiddlers are tagged with <>: <!has[text]!has[tags]tagging[]]" class:"multi-columns">> -<% endif %> \ No newline at end of file +<%endif%> \ No newline at end of file diff --git a/editions/tw5.com/tiddlers/releasenotes/Release 5.3.2.tid b/editions/tw5.com/tiddlers/releasenotes/Release 5.3.2.tid index d99d537c1..56f54cbb0 100644 --- a/editions/tw5.com/tiddlers/releasenotes/Release 5.3.2.tid +++ b/editions/tw5.com/tiddlers/releasenotes/Release 5.3.2.tid @@ -23,13 +23,13 @@ type: text/vnd.tiddlywiki These new token-based shortcuts allow a richer structure and expressivity than existing features such as widgets or pragmas. For example: ``` -<% if [match[Elephant]] %> +<%if [match[Elephant]] %> It is an elephant -<% elseif [match[Giraffe]] %> +<%elseif [match[Giraffe]] %> It is a giraffe -<% else %> +<%else%> It is completely unknown -<% endif %> +<%endif%> ``` Behind the scenes, the conditional shortcut syntax is rendered as the equivalent [[ListWidgets|ListWidget]]. diff --git a/editions/tw5.com/tiddlers/system/doc-macros.tid b/editions/tw5.com/tiddlers/system/doc-macros.tid index d0574fe5f..199479fb8 100644 --- a/editions/tw5.com/tiddlers/system/doc-macros.tid +++ b/editions/tw5.com/tiddlers/system/doc-macros.tid @@ -119,7 +119,7 @@ type: text/vnd.tiddlywiki \procedure .infoBox(text:"", title, icon:"$:/core/images/info-button", class, iconSize:"1.4rem") \function _f.tipClass() [[doc-icon-block]] [!is[blank]then] +[join[ ]]
>> - <%if [!is[blank]] %><div>''<<title>>''</div><% endif %> + <%if [<title>!is[blank]] %><div>''<<title>>''</div><%endif%> <div class="doc-block-icon"><$transclude $tiddler=<<icon>> size=<<iconSize>>/></div> <<text>> </div> diff --git a/editions/tw5.com/tiddlers/system/filter-run-template.tid b/editions/tw5.com/tiddlers/system/filter-run-template.tid index 73b4a2510..c559d8bdd 100644 --- a/editions/tw5.com/tiddlers/system/filter-run-template.tid +++ b/editions/tw5.com/tiddlers/system/filter-run-template.tid @@ -9,18 +9,18 @@ type: text/vnd.tiddlywiki \whitespace trim \procedure .op-place() -<% if [<op-name>!is[blank]] %> +<%if [<op-name>!is[blank]] %> <$macrocall $name=".place" _=<<op-name>> /><span class="tc-tiny-gap">=</span> -<% endif %> +<%endif%> \end \procedure .op-row() -<% if [<op-body>!is[blank]] %> +<%if [<op-body>!is[blank]] %> <tr> <th align="left"><<op-head>></th> <td><<.op-place>><<op-body>></td> </tr> -<% endif %> +<%endif%> \end <$list filter="[all[current]tag[Named Filter Run Prefix]]"> diff --git a/editions/tw5.com/tiddlers/system/operator-macros.tid b/editions/tw5.com/tiddlers/system/operator-macros.tid index 2b19d56db..e2dce9e2d 100644 --- a/editions/tw5.com/tiddlers/system/operator-macros.tid +++ b/editions/tw5.com/tiddlers/system/operator-macros.tid @@ -16,9 +16,9 @@ title: $:/editions/tw5.com/operator-macros <$list filter="[title<.state-prefix>addsuffix{!!title}addsuffix[/]addsuffix<n>]" variable=".state"> <$reveal state=<<.state>> type="nomatch" text="show"> <code><$text text=<<eg>>/></code> - <% if [<ie>!is[blank]] %> + <%if [<ie>!is[blank]] %> <dd>→ <<ie>></dd> - <% endif %> + <%endif%> <dl> <dd><$button actions=<<.operator-example-tryit-actions>>>Try it</$button></dd> </dl> diff --git a/editions/tw5.com/tiddlers/system/operator-template.tid b/editions/tw5.com/tiddlers/system/operator-template.tid index f4f3e08ef..47096f79c 100644 --- a/editions/tw5.com/tiddlers/system/operator-template.tid +++ b/editions/tw5.com/tiddlers/system/operator-template.tid @@ -8,17 +8,17 @@ title: $:/editions/tw5.com/operator-template \whitespace trim \procedure .op-place() -<% if [<op-name>!is[blank]] %> +<%if [<op-name>!is[blank]] %> <$macrocall $name=".place" _=<<op-name>> /><span class="tc-tiny-gap">=</span> -<% endif %> +<%endif%> \end \procedure .op-row() -<% if [<op-body>!is[blank]] %> +<%if [<op-body>!is[blank]] %> <tr> <th align="left"><<op-head>></th><td><<.op-place>><<op-body>></td> </tr> -<% endif %> +<%endif%> \end <$list filter="[all[current]tag[Filter Operators]]"> diff --git a/editions/tw5.com/tiddlers/system/version-macros.tid b/editions/tw5.com/tiddlers/system/version-macros.tid index c03f4237c..35e98cf71 100644 --- a/editions/tw5.com/tiddlers/system/version-macros.tid +++ b/editions/tw5.com/tiddlers/system/version-macros.tid @@ -19,11 +19,11 @@ type: text/vnd.tiddlywiki \end \procedure .from-version(version) -<% if [<version>compare:version:gteq<tf.from-version-reference>] %> +<%if [<version>compare:version:gteq<tf.from-version-reference>] %> <<.from-version-template "doc-from-version doc-from-version-new" "New in v">> -<% else %> +<%else%> <<.from-version-template "doc-from-version" "Introduced in v">> -<% endif %> +<%endif%> \end \procedure .deprecated-since(version, superseded:"") diff --git a/editions/tw5.com/tiddlers/widgets/EditTextWidget.tid b/editions/tw5.com/tiddlers/widgets/EditTextWidget.tid index dcfd088fb..609cf36ff 100644 --- a/editions/tw5.com/tiddlers/widgets/EditTextWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/EditTextWidget.tid @@ -75,7 +75,7 @@ eg="""<$edit-text tiddler=<<currentTiddler>> field="heading" size="25" focus="ye eg="""\procedure onInput() <%if [get[temp]match[$:/]] %> <$action-confirm $message="Yes, this is how system tiddler names begin!"/> - <% endif %> + <%endif%> \end Type a new tiddler name, starting with the system prefix `$:/`: <$edit-text inputActions=<<onInput>> field="temp" class="tc-edit-texteditor"/> diff --git a/editions/tw5.com/tiddlers/widgets/EditWidget.tid b/editions/tw5.com/tiddlers/widgets/EditWidget.tid index 2b72aa8ec..6822d4d77 100644 --- a/editions/tw5.com/tiddlers/widgets/EditWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/EditWidget.tid @@ -26,7 +26,7 @@ The content of the `<$edit>` widget is ignored. ! Examples -!! Edit the contents (text field) of a tiddler titled <%if [<now YYYY-0MM-0DD>is[tiddler]] %> <$tiddler tiddler=<<now YYYY-0MM-0DD>> > <$link/></$tiddler> <%else %> with today’s date <% endif %> +!! Edit the contents (text field) of a tiddler titled <%if [<now YYYY-0MM-0DD>is[tiddler]] %> <$tiddler tiddler=<<now YYYY-0MM-0DD>> > <$link/></$tiddler> <%else %> with today’s date <%endif%> <$macrocall $name=".example" n="1" eg="""<$edit tiddler=<<now YYYY-0MM-0DD>> class="tc-edit-texteditor"/> diff --git a/editions/tw5.com/tiddlers/wikitext/Conditional Shortcut Syntax.tid b/editions/tw5.com/tiddlers/wikitext/Conditional Shortcut Syntax.tid index 8cef3acfb..48ff59757 100644 --- a/editions/tw5.com/tiddlers/wikitext/Conditional Shortcut Syntax.tid +++ b/editions/tw5.com/tiddlers/wikitext/Conditional Shortcut Syntax.tid @@ -11,40 +11,40 @@ Within an "if" or "elseif" clause, the variable `condition` contains the value o A simple example: <$macrocall $name='wikitext-example-without-html' -src='<% if [{$:/info/url/protocol}match[file:]] %> +src='<%if [{$:/info/url/protocol}match[file:]] %> Loaded from a file URI -<% else %> +<%else%> Not loaded from a file URI -<% endif %> +<%endif%> '/> -One or more `<% elseif %>` clauses may be included before the `<% else %>` clause: +One or more `<%elseif%>` clauses may be included before the `<%else%>` clause: <$macrocall $name='wikitext-example-without-html' -src='<% if [{$:/info/url/protocol}match[file:]] %> +src='<%if [{$:/info/url/protocol}match[file:]] %> Loaded from a file URI -<% elseif [{$:/info/url/protocol}match[https:]] %> +<%elseif [{$:/info/url/protocol}match[https:]] %> Loaded from an HTTPS URI -<% elseif [{$:/info/url/protocol}match[http:]] %> +<%elseif [{$:/info/url/protocol}match[http:]] %> Loaded from an HTTP URI -<% else %> +<%else%> Loaded from an unknown protocol -<% endif %> +<%endif%> '/> The conditional shortcut syntax can be nested: <$macrocall $name='wikitext-example-without-html' src='\procedure test(animal) -<% if [<animal>match[Elephant]] %> +<%if [<animal>match[Elephant]] %> It is an elephant -<% else %> - <% if [<animal>match[Giraffe]] %> +<%else%> + <%if [<animal>match[Giraffe]] %> It is a giraffe - <% else %> + <%else%> It is completely unknown - <% endif %> -<% endif %> + <%endif%> +<%endif%> \end <<test "Giraffe">> @@ -56,7 +56,7 @@ src='\procedure test(animal) Notes: -* Clauses are parsed in inline mode by default. Force block mode parsing by following the opening `<% if %>`, `<% elseif %>` or `<% else %>` with two line breaks +* Clauses are parsed in inline mode by default. Force block mode parsing by following the opening `<%if %>`, `<%elseif%>` or `<%else%>` with two line breaks * Widgets and HTML elements must be within a single conditional clause; it is not possible to start an element in one conditional clause and end it in another * The conditional shortcut syntax cannot contain pragmas such as procedure definitions diff --git a/plugins/tiddlywiki/github-fork-ribbon/usage.tid b/plugins/tiddlywiki/github-fork-ribbon/usage.tid index 2c1388da0..c91566b69 100644 --- a/plugins/tiddlywiki/github-fork-ribbon/usage.tid +++ b/plugins/tiddlywiki/github-fork-ribbon/usage.tid @@ -6,11 +6,11 @@ title: $:/plugins/tiddlywiki/github-fork-ribbon/usage \end \procedure ribbonCreateActions() -<% if [[$:/github-ribbon]!is[tiddler]] %> +<%if [[$:/github-ribbon]!is[tiddler]] %> <$action-setfield $tiddler="$:/github-ribbon" $field="text" $value=<<ribbonCode>> tags="$:/tags/PageTemplate" code-body="yes" /> -<% endif %> +<%endif%> <$action-navigate $to="$:/github-ribbon" /> \end @@ -18,9 +18,9 @@ title: $:/plugins/tiddlywiki/github-fork-ribbon/usage <$button actions=<<ribbonCreateActions>> > <%if [[$:/github-ribbon]!is[tiddler]] %> Create -<% else %> +<%else%> Show -<% endif %> ~$:/github-ribbon +<%endif%> ~$:/github-ribbon </$button> \end