Did I find a bug? Or am I using it wrong?

81 views
Skip to first unread message

Stephan Hradek

unread,
Jul 2, 2019, 2:44:04 AM7/2/19
to tiddl...@googlegroups.com
For my mailto-link I want to supply a tiddlername and a linktext to a macro.

For this I thought it would be a good ideat to do it in the form of

{{the tiddler with the mail template -- the linktext||mailto}}

So the idea is to have a mailtext in the tiddler (the tiddler with the mail template) and to create a mailto-link of the form

<a href="mailto:…">the linktext</a>

So for this I need to split the text at " -- ", but this only worked, when my tiddler's title does not contain a blank. Otherwise it fails.

Here is a simple tiddler for you to test:

<$set name="testtext" value="the tiddler with the mail template -- the linktext">

<$set name="left" filter="[<testtext>splitbefore[ -- ]removesuffix[ -- ]]">

<$set name="right" filter="[<testtext>removeprefix<left>removeprefix[ -- ]]">

Original: <$text text=<<testtext>>/>

Left of ' -- ': <$text text=<<left>>/>

Right of ' -- ': <$text text=<<right>>/>

</$set>
</$set>
</$set>

The output is

Original: the tiddler with the mail template -- the linktext


Left of ' – ': [[the tiddler with the mail template]]


Right of ' – ': 


Without spaces the output is

Original: the_tiddler_with_the_mail_template -- the linktext

Left of ' – ': the_tiddler_with_the_mail_template


Right of ' – ': [[the linktext]]


So for some reason there are square brackets added to the variable's value which will make my nice logic fail.

Is there a way around this?

P.S. There is a way around it I just noticed: Use $list instead of $set:

<$set name="testtext" value="the tiddler with the mail template -- the linktext">

<$list variable="left" filter="[<testtext>splitbefore[ -- ]removesuffix[ -- ]]">

<$list variable="right" filter="[<testtext>removeprefix<left>removeprefix[ -- ]]">

Original: <$text text=<<testtext>>/>

Left of ' -- ': <$text text=<<left>>/>

Right of ' -- ': <$text text=<<right>>/>

</$list>
</$list>
</$set>

But the question remains: Is this a bug?

Xavier Cazin

unread,
Jul 2, 2019, 3:46:31 AM7/2/19
to tiddl...@googlegroups.com
Hi Stephan,

In order to "flatten" the titles retrieved from the filter, you need to use the select attribute of your <$set> widget like so: <$set name="left" filter="[<testtext>splitbefore[ -- ]removesuffix[ -- ]]" select=0>

Cheers,
-- Xavier Cazin


--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/1fe8473f-9fb3-482c-b4a9-975eedc4b093%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stephan Hradek

unread,
Jul 2, 2019, 6:09:15 AM7/2/19
to TiddlyWiki
Am Dienstag, 2. Juli 2019 09:46:31 UTC+2 schrieb Xavier:
Hi Stephan,

In order to "flatten" the titles retrieved from the filter, you need to use the select attribute of your <$set> widget like so: <$set name="left" filter="[<testtext>splitbefore[ -- ]removesuffix[ -- ]]" select=0>


Thanks a lot @Xavier. Works perfectly
 

Mat

unread,
Jul 2, 2019, 9:34:28 AM7/2/19
to TiddlyWiki
Xavier wrote:
In order to "flatten" the titles retrieved from the filter, you need to use the select attribute of your <$set> widget like so: <$set name="left" filter="[<testtext>splitbefore[ -- ]removesuffix[ -- ]]" select=0>

I was not aware of this technique. I would have attempted

<$wikify name="left" text="{{{ [<testtext>splitbefore[ -- ]removesuffix[ -- ]] }}}">

Is there any advantage or disadvantage with either?

<:-)

Jeremy Ruston

unread,
Jul 2, 2019, 9:50:36 AM7/2/19
to tiddl...@googlegroups.com
Hi @twMat
I don’t think your wikify widget will deal with adding the double square brackets.

Anyhow, wikify widget is intrinsically slow because it requires the text to be parsed and rendered on each refresh cycle. It should be avoided unless there is no alternative.

There’s only a small number of use cases for the wikify widget, and they all boil down to a need to manipulate the results of wikification other than to just display them.

Best wishes

Jeremy.


<:-)

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.

Mat

unread,
Jul 2, 2019, 9:55:51 AM7/2/19
to TiddlyWiki
Jeremy Ruston wrote:
I don’t think your wikify widget will deal with adding the double square brackets.

I think the request was to remove the brackets which the filter transclusion between quotation marks seems to do.

Thanks for the explanation. I probably over use wikify but I often don't see any other way out. This problem with extra brackets is one such recurrence so the $set technique was valuable.

<:-)


Jeremy Ruston

unread,
Jul 2, 2019, 10:02:35 AM7/2/19
to tiddl...@googlegroups.com
Hi Mat


On 2 Jul 2019, at 14:55, Mat <matia...@gmail.com> wrote:


I think the request was to remove the brackets which the filter transclusion between quotation marks seems to do.

You’re quite right, I’d missed the select=“0” in Xaviers post.

Best wishes

Jeremy
Reply all
Reply to author
Forward
0 new messages