Transclusion Filter for specifying character limit and raw transclusion

79 views
Skip to first unread message

Raghu Veer S

unread,
Apr 15, 2020, 8:56:54 AM4/15/20
to tiddl...@googlegroups.com
As the title says, I want to transclude contents of one tiddler into another but limit the number of characters that are transcluded, meaning, when I transclude a tiddler I want to be able to specify the number of characters to be shown in the new tiddler. Also strip the formatting from the content that is transcluded. Is there a way to achieve something like that?

An example would be: <$transclude tiddler="Tiddler1" characterlimit="100" mode=raw />

If Tiddler1 looks like this:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua
. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat
. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur
. Excepteur sint occaecat cupidatat non
proident
, sunt in culpa qui officia deserunt mollit anim id est laborum.

lorem ipsum dolor sit amet
, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua
. ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat
. duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur
. excepteur sint occaecat cupidatat non
proident
, sunt in culpa qui officia deserunt mollit anim id est laborum.

lorem ipsum dolor sit amet
, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua
. ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat
. duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur
. excepteur sint occaecat cupidatat non
proident
, sunt in culpa qui officia deserunt mollit anim id est laborum.

When I say <$transclude tiddler="Tiddler1" characterlimit="100" mode=raw /> in Tiddler2, It should only transclude:

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore

And mode=raw should be able to strip all the formatting from the original tiddler and only fetch the text without any markups. Any help is appreciated.




PMario

unread,
Apr 15, 2020, 9:30:02 AM4/15/20
to TiddlyWiki
Hi,

What if  Tiddler1 contains {{Tiddler2}} and Tiddler2 contains the "lorem ipsum" stuff?

and you say: <$transclude tiddler="Tiddler1" characterlimit="100" mode=raw />

You'd see: {{Tiddler2}} Is that OK for you?

There are some discussions here in the group. But I can't find them atm.

@Others may jump in here!

-m

Jeremy Ruston

unread,
Apr 15, 2020, 10:16:29 AM4/15/20
to tiddl...@googlegroups.com
Hi Raghu

Here’s a macro that gets close to what you want:

\define show-extract(title)
<$wikify name="output" text={{$title$}} mode="block" output="text">
<$text text={{{ [<output>split[]first[500]join[]] }}}/>
</$wikify>
\end

<<show-extract "HelloThere">>

Transclusions will be respected (ie you’ll see the content of the transcluded tiddler, and not the {{}} markup). The problem is that all the text will appear to be on one line.

That can be fixed with some CSS:

<div style="white-space:pre;">
<<show-extract "HelloThere">>
</div>

Best wishes

Jeremy

And mode=raw should be able to strip all the formatting from the original tiddler. Any help is appreciated.





--
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 tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/c182cb96-7a4a-443e-81d2-942eb5d7b0f6%40googlegroups.com.

Raghu Veer S

unread,
Apr 15, 2020, 10:18:07 AM4/15/20
to TiddlyWiki
Do you mean the problem that could arise as a result of a loop between the two tiddlers if they transclude each other? If that's the case, that's why I proposed a mode=raw, where the markup is stripped off, thereby eliminating any issues due to loop. I'm sorry if this was not what you meant.

Raghu Veer S

unread,
Apr 15, 2020, 10:43:15 AM4/15/20
to tiddl...@googlegroups.com
Thanks a lot Jeremy! Exactly what I wanted. 😀
To unsubscribe from this group and stop receiving emails from it, send an email to tiddl...@googlegroups.com.

Raghu Veer S

unread,
Apr 15, 2020, 11:44:49 AM4/15/20
to tiddl...@googlegroups.com
Although it is working separately, I am unable to get it to work with reflink tidller in TiddlyBlink:


\define mycrit() (?i)\b$(searchspx)$\b

<hr>

<div class="linkstothisnote">
<h3>Links to this note</h3>

<$vars searchme=<<currentTiddler>> searchspx={{{ [<currentTiddler>escaperegexp[]]}}} >

<div class="ln-wrapper">
  <$list filter="[!is[system]all[current]backlinks[]!tag[hide]sort[title]] -[is[current]]">
  <div class="ln-group">
    <$link>
      <p class="ln-title"><$view field="title" /
></p>
     
<p class="ln-excerpt"><<show-extract "title">></p>   <------------ This is how I am trying to use it, but nothing is appearing in other tiddlers. How can I pass the title to show-excerpt macro?
   
</$link>
 </
div>
</$list>
</
div>
</$vars>
</
div>



On Wednesday, April 15, 2020 at 7:46:29 PM UTC+5:30, Jeremy Ruston wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to tiddl...@googlegroups.com.

Jeremy Ruston

unread,
Apr 15, 2020, 12:01:49 PM4/15/20
to TiddlyWiki
Hi Raghu

Instead of <<show-excerpt "title">>, try:

<$macrocall $name="show-excerpt" title={{!!title}}/>

Best wishes

Jeremy.

On 15 Apr 2020, at 16:44, Raghu Veer S <ragh...@gmail.com> wrote:

Although it is working separately, I am unable to get it to work with reflink tidller in TiddlyBlink:


\define mycrit() (?i)\b$(searchspx)$\b

<hr>

<div class="linkstothisnote">
<h3>Links to this note</h3> 

<$vars searchme=<<currentTiddler>> searchspx={{{ [<currentTiddler>escaperegexp[]]}}} >

<div class="ln-wrapper">
  <$list filter="[!is[system]all[current]backlinks[]!tag[hide]sort[title]] -[is[current]]">
  <div class="ln-group">
    <$link>
      <p class="ln-title"><$view field="title" /
></p>

      
<p class="ln-excerpt"><<show-excerpt "title">></p>   <------------ This is how I am trying to use it, but nothing is appearing in other tiddlers. How can I pass the title to show-excerpt macro?
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/c7e9c7f6-6e83-44ff-afcb-2cd3bc0f0ad7%40googlegroups.com.

Raghu Veer S

unread,
Apr 15, 2020, 12:19:31 PM4/15/20
to TiddlyWiki
Thanks Again! Really appreciate the help. It worked.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages