Brilliant! Thanks Eric.

Can you suggest any better way to extract the a "excerpt" of a tiddler?
I found this get_extract function searching this forum but it kind of 
breaks the text by eating the formatting html. I just want plaintext of the 
first 140 characters or so with non-relevant characters replaced by spaces 
(and multiple spaces trimmed to one).

Cheers,
Adithya

On Saturday, August 15, 2020 at 9:29:36 PM UTC+5:30 Eric Shulman wrote:

> On Saturday, August 15, 2020 at 8:39:40 AM UTC-7, Adithya B M wrote:
>
>> Please look at the code below. In this, the get-extract() should called 
>> if the description field is absent. How could this be made to work?
>>
> \define get_description()
>> <$text text={{{ [<currentTiddler>get[description]else<get-extract
>> <currentTiddler>>] }}} />
>> \end
>>
>> \define get-extract(title)
>> <$wikify name="output" text={{$title$}} mode="block" output="text">
>> <$text text={{{ [<output>split[]first[500]join[]] }}}/>
>> </$wikify>
>> \end
>>
>
> Unfortunately, you can't invoke a macro with parameters from inside a 
> filter.  Instead, you can "pre-compute" the extract value, and then use the 
> filter, like this:
> \define get_description()
> <$wikify name="extract" text={{{ [<currentTiddler>get[text]split[]first[
> 500]join[]] }}}>
> <$text text={{{ [<currentTiddler>get[description]else<extract>] }}} />
> </$wikify>
> \end
> Note that for the $wikify widget, mode="block" and output="text" 
> parameters are the defaults, so they can be omitted.
>
> -e
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/6c59746c-764a-4c8a-a386-096e81fa1096n%40googlegroups.com.

Reply via email to