Lost in [<{Brackets}>]

One very specific question and one more general one.

First, I was able to get a quick overview of some tiddlers representing sample files for parts of the system I’m documenting, like this:

<table>
<tr><th>Name</th><th>Description</th><th>Lines</th></tr>
<$list filter="[tag[Sample]]">
<tr>
<td><$link/></td>
<td>{{!!description}}</td>
<td>{{{ [<currentTiddler>get[text]split[
]count[]] }}}</td>
</tr>
</$list>
</table>

But the counts of lines in the third TD end up as links such as the equivalent of [[4]] and [[217]]. How do I make them plain text, 4 and 217?

More generally, I’m still applying a lot of magic thinking to get the result I want. I fiddle with various syntaxes that feel right but almost never are. Eventually I stumble onto something that works, then cut-and-paste wherever I need something similar. This is not efficient or effective. Are there some good simple references for how and when to use the various brackets and in which combinations?
I like GrokTiddlywiki but that’s aimed at tutorial-level learning, not quick references. There are several good cheat-sheets out there. I like the one from tobibeer, but it’s aimed at the overall editing experience. The one from TonyM seems to have a fair bit of interesting information, but is more of a brain dump than a how-to guide.

Are there any cheat sheets not aimed at questions like “How do I underline some text”? but rather at ones like “How do I manipulate and display the data in a field when I’m in plain wikitext mode?”. And I don’t literally mean cheat-sheets, as in single-page/tiddler versions, just something where I can look up such intermediate user questions quickly without too much of a break in my content-creation flow.

Any suggestions?

1 Like

You wanted something like the above in a table cell, but as text rather than as link. So you’ll need text widget (without using quote marks around the evaluated filter):

<$text text={{{ [<currentTiddler>get[text]split[
]count[]] }}}/>

Update: so as not to require the line break in code to do real work, it may be better practice to tweak this “solution” like so, as noted below by @EricShulman. (It will still work within a table cell.)

<$let lf={{{ [charcode[10]] }}}><$text text={{{ [<currentTiddler>get[text]split<lf>count[]] }}}/></$let>
2 Likes

Although I’m confident with the particular case of getting a filter result to display as text rather than as a link (your task above), I sometimes have a similar feeling about cobbling solutions together with lots of trial and error.

So I’m curious whether others have a favorite resource for the different kinds of brackets, braces, and references that work together in filters. (And ideally, foo and bar would make no appearance; examples should leverage recognizable patterns and familiar concepts, rather than take place in some abstract space of untethered variables.)

-Springer

Honestly, the best reference resource is TiddlyWiki.com. Read up on wikitext, transclusions, text references, transclusions, filter runs, filter expressions, and familiarize yourself with the current filter operators. It’s well written, with lots of example code that you can often test in-place. It’s not linear, for the same reason that an octopus isn’t linear.

It doesn’t read like a textbook, but then again, neither does the internet. :upside_down_face:

2 Likes

Thank you. That did just fine, except that I had to restore the line-break inside split as I’m counting lines not words.

I had tried the text widget a number of times in my previous stumbles, but something else was clearly wrong there. Once I got this to work, I forgot to try it again. I’m learning, but too damn slowly.

Thanks for the help!

Yes, I get about 75% of my information from the source. But the things I’m looking for are not easy to look up in there. When I search for “text”, there are 389 references, maybe 20% in the title. It’s far too hard to even scan for likely candidates. When I try “convert text” there are only 11, but none looks likely to answer the question. And am I looking for a widget? A macro? A pragma? Is this done in one of the million or so filter operators?

Tiddlywiki.com is a great resource, and I read over some of the high-level sections regularly. But my progress feels far too slow, given how I usually progress in learning technical topics.

It might simply be that I haven’t yet had that moment where everything clicks, and that when I hit that, things will come fast and furious. But I’ve been casually using TW since, I think, 2004 or 2005. My personal notes at work are in TW. I keep various information in various wikis. But when I need to do something complex, I find myself cutting and pasting or simply wildly hoping. That is not a recipe for success.

And I seem to be complaining too much here. This community has been extremely helpful. My largest TW project by far is coming along nicely. I’m mostly hoping that a reference that suits my style of working already exists. If not, I’m hoping to get to a level of expertise where I can take an initial stab at creating one.

