<<forEachTiddler
where
'tiddler.tags.containsAny(["definition"])'
sortBy
"tiddler.title.toLowerCase()"
ascending
script
'
function getFirstLine(s) {
var m = s.match(/\s*(.*)/);
return m != null && m.length >= 1 ? m[1] : "";
}
'
write
'";[["+tiddler.title+"]]\n:{{green{"+getFirstLine(tiddler.text)+"}}}\n"'>>
I need a glossary tiddler that includes only the first line for each term tagged "definition". (The full tiddler for each term often goes on to include examples, history, other associated data.)Here's how the glossary worked at my old site using ForEachTiddler :<<forEachTiddler
where
'tiddler.tags.containsAny(["definition"])'
sortBy
"tiddler.title.toLowerCase()"
ascending
script
'
function getFirstLine(s) {
var m = s.match(/\s*(.*)/);
return m != null && m.length >= 1 ? m[1] : "";
}
'
write
'";[["+tiddler.title+"]]\n:{{green{"+getFirstLine(tiddler.text)+"}}}\n"'>>What's the most straightforward way to translate this into TW5?
<$list filter="[tag[definition]sort[title]]">
<$link /><br>
@@color:green; {{{ [<currentTiddler>get[text]splitregexp[\n]first[]] }}}@@
</$list>
On Sunday, December 22, 2019 at 8:25:54 AM UTC-8, springer wrote:I need a glossary tiddler that includes only the first line for each term tagged "definition". (The full tiddler for each term often goes on to include examples, history, other associated data.)Here's how the glossary worked at my old site using ForEachTiddler :<<forEachTiddler
where
'tiddler.tags.containsAny(["definition"])'
sortBy
"tiddler.title.toLowerCase()"
ascending
script
'
function getFirstLine(s) {
var m = s.match(/\s*(.*)/);
return m != null && m.length >= 1 ? m[1] : "";
}
'
write
'";[["+tiddler.title+"]]\n:{{green{"+getFirstLine(tiddler.text)+"}}}\n"'>>What's the most straightforward way to translate this into TW5?
<$list filter="[tag[definition]sort[title]]">
<$link /><br>
@@color:green; {{{ [<currentTiddler>get[text]splitregexp[\n]first[]] }}}@@
</$list>
In TW5, the <$list> widget is the equivalent of the TWClassic "ForEachTiddler" macro...
Depending on what you are trying to do a method I use may help,
Testing the text field for a prefix.
Get[text]prefix[https://]
this partial filer can for example identify Tiddlers containing a link pasted with ctrl V
Tony
<$list filter="HelloThere">
<$list filter="[all[current]get[text]splitregexp[\n]prefix[Abstract:]]" variable=abstract>
<$link to=<<currentTiddler>> ><$text text=<<abstract>>/></$link>
</$list>
</$list>
Abstract: Tiddler introducing Tiddlywiki features
<$list filter="HelloThere">
<$link to=<<currentTiddler>> ><$text text={{{ [all[current]get[text]splitregexp[\n]prefix[Abstract:]removeprefix[Abstract:]] }}}/></$link></$list>
I'm quite sure that your work was at the core of most of what I achieved in TW Classic. I'm deeply grateful for that, and also appreciative that you're still so active in the community!
Something about the filtered list code in your reply is not *yet* coming out quite right (first impression: It isn't showing the titles, and looks as though some css styling is getting applied inappropriately, and isn't handling wikified text in the definition tiddlers properly), so there may be just a small typo, or something, that's not quite right? I'll poke around later. I'm quite sure I'll be able to troubleshoot it with another chunk of time. Thanks!
<$list filter="[tag[definition]sort[title]]">
<$link><$text text=<<currentTiddler>>/></$link><br>
<$wikify name="firstline" text={{{ [<currentTiddler>get[text]splitregexp[\n]first[]] }}}>
@@color:green; <<firstline>>@@<br>
</$wikify>
</$list>
Sorry, the filter tag[definition] was only partial. I just assumed you would have a proper filter according to your needs. E.g. [all[current]] etc...
Regards
Tony