"Extended" Camel-case linking?

Automatic CamelCase linking is one of my favorite feature in Tiddlywiki, it greatly reduces friction of adding relevant links by simply training yourself to refer to topics via CamelCase.

I would like to extend the auto-link parser a bit though just not sure the best way to go about that.

I found Special_Links — creates an automatic wikilink which allows for underscores in Camel_Case which is likely a good reference, but the other patterns I would like to match would be:

Some kind of allowance for “Title-case Acronyms”?
I have a class electromagnetics which colloquially shortens to EMAG but I don’t have an elegant way to camelcase this term with the out of the box parsing.

E-Mag, E_Mag and EMag are not counted camel case as there are no sandwiched lowercase characters, so working as expected.

EmaG and ElMag are, but these look kind of clunky to me.

The other text pattern I would like to see auto-Linked is Titlecase mixed with numerals,

Like Homework2, or a date shorthand like 28Jan26.

I guess you could lump these both into one category of “Mixed Titlecase?”

With Mixed here meaning Titlecase strings that also contain at least one numeral or symbol.

So I could get links for E-Mag or 28Jan26 or
28-Jan-26

But not t-bone or T-bone, or hw3 or 28-1-26

Anyways let me know your thoughts.

-Xyvir

You might benefit from using the “Freelinks” plugin, available from the TWCore Official Plugin Library.

What it does is automatically link any text that matches an existing tiddler title.

For example, you would first create your EMAG tiddler in the usual manner. Then, whenever EMAG occurs in tiddler content, it would be automatically linked to your existing EMAG tiddler.

-e

In TW Titlecase is this: [[a link]]. IMO that’s not really what you describe.

Your first example is EMAG, which is “all uppercase”. So IMO it should be straight forward to create a WikiLink for “all uppercase”.

But it would not link to ALL UPPERCASE. WikiLiks usually are not separated by spaces. If they are they need braces eg: [[ALL UPPERCASE]], which is a standard wiki link.

I would call E-Mag an “hyphen link”. The code would be very similar to “Special_Link”. Only the separator would be different.

I would call 28Jan26 an “ugly link”. I personally would not really want to use / see it.

I would write 28-1-26 as 2026-01-28 or 2026-Jan-28, which I would name “date link” or an extended form of the hypen-link (maybe). The advantage of my preferred format is automatically sorted, without the need for a custom sort operator.

So what you described are basically 4 different “new” link patterns, not one.

For consistency reasons, I would ask. What would be the one pattern, that you really, desperatly need?

Just a question?
-Mario

Thanks for the detailed clarifications, I’m sure I butchered my ‘case’ terms a bit which is why I tried to give examples too. I probably shouldn’t have said TItle Case.

Also I think there is a bit of semantic shift or something going on because some people use the convention:

TitleCase
camelCase (like classes in Python)

but Tiddlywiki doesn’t create hyperlinks out of ‘camelCase,’ but I’m sure I’ve seen CamelCase used the way TW does so who knows.

Anyways, I think I could create a ‘catch-all’ pattern that would match all the additional example strings I would like to see treated as links, namely:

  1. String contains no spaces or whitespace. (ofc)
  2. String contains any number of alpha character groups, as long as each ‘delimited’ group starts with a capital.
  3. At least one delimiter (being a number or hyphen or underscore).
  4. Please also note that delimiters don’t necessarily have to have alpha on both sides, or either side, delimters can be adjacent, etc.

Google Gemini gave me this Regex for that description, which seems to work but I am no Regex wizard, nor am I a TiddlyWiki wizard either lol.

pattern:
^(?=\S*[\d_-])(?![^A-Z]*[a-z])[a-zA-Z\d_-]+$

Test Cases:

These_Pass-
Alpha-Beta
Alpha123
A_B-C
26Jan28
E-Mag
_Hello_World
These fail-
123_abc	Fail
Alpha Beta
Alpha
t-bone

regex101: build, test, and debug regex

So yeah something like that, I’d have to use it more though to see if I thought it was ‘too aggressive’ and made too many strings into links.

Oh this might be the ticket, I had ran across the term freelink but didn’t quite know what it meant in regards to TiddlyWiki.

I will definitely check this out; though this is a bit ‘more’ friction as it needs to have the tiddler existing for it to trigger. But maybe this is for the better.

I’ll check it out.

The Freelinks plugin is pretty good! The only drawback is it (understandably so) doesn’t match on a tiddlers’ aliases field like used in $:/plugins/mklauber/aliases/

I think if I manually adjusted or added to the existing the CamelCase links pattern matching it /would/ work with ‘rule-matching defined aliases’ out-of-the-box at least if I understand the interplay of components correctly.

-Xyvir

You should ask Gemini, if it can create a regexp, that also allows other languages than English. Eg: Öas-Df would fail, even if the “pattern” should detect it.

That’s the reason, why I did use the $tw.config.textPrimitives.??? from core/modules/config.js to create the regexp. They are a little bit better, but still have room for improvements.

-m

Thanks for the tip on the primatives, inside TW I should probably invoke those directly but just cramming them in the existing regex seemed to work well enough for regex101

^(?=[^a-zA-Z\u00c0-\u00d6\u00d8-\u00de\u00df-\u00f6\u00f8-\u00ff\u0150\u0170\u0151\u0171]*[A-Z\u00c0-\u00d6\u00d8-\u00de\u0150\u0170])(?=\S*[\d_-])(?![a-z\u00df-\u00f6\u00f8-\u00ff\u0151\u0171]|.*[^a-zA-Z\u00c0-\u00d6\u00d8-\u00de\u00df-\u00f6\u00f8-\u00ff\u0150\u0170\u0151\u0171][a-z\u00df-\u00f6\u00f8-\u00ff\u0151\u0171])[a-zA-Z0-9_\-\u00c0-\u00d6\u00d8-\u00de\u00df-\u00f6\u00f8-\u00ff\u0150\u0170\u0151\u0171]+$

Matches
Öas-Df