Tiddlywiki5: Can I truncate a tiddler's plain text to generate description?

Created on 16 Nov 2019  ·  2Comments  ·  Source: Jermolene/TiddlyWiki5

I'm trying to generate description for a tiddler automatically.

I have learned wikify widget, which can turn tiddler source code into plain text without html tags.

<$wikify name="rendered" text={{tiddler-title!!text}} output="text">
<<rendered>>
</$wikify>

I've also learned filter widget, which can split plain text by some special characters.

<$list filter="'abc/def'+[split[/]first[]]">
<<currentTiddler>>
</$list>

But I don't know if there is a way to pipe the two operation together for description generating?

Most helpful comment

Hi @pimgeek

I have learned wikify widget, which can turn tiddler source code into plain text without html tags.

There's a couple of much simpler (and faster) way to achieve the same thing:

<$view tiddler="tiddler-title" field="text"/>
<$text text={{tiddler-title!!text}}/>

But I don't know if there is a way to pipe the two operation together for description generating?

The trick is using triple curly braces for attribute values. The content of the braces is interpreted as a filter (see https://tiddlywiki.com/#Filters), and the first entry from the resulting list is assigned to the attribute (see "Filtered Attribute Values" under https://tiddlywiki.com/#HTML%20in%20WikiText). Thus, you could do something like this:

<$text text={{{ [[tiddler-title]get[text]split[/]] }}}/>

All 2 comments

Hi @pimgeek

I have learned wikify widget, which can turn tiddler source code into plain text without html tags.

There's a couple of much simpler (and faster) way to achieve the same thing:

<$view tiddler="tiddler-title" field="text"/>
<$text text={{tiddler-title!!text}}/>

But I don't know if there is a way to pipe the two operation together for description generating?

The trick is using triple curly braces for attribute values. The content of the braces is interpreted as a filter (see https://tiddlywiki.com/#Filters), and the first entry from the resulting list is assigned to the attribute (see "Filtered Attribute Values" under https://tiddlywiki.com/#HTML%20in%20WikiText). Thus, you could do something like this:

<$text text={{{ [[tiddler-title]get[text]split[/]] }}}/>

Thanks very much for your reply, almost instantly~~

Now I know how to achieve my desired results! Even if my tiddler source has a lot of wiki codes, I can first use $wikify widget to turn it into plain text, and then use the method offered by you. I really should have asked you earlier.

To be specific, you help me turn this tidder source:

[img width="160px" [....jpg]]
 
<a href="https://tiddlywiki.com" rel="noopener noreferrer">
[img[....png]]
</a>

This is a knowledge base built on [[TiddlyWiki]] . First time visitor please goto ...

into this:

This is a knowledge base built on TiddlyWiki

by applying this method:

<$wikify name="rendered" text={{about!!text}} output="text">
<$text text={{{ [<rendered>split[. ]] }}}/>
</$wikify>
Was this page helpful?
0 / 5 - 0 ratings