How to use nested list filter

I hope to use a filter to determine whether it is in https status, but when the button is clicked, the outermost filter seems to affect it, causing the click to be invalid.

<$list filter="[{$:/info/url/protocol}match[http:]]" >
  <$list filter="[all[shadows+tiddlers]tag[$:/tags/ViewToolbar]!has[draft.of]] :filter[lookup[$:/config/ViewToolbarButtons/Visibility/]!match[hide]]" storyview="pop" variable="listItem">
  <$set name="tv-config-toolbar-class" filter="[<tv-config-toolbar-class>] [<listItem>encodeuricomponent[]addprefix[tc-btn-]]"><$transclude tiddler=<<listItem>>/></$set>
  </$list>
</$list>
<$list filter="[{$:/info/url/protocol}match[https:]]" >
  <$list filter="[[$:/core/ui/Buttons/permalink]] [[$:/core/ui/Buttons/close]]" storyview="pop" variable="listItem">
  <$set name="tv-config-toolbar-class" filter="[<tv-config-toolbar-class>] [<listItem>encodeuricomponent[]addprefix[tc-btn-]]">
  <$transclude tiddler=<<listItem>>/>
  </$set>
  </$list>
</$list>

In your two outer list widgets you are testing if something is true, just add variable=~ or variable=nul so the currentTiddler is not changed and it seems to work

Cool, now I finally understand the meaning of variable=“ignore”

This might be a good place to introduce the new 5.3.2 conditional syntax.

<%if [{$:/info/url/protocol}match[http:]] %>
  <$list filter="[all[shadows+tiddlers]tag[$:/tags/ViewToolbar]!has[draft.of]] :filter[lookup[$:/config/ViewToolbarButtons/Visibility/]!match[hide]]" storyview="pop" variable="listItem">
  <$set name="tv-config-toolbar-class" filter="[<tv-config-toolbar-class>] [<listItem>encodeuricomponent[]addprefix[tc-btn-]]"><$transclude tiddler=<<listItem>>/></$set>
  </$list>
<%elseif [{$:/info/url/protocol}match[https:]] %>
  <$list filter="[[$:/core/ui/Buttons/permalink]] [[$:/core/ui/Buttons/close]]" storyview="pop" variable="listItem">
  <$set name="tv-config-toolbar-class" filter="[<tv-config-toolbar-class>] [<listItem>encodeuricomponent[]addprefix[tc-btn-]]">
  <$transclude tiddler=<<listItem>>/>
  </$set>
  </$list>
<%endif %>

It’s a little tighter and easier to understand. And it takes care of sequestering the variable away too (in this case, into “condition” rather than “ignore”)

Good point @Flibbles this is a good use case for the new conditional syntax.

  • As mentioned elsewhere, within the if or else if sections, the variable <<condition>> also contains the result of the filter in the if or elseif (if there was a result).

Yes, I tried to use if to write it for the first time, but at that time I forgot to switch the type to text/vnd.tiddlywiki. It does not work in markdown. It is really convenient for if to automatically have variable isolation. It’s also different to write multiple filters.

I don’t use markdown except to store content obtained for other sources like chat GPT but it would be sad to loose the TiddlyWiki script features.

  • I imagen work could be done on the markdown parser to include some if not all TiddlyWiki script, so perhaps raise this in a new thread.

However I just tried a placing the code from the TableOfContents tiddler in a markdown tiddler and it works.

This is markdown header

{{TableOfContents}}

<hr>

<div class="tc-table-of-contents">

<<toc-selective-expandable 'TableOfContents'>>

</div>


This is markdown footer;

At the top I just trancluded the tiddler, and at the bottom inserted the code;

  • Both work

However since the %if is not working try the excise button and replace the code with a transclusion, then edit the tiddler it created, and set its type to text/vnd.tiddlywiki, I tested it and it works.

  • I suspect the markdown plugin has not been updated to be aware of this new code syntax and it’s just an oversight.

Note: I am using the core markdown plugin, $:/plugins/tiddlywiki/markdown are you?

  • Perhaps find the plugin in github and raise an issue.

markdown uses wikiparser directly, and if syntax pr has updated some parsing syntax, but I don’t know why it doesn’t work.

Markdown has a tiddler in there that’s something like:

\rules only html macrocallinline ...

All that would need to happen is for “conditional” to be added to that list.

Edit: Yeah, $:/config/markdown/renderWikiTextPragma. Adding “conditional” to that would fix this issue.

2 Likes

I suspected as much, thanks. Will someone raise an issue?

I tried this method. Still doesn’t seem to work

Really? Did you make sure to refresh your TiddlyWiki after changing renderWikiTextPragma? The javascript only accesses that file once during startup.

No you’re right. That doesn’t work. I really thought it would. Not sure why not.

Okay, I looked into it. It’s not as simple as adding “conditional” to that rules file.

Somebody has to go into the markdown-it-tiddlywiki.js file and program in a rule. It shouldn’t be more than about 15 or 20 lines, but it’d probably need some tests to go with it. Who’s been revamping the markdown? It’s very different from how I remember it when I made Relink. Whoever did it would be the best person for this.

I took a brief look at this markdown-it-tiddlywiki.js, but I haven’t figured out how it works.

The general process is to parse the corresponding wikiparser and then add it to the rules of markdown so that markdown supports it.