Ah, the single-ticks way of handling code had forced a rewrap. Only triple-ticks preserve the line breaks. Learned a new thing about the forum syntax!

I do think it’s odd that we don’t yet have, “out of the box”, a way of referencing line breaks with something like an escape string; \n and \r don’t work; in this old thread Eric Shulman defines a variable <lf> that can do this work, but it would be nice not to rely on actual line breaks in your code!

All, has anything in the core changed, since 2020, that would affect this situation?

I could not find one so I wrote my own based on one of Tobias great notes. I have shared it a bit but now it is out of date with changes in recent versions of tiddlywiki, and about to change more with 5.3.0

Here it is with the caveat that its out of date, which means the are better ways now to do some of these things Tones GitWiki — For Designers from TW Tones (AKA TonyM)

1 Like

Well, “text” is a very popular topic in a wiki that runs on … text. And “convert text” could mean a wide range of things. Perhaps describe a bit of what your goal was, and then maybe we could look at it together and see if there is a way to leverage the information via tiddlywiki.com.

As you’ve noted, my old suggestion of

<$vars lf="
">

relies upon having an actual line break embedded in the code.

Since then, a new filter operator was added, charcode[...], which makes it possible to eliminate the embedded literal line break and instead generate the line break value by specifying a decimal ASCII character code like this:

<$let lf={{{ [charcode[10]] }}}>

Similarly, you can use charcode[...] to define left and right square bracket variables, like this:

<$let lb={{{ [charcode[91]] }}} rb={{{ [charcode[93]] }}}>

Also note the use of $let which supercedes the use of $vars. The advantage of $let is that when defining variables, you can immediately refer to variables previously created within the same $let widget.

For example, you can define a “paragraph break” (two line breaks in a row), like this:

<$let lf={{{ [charcode[10]] }}} p={{{ [<lf>addsuffix<lf>] }}}>

enjoy,
-e

5 Likes

I did also try “convert tiddler reference to text” and when that had no results, “convert tiddler reference”. While the search facility is powerful, it’s not a substitute for something like Google.

The initial question here seemed well enough asked that I got a working answer in ten minutes. If you can see how I could have used Tiddlywiki.com to answer it, I’d love to know. But answers like “use the TextWidget” are disqualified unless they include a clear path through TW to get to that answer. I don’t mind asking here for help. It’s just that I’d love to be able to do this without the flow interruption.

Which is why I’d love to find an appropriate reference.

Oh, that’s great to know. I find the embedded newlines disconcerting.

Thank you.

Well, when you’re talking about TW, two terms that should be in the forefront of your thinking are “filters” and “widgets”. So while you might not have thought to look for “TextWidget”, if you had searched for “widget text” the TextWidget would have been one of the top 3 answers.

But also, there is another solution. Since you’re doing a count, you could have also typed “count widget” and immediately discovered the CountWidget , which is another way to turn the count from a filter directly into rendered text.

In fact, just going through the list of existing widgets might give you some ideas. For instance, you probably could have also accomplished your goal using the WikifyWidget, which is an all-purpose tool for converting various kinds of wikitext into text or html.

For better or worse, there really isn’t any more exhaustive reference resource than tiddlywiki.com. Especially since new tools are being constantly added (like parameterized transclusions).

This is where we need new and experienced users alike to contribute to the documentation when we see a hole in it.

However in this case “tiddler reference” means something different, in this case perhaps “tiddler link” is more suitable, see Linking in WikiText however this case it not documented either.

  • But in the case you mention the link is a “soft link” and this documentation tiddler does not mention “tiddler links”.

I will submit a documentation update

First, I’m pretty sure the coming version TW5.3 with “parameterized transclusions” will simplify these things substantially.

Second, we already have some of “parametrized transclusions” that you can use in regular filtered transclusions by means of templates, i.e create a simple template tiddler e.g like so:

title: plaintext
text: <$text text={{!!title}}/>

and use this as a parameter in the filtered transclusion like so

{{{ 1 2 3 || plaintext }}}

If you have a some formats that you use recurringly, then the easiest way is probably to predefine a set of such templates.

