Macro not working on single word target

56 views
Skip to first unread message

Les Barbott

unread,
May 7, 2020, 9:57:26 AM5/7/20
to TiddlyWiki
Hello all, I discovered TW a couple of weeks ago, and I was blown away by the great possibilities of this tool ! I am currently writting a set of customization for my TW, partly to have a better suited tool, partly just because programming is fun ! 

One of the things I want to do is to have a template rendered after each tiddlers body, with backlinks and links to related tiddlers. The related links are stored in a field (« relatif »). I wanted to reuse the core/ui/EditorTool/link-dropdown code to be able to select a new relation, then add a link to it in my field.

Well, my code works fine, except for tiddlers where the title is a single word.... Only that word is added to the field, without the [[]]. I just don’t understand, I spent more than a day on that and start becomming crazy !! Any help would be greatly appreciated !

This bit adds the brackets :
\define myLink() [[$(lien)$]]

This bit adds the link to the field :
\define add-link-actions()
<$vars lien={{$(linkTiddler)$}} >
<$action-listops $field="relatif" $subfilter=<<myLink>> />
</$vars>

Full code attached !

Thank you !
BBT_fonction_ajouterRelation.tid

Saq Imtiaz

unread,
May 7, 2020, 10:54:00 AM5/7/20
to TiddlyWiki
Note that brackets have a special meaning in filters, you can refer to filter syntax for details. So it's the subfilter stripping the brackets before saving the value to the field.

Why do you want brackets around it in the field? If storing multiple values as a list in the same field, note that this is a valid syntax:
SingleWord [[With space]] HelloThere [[Getting Started]]

That is, in a list you only need brackets around tiddler titles with spaces.

Les Barbott

unread,
May 7, 2020, 11:02:54 AM5/7/20
to TiddlyWiki
Thank you very much Saq ! Trying to wrap the names in bracketts before storing them felt like easier to then display, just view the field and you’re done.

Thank you very much for your quick answer ! I would never have found myself.

TonyM

unread,
May 8, 2020, 5:59:13 AM5/8/20
to TiddlyWiki
Led

A quick followup. The list-ops term in tiddlywiki relates to manipulating titles so that handles the square brackets as needed.

Regards
Tony

Les Barbott

unread,
May 8, 2020, 6:14:12 AM5/8/20
to TiddlyWiki
So I went back to studying and spent some more time looking at the Title List, Listops widget and filtering.

If I store the data SingleWord [[With space]] HelloThere [[Getting Started]] in the field myField, what would you say is the best syntax to :
1. generate a list of links (so the end goal is to have [[SingleWord]] [[With space]] [[HelloThere]] [[Getting Started]]) ?
2. generate a string without the [[]] ?

I only seems to find extremely convoluted solutions to this problem !

Thank you again for your help, I am really enjoying what the software allows so far. My only other trouble is working with string manipulation, variables and substitution... But that’s for another day !

Best regards, 
Paul

Saq Imtiaz

unread,
May 8, 2020, 6:20:13 AM5/8/20
to TiddlyWiki
<$list filter="[enlist{mytiddler!!Myfield}]"/>

Will give you a link to each title regardless of whether it has spaces in the title or not. You can also do something different with each title inside the list widget.

Les Barbott

unread,
May 8, 2020, 6:22:16 AM5/8/20
to TiddlyWiki


Le vendredi 8 mai 2020 11:20:13 UTC+1, Saq Imtiaz a écrit :
<$list filter="[enlist{mytiddler!!Myfield}]"/>

Will give you a link to each title regardless of whether it has spaces in the title or not. You can also do something different with each title inside the list widget.


Thank you ! 

Saq Imtiaz

unread,
May 8, 2020, 6:28:55 AM5/8/20
to TiddlyWiki
Les: Basically enlist gives you a list/array of words where each member is one title, regardless of spaces, with no brackets.

<$list filter="[enlist{mytiddler!!mylist}]">
<li><$text text=<<currentTiddler>>/></li>
</$list>

Might help with understanding as to what is going on and what the value of currentTiddler is for each title list member.

If you want to create links that look different etc, perhaps take a look at the LinkWidget.

Les Barbott

unread,
May 8, 2020, 8:53:53 AM5/8/20
to TiddlyWiki
That’s great, and it does help. Thx !

The only other area I am sometimes struggling with is the need to wrap everything when working with variables, string manipulation and list. It can get quite convoluted ! Is there any good ressources about that ?  I wish I could just set a variable by value at one point and just be done with the references !
Reply all
Reply to author
Forward
0 new messages