[TW5] Plugin for "the"-insensitive links?

341 views
Skip to first unread message

f10

unread,
Jan 8, 2015, 1:21:13 PM1/8/15
to tiddl...@googlegroups.com
Hi,

I'm a new TiddlyWiki user and haven't seen a solution for my problem while scrolling through the group so far, so I apologize if this has been discussed before.

I know there is a plugin to help with case and space insensitive links, but is there one for the word "the"?
Example: I have a tiddler titled "The First Tiddler" and would like to link to it as "the [[First Tiddler]]"

1. I know that [[First Tiddler|The First Tiddler]] solves this problem, but I would have to do that for a lot of links and am wondering if there is an easier way. 
2. I also know that [[the First Tiddler]] would also be a solution when using the LooseLinks plugin, but I'd prefer not to include "the" in the hyperlink due to visual preferences. 

Any help you can provide (even if it's just "It would be better just to stick with one of your mentioned solutions") would be greatly appreciated!

Thanks,
Faith

Jed Carty

unread,
Jan 8, 2015, 2:16:06 PM1/8/15
to tiddl...@googlegroups.com
For the moment you should stick to one of the options you mentioned. To my knowledge there isn't any plugin like the one you suggest yet.

I don't know how hard it would be to make one, but you may be able to put together a macro using the regexp search that will do what you want. That may not be helpful in your situation as it would require you to redo all of your links anyway.

f10

unread,
Jan 8, 2015, 2:25:45 PM1/8/15
to tiddl...@googlegroups.com
Ah well, it didn't hurt to ask.

Thank you for you help!

Erwan

unread,
Jan 8, 2015, 3:08:59 PM1/8/15
to tiddl...@googlegroups.com

Hi Faith,

Sometimes in cases like this I create a tiddler "First Tiddler" with content {{The First Tiddler}}, so that the latter is basically a symbolic link to the former.
The disadvantage is that you have to remember which one is the original when you want to edit it, especially if you do that a lot!

Regards
Erwan
--
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 http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.

Eric Shulman

unread,
Jan 8, 2015, 3:13:31 PM1/8/15
to tiddl...@googlegroups.com
On Thursday, January 8, 2015 at 11:16:06 AM UTC-8, Jed Carty wrote:
For the moment you should stick to one of the options you mentioned. To my knowledge there isn't any plugin like the one you suggest yet.

I don't know how hard it would be to make one, but you may be able to put together a macro using the regexp search that will do what you want. That may not be helpful in your situation as it would require you to redo all of your links anyway.


It allows use of "case folded" and "space folded" matching to link to existing tiddlers.  However, it does not have any handling for using optional prefix or suffix text (e.g., automatically adding "the" in front of the specified title).

-e
Eric Shulman
Inside TiddlyWiki (The Missing Manual)
TiddlyTools - Small Tools for Big Ideas
TiddlyWiki Classic Lead Developer

P.S.  @Jed... although it's (currently) only written for TWClassic, you might want to familiarize yourself with my TiddlyTools site... many of the ideas that are implemented in the TW5 core are based on the plugins I wrote for TWC... and there's still lots of TiddlyTools plugins with useful features and functionality that have not yet been re-implemented for TW5 (that is a long-term project on my plate).  At the very least, it will give you some historical perspective on what has been done before... and perhaps it will spur some ideas for you...

Birthe C

unread,
Jan 9, 2015, 7:12:27 AM1/9/15
to tiddl...@googlegroups.com
Hi f10
Maybe you could use http://tw5magick.tiddlyspot.com/ Look for the tiddler called Aliases.


Birthe

Tobias Beer

unread,
Jan 9, 2015, 11:34:21 AM1/9/15
to tiddl...@googlegroups.com

Maybe you could use http://tw5magick.tiddlyspot.com 
Look for the tiddler called Aliases.

Did some recoding, simplifying, and so forth...


Best wishes, Tobias.

Astrid Elocson

unread,
Jan 12, 2015, 7:32:46 AM1/12/15
to tiddl...@googlegroups.com
Hi Tobias,

Your alink macro would be really handy for use in the TiddlyWiki documentation. It would significantly reduce the file size, because we have lots of links of the form `[[…|…]]` (and we will be acquiring more over time).

The main drawback is that it's not understood by important filters such as `[backlinks[]]` and `[all[orphans]]`, which means that the sidebar Orphans tab can show false positives and the info References tab can incorrectly show nothing.

A comment about the implementation: The regexp doesn't check for a trailing pipe sign, so `<<a: tab>>` will match `|table`. The fact that your example shows `|alias|aliases` suggests this isn't what you intended. It would be problematic if one tiddler had an alias of `|tab` and another had an alias of `|table` – it wouldn't be clear which one `<<a: tab>>` (or indeed `<<a: ta>>`) would link to.

– æ

Astrid Elocson

unread,
Jan 12, 2015, 8:30:52 AM1/12/15
to tiddl...@googlegroups.com
Further to my previous comment, I've just discovered that `[backlinks[]]` and `[all[orphans]]` don't take account of most automated links.

For instance, if I have a tiddler whose text is

  <<my-macro "[[Target]]">>

then the Target tiddler has an empty References list and shows up on the Orphans tab. And if the Target tiddler doesn't exist, it doesn't show up on the Missing tab.

It's much the same situation if I have a tiddler whose text is

  <$list filter="[title[Target]]">
  <$link>click here</$link>
  </$list>

As a result of this, the tiddlywiki.com site shows almost half of its tiddlers as orphans, even though most of them aren't.

Interestingly, things do work correctly if I have a tiddler whose text is

  <$link to="Target">click here</$link>

Apologies if this has been discussed before, but it's a difficult thing to search the group for.

– æ

Tobias Beer

unread,
Jan 12, 2015, 10:30:16 AM1/12/15
to tiddl...@googlegroups.com
Hi Astrid,
 
The regexp doesn't check for a trailing pipe sign, so `<<a: tab>>` will match `|table`.

That's correct. Fixed.

Best wishes, Tobias.

Astrid Elocson

unread,
Jan 12, 2015, 11:21:56 AM1/12/15
to tiddl...@googlegroups.com
On further reflection, the problem of backlinks and orphans is not as important as I initially thought. Links that are automatically generated by a filter-based widget will normally always be links to existing tiddlers, otherwise the filter wouldn't have selected them. So these links can be filed under "things the system takes care of so you don't have to".

But it's potentially problematic that the system doesn't keep track of links within macro parameters. If TiddlerOne passes a sentence of ordinary text to a simple macro that just returns its parameter in bold with a red background, and if that sentence contains a link to TiddlerTwo, then it would be nice if TiddlerTwo recognised TiddlerOne on its info References tab. I suppose the difficulty is that the system can't easily detect whether the macro returns its parameter intact.

– æ

Tobias Beer

unread,
Jan 12, 2015, 12:00:06 PM1/12/15
to tiddl...@googlegroups.com
But it's potentially problematic that the system doesn't keep track of links within macro parameters. If TiddlerOne passes a sentence of ordinary text to a simple macro that just returns its parameter in bold with a red background, and if that sentence contains a link to TiddlerTwo, then it would be nice if TiddlerTwo recognised TiddlerOne on its info References tab. I suppose the difficulty is that the system can't easily detect whether the macro returns its parameter intact.

So long as (part of?) a macro parameter is declared via double square brackets, that may be achieved.
When using just quotes that's a lot more complicated as it's just as likely a mere string.

Best wishes, Tobias. 

Astrid Elocson

unread,
Jan 12, 2015, 12:55:02 PM1/12/15
to tiddl...@googlegroups.com
Hi Tobias,


> So long as (part of?) a macro parameter is declared via double square brackets, that may be achieved.

How so? While it's possible to use double square brackets to delimit a macro parameter, these are merely an alternative for quotes. They have no link semantics.

For example, given `\define emphasis(_) //$_$//`, the call `<<emphasis [[Target Tiddler]]>>` returns `//Target Tiddler//` rather than any kind of link to Target Tiddler.

I believe a macro parameter is always a mere string of characters, no matter how it's passed. Even if you use the $macrocall widget,

  <$macrocall $name=emphasis _="[[Target Tiddler]]"/>

the parameter remains a string, in this case `[[Target Tiddler]]`.

The issue is that macros are dynamic, so they're not really suitable candidates for the rapid indexing relied on by things like [backlinks[]] and [all[orphans]].

I wonder if the message "No tiddlers link to this one" on the References tab ought to say "No tiddlers contain static links to this one"?

– æ

Tobias Beer

unread,
Jan 12, 2015, 4:21:50 PM1/12/15
to tiddl...@googlegroups.com
Hi Astrid,
 
While it's possible to use double square brackets to delimit a macro parameter, these are merely an alternative for quotes. They have no link semantics.

Not intrinsically, that is true...
as parameters they're just another way to enclose string literals.
However, in general, that's how they're used, not just in internal / pretty links.

For example, given `\define emphasis(_) //$_$//`, the call `<<emphasis [[Target Tiddler]]>>` returns `//Target Tiddler//` rather than any kind of link to Target Tiddler.

Sure, but I wouldn't write it that way if emphasis was the purpose of my macro.
Then I would use it like <<emphasis "some string">> ...and that's how it should be recommended.
 
I believe a macro parameter is always a mere string of characters, no matter how it's passed. 
Even if you use the $macrocall widget,

  <$macrocall $name=emphasis _="[[Target Tiddler]]"/>

the parameter remains a string, in this case `[[Target Tiddler]]`.

While technically correct,
that looks like poor use of double square brackets to me...
and not what anyone would intrinsically do just to emphasize text,
rather than a link... it's entirely confusing markup.

The issue is that macros are dynamic, so they're not really suitable candidates for the rapid indexing relied on by things like [backlinks[]] and [all[orphans]].

Sometimes, it is vital to be aware of those references, something where TWc also fell short.
There could well be a recommendation to always use single or double quotes or triple double quotes for strings
and reserve double square brackets for tiddler titles only.

I wonder if the message "No tiddlers link to this one" on the References tab 
ought to say "No tiddlers contain static links to this one"?

Perhaps "tiddler-links", or TiddlyLinks but not "static links".

Best wishes, Tobias.

Astrid Elocson

unread,
Jan 12, 2015, 4:49:43 PM1/12/15
to tiddl...@googlegroups.com
Hi Tobias,


> that looks like poor use of double square brackets to me...

Let me suggest a less abstract example, then. Your tb5 site offers a macro for colouring text. One can easily imagine passing a whole sentence, e.g. a warning message, to this macro, and that sentence could contain a link. That link would not be detected by the link-tracking system that drives the References and Orphans tabs.


> There could well be a recommendation to always use single or double quotes or triple double quotes for strings
and reserve double square brackets for tiddler titles only.

But that still wouldn't solve the general case in which a quote-delimited parameter can contain a double-square-bracketed link as part of its content.

>
Perhaps "tiddler-links", or TiddlyLinks but not "static links".

I agree that "static" isn't the right word, but the alternatives you suggest could apply equally well to links generated on the fly by macros and widgets and whatnot. Perhaps we could speak of a "literal" link – a link that is literally present in the text field of a tiddler.

– æ

f10

unread,
Jan 12, 2015, 4:54:17 PM1/12/15
to tiddl...@googlegroups.com
Thank you for this, Tobias.
I'll try it out right now

Again, thanks!
Faith

Tobias Beer

unread,
Jan 12, 2015, 5:39:41 PM1/12/15
to tiddl...@googlegroups.com
Let me suggest a less abstract example, then. Your tb5 site offers a macro for colouring text. One can easily imagine passing a whole sentence, e.g. a warning message, to this macro, and that sentence could contain a link. That link would not be detected by the link-tracking system that drives the References and Orphans tabs.

I know that it wouldn't and I think it could and perhaps should.

> There could well be a recommendation to always use single or double quotes or triple double quotes for strings and reserve double square brackets for tiddler titles only.

But that still wouldn't solve the general case in which a quote-delimited parameter can contain a double-square-bracketed link as part of its content.

Whichever way the backlinks parser works, it would have to take care of that by having some kind of special parsing mode that includes macro parameters and element attributes, or simply matches anything in double square brackets that doesn't contain newlines.

> Perhaps "tiddler-links", or TiddlyLinks but not "static links".

I agree that "static" isn't the right word, but the alternatives you suggest could apply equally well to links generated on the fly by macros and widgets and whatnot. Perhaps we could speak of a "literal" link – a link that is literally present in the text field of a tiddler.

How about a "manual link"?

Best wishes, Tobias.

Astrid Elocson

unread,
Jan 12, 2015, 6:15:49 PM1/12/15
to tiddl...@googlegroups.com
Hi Tobias,

Sorry if I misunderstood. I got the impression we were talking slightly at cross-purposes, so felt the need to clarify further. But we're in agreement.

"Manual link" isn't bad.

– æ

f10

unread,
Jan 12, 2015, 9:51:08 PM1/12/15
to tiddl...@googlegroups.com
I apologize if this has been addressed elsewhere in this thread, but does this allow the use of multiple-word aliases? For example:
|first|first tiddler|the first tiddler|

If so, is there a certain way I should be formatting the code to accomplish that?

I appreciate all the help!
Faith

On Friday, January 9, 2015 at 8:34:21 AM UTC-8, Tobias Beer wrote:

f10

unread,
Jan 12, 2015, 10:11:28 PM1/12/15
to tiddl...@googlegroups.com
Never mind, I figured it out!

Tobias Beer

unread,
Jan 13, 2015, 4:26:59 AM1/13/15
to tiddl...@googlegroups.com
Hi f10,
 
Never mind, I figured it out!

I apologize if this has been addressed elsewhere in this thread, but does this allow the use of multiple-word aliases? For example:
|first|first tiddler|the first tiddler|

If so, is there a certain way I should be formatting the code to accomplish that?

It should just work like that.
Did you run into problems? 

Best wishes, Tobias.

JL

unread,
Sep 14, 2015, 5:04:59 AM9/14/15
to TiddlyWiki

Hi Tobias, thanks for the macro — I’m finding that when the alias in the piped field is CamelCase, <<a: CamelCase>> fails, but <<a: camelcase>> works.

I'm on version 5.1.9

Cheers, JL

Tobias Beer

unread,
Sep 15, 2015, 5:58:55 AM9/15/15
to TiddlyWiki
Hi JL,

Thanks for the pointer. To capture more aliases, I had set it up to being case-insensitive to the macro input. As you noticed, this requires the piped aliases to be lowercase letters only.

I have added that bit of information to the documentation.

http://tobibeer.github.io/tb5/#alink

— tb

JL

unread,
Sep 15, 2015, 10:38:03 AM9/15/15
to TiddlyWiki

I see, thanks for that. I did read that it was case-insensitive, but I interpreted that as meaning it would pick up CamelCase, camelcase or cAMelCASe. Anyway, cheers, all working now JL

Tobias Beer

unread,
Sep 16, 2015, 1:12:45 AM9/16/15
to TiddlyWiki

I interpreted that as meaning it would pick up CamelCase, camelcase or cAMelCASe

Yes, all that would be working as macro parameters to match |camelcase|, hence the case insensitivity, but never as aliases. ;-)
 

Anyway, cheers, all working now JL

Great!

— tb

Alexei R

unread,
May 10, 2020, 1:42:01 PM5/10/20
to TiddlyWiki

[IDEA] Optional system-wide case-insensitivity for titles, links and tags #4612 https://github.com/Jermolene/TiddlyWiki5/issues/4612

Reply all
Reply to author
Forward
0 new messages