1 Like

And perhaps I’m too ready to reach for the forum instead of doing further searching. It’s mostly a matter of not getting out of my writing flow. In this case, I put it aside, added a TODO tag, came back an hour later and spent six or eight minutes searching on TiddlyWiki.com and on DuckDuckGo/Google, didn’t find what I wanted and posted the question. I probably would have figured this one out without an inordinate amount of work, but the main reason for posting is the more general topic. If there was already a good reference out there that worked the way I wanted, I would love to know. It sounds like there’s not, so I will probably have a go at creating one. However, it’s likely to be slow going, since I’m at best an intermediate user.

Thank you. That is definitely a better fit.

I’m doing that fairly often with various parts of the docs, but they don’t sink in quickly until I find a use for them. I’ll keep working on it, though.

1 Like

Yes, I’m hoping to start creating some documentation that works the way I want. If it ever seems likely to help others, I’ll find a way to share it. As to the internal documentation, what’s the mechanism to contribute? GitHub pull requests? Posts here? Submissions to one of the links sites? Something else?

That’s great to hear. I’m generally quite impressed with all the tools already available, but somewhat overwhelmed by them. Eventually, I’m sure, I’ll internalize them and wonder about my earlier confusion. But for instance, your example uses {{{ ... }}}, and I still don’t have a feel for when to use the triple curly brackets. I stumbled on them in this case as something I stumbled across that seemed vaguely related used them. But I don’t know yet when they’re the right tool. (And I’m not asking; I’ll look it up. This is just a symptom of a more general confusion.)

Thank you. This confused me at first. My initial thought was "‘title’? Wouldn’t I want to use the ‘text’ instead? But as I was typing it in and before I actually tested it, I got it. I don’t know the exact mechanism, but I could do the same thing with

{{{ [[Lorem ipsum]] [[dolor sit amet]] || plaintext }}}

Now I need to go read up again on the triple curly bracket.

Thanks for your help,

– Scott

That’s essentially what I’m aiming to do on my wiki :

https://demos.tiddlyhost.com/#Q%26A

Your question is already answered in the doc tho: https://tiddlywiki.com/#Transclusion%20in%20WikiText

The doc is full of useful info but yes it’s not that easy to navigate, especially when a new user does not have all the terminology.

I think we should display a quick overview of the different features of TW on the home page so that users know how to call and thus search for things.

Maybe a cheatsheet that serve as demo with basic examples, macros, widgets, filters, transclusions, etc., or a lexicon/index/Table-of-Contents with links to the relevant tiddlers.

That looks like a fantastic resource! Thank you.

I did my own, “How do I build a glossary” work and it ends up very different from yours. It serves a different purpose, as I want to specifically list the items that appear in the glossary, and their tiddler titles are appropriate names to look them up with. The list of terms tagged “Glossary” is the last entry in my main table of contents, but if you load that tag itself, you will get a definition list with a DT for each such tiddler and a matching DD containing the first paragraph of the tiddler and a [...more] link for the rest. Then when I needed that same DL format elsewhere, I was able to extract it to a global macro I could use like

<<ExcerptList [tag[Glossary]]>>

And that’s where I started feeling like I was getting the hang of TW.

I will be reading the rest of those entries carefully; while it’s not exactly what I would like for such reference, it’s the closest I’ve seen so far.

In fact, that was one of the places I looked. But once I figured out my other parts, especially how to split the text for a given tiddler into lines and count those lines, I didn’t see right off – including in that section and some of its initial links – how to then turn my linked text into plain text. Now that I’ve seen it here, I probably won’t forget. But finding it still is hard.

Right, and I think I right now have 30 - 40% of the terminology I would like to have to do this right. I’ll get there.

Perhaps, but that main site is so full of content, it’s hard to know how to call attention to it for people like me coming in to it with a good chunk of the knowledge necessary but not all. The Content/Learning section already has 41 topics, and there are more nested deeper. It would be great if the main site can serve this sort of tutorial role as well, but I’m afraid it might be difficult.

Yes, that’s what I’m imagining. There are several reasonable attempts out there, but from my perspective, they cover the easy stuff, and not the somewhat more advanced things I’m running into.

1 Like