Pipe | ruins filter. Alternatives?

119 views
Skip to first unread message

Mat

unread,
Apr 20, 2021, 8:18:13 AM4/20/21
to TiddlyWiki
I want to create a pretty title link in a filter. Unfortunately the pipe character in hi| breaks the filter (ref1).

E.g these attempts no worky:

<$vars l="[[" r="]]">{{{ HelloThere +[addprefix[hi|]addprefix[l]addsuffix[r]] }}}</$vars>

<$vars l="[[" r="]]">{{{ hi HelloThere +[join[|]addprefix[l]addsuffix[r]] }}}</$vars>

Any ideas what to do? Maybe some magic regepx is needed but I don't know how to construct it in that case...

<:-)

...Hm, that's like my fourth question today and I didn't even have lunch yet. I have no idea why they all mount up at the same time. I typically tiddle fiddle for days without questions.

Álvaro

unread,
Apr 20, 2021, 8:48:11 AM4/20/21
to TiddlyWiki
You can use a variable for pipe.

This works
<$vars l="[[" r="]]" x="|">{{{ hi HelloThere +[join<x>addprefix<l>addsuffix<r>] }}}</$vars>

Mat

unread,
Apr 20, 2021, 9:15:26 AM4/20/21
to TiddlyWiki
Thanks Alvaro. For some reason I don't get that to work in my context, i.e:  https://link-or-ext.tiddlyhost.com/

The workaround I use there is bad but maybe it'll have to do (breifly; the user has to himself suffix the pipe character to the pretty title in the macro call) 

Thanks.

<:-)

Álvaro

unread,
Apr 21, 2021, 7:45:09 PM4/21/21
to TiddlyWiki
I don't understand some things in your macro.

Why are you using two different methods to create the links?


I am using something like the following snippet, but i use it with two "basic" macros. Maybe you can use the idea of snippet in your context.

\define basic-macro(z) x5 y3 $z$

\define complex-macro(x, y)
\whitespace trim
<$set name="result" filter=" [<__y__>!match[]]"
        value="""<$macrocall $name="basic-macro" z=<<__x__>> />"""
        emptyValue="""<$macrocall $name="basic-macro" />""" >
    <<result>>
</$set>
\end


Examples:

`<<complex-macro Z>>`=><<complex-macro Z>>

`<<complex-macro Z test>>`=><<complex-macro Z test>>

Maybe you don't need use macrocall widget and you can use basic macro call <<basic-macro $x$ $y$>> . It depends if you need call the parameters as variables or if it is enought the text sustitution of the parameter. Also in the filter you could use it the text sustitution, in the snippet [[$y$]!match[]]

TW Tones

unread,
Apr 22, 2021, 10:11:16 PM4/22/21
to TiddlyWiki
Folks,

\define pipe() |

use <pipe> in filters

addprefix<pipe>addprefix[hi]

Regards
Tones

Mat

unread,
Apr 23, 2021, 10:54:39 AM4/23/21
to TiddlyWiki
@Alvaro and @TT, your input inspired me to rework it. It now does use two macros which I was trying to avoid, and it is annoying that vars can't refer to one another within the same varswidget, but still I feel it is better than before and much clearer:


Thank you.

<:-)

Álvaro

unread,
Apr 23, 2021, 6:33:49 PM4/23/21
to TiddlyWiki
I understand you. It is really hard achieve use one macro or declare all variable in unique varswidget, except when we write very long code.

You don´t need use three varswidget because label an link are not depend each other. You can declare in the same varswidget.

Regards
Reply all
Reply to author
Forward
0 new messages