[TW5] Extracting Introductions From Tiddlers

474 views
Skip to first unread message

Tobias Beer

unread,
Oct 5, 2016, 2:15:39 AM10/5/16
to tiddl...@googlegroups.com
Hi everyone,

Here's a little How To for:


...using tobibeer/split to extract the desired content.

Two methods are explained for defining and extracting introductions:
  1. for Introductions being
    the opening lines to a tiddler,
    separated via something like ~~~~

  2. for multiline Summaries / Excerpts / Introductions
    in an otherwise hidden html comment
    that you don't want displayed by default
    but use somewhere else to show
    an abstract of some other tiddler

  3. And —  as thoughtfully requested by PMario —
    how to simply extract whatever is the first paragraph
    as the introduction of a tiddler.
Best wishes,

Tobias.

PMario

unread,
Oct 5, 2016, 3:49:06 AM10/5/16
to TiddlyWiki
Hi Tobias,

Nice plugin.

One example, that you could include. IMO it's the cleanest way, to use the first 2 line breaks as a separator. Like so

<$list filter="[all[current]get[text]split:first[

]addsuffix[]]">

//<<currentTiddler>>//
</$list>

So the first paragraph of the tiddler will be used, without the need for an "interrupting" element

just my 2€ents
-mario

Tobias Beer

unread,
Oct 5, 2016, 5:50:48 AM10/5/16
to TiddlyWiki
Hi Mario,


IMO it's the cleanest way, to use the first 2 line breaks as a separator.

Sure thing, will add.

Personally, I would prefer some inline separator,
so I am not forced to always make the introduction a paragraph of its own.
But sure, that's a meaningful option.

Best wishes,

Tobias.

Thomas Elmiger

unread,
Oct 5, 2016, 7:44:14 AM10/5/16
to TiddlyWiki
Hi Tobias

This looks very interesting! Could your solution do something like
– extract the first 200 characters
– check, if we are in an &entity; and either cut before & or after ;
– trim whitespace and append " …"

If yes, could you provide an example for this too?

This is how designers would generate excerpts to make sure the snippets all have about the same text length …

Kind regards, Thomas

Tobias Beer

unread,
Oct 5, 2016, 1:19:56 PM10/5/16
to TiddlyWiki
Hi Thomas,

There is not quite a way to automagically identify markup in wikitext.
It all boils down to what the parser makes of your wikitext.
Entities would be but one problem issue.
What about any other WikiMarkup?

I'm quite certain: you have to be specific about
either how or where you set your marker.
You don't want no guessing.

Best wishes,

Tobias.

Thomas Elmiger

unread,
Oct 5, 2016, 1:43:03 PM10/5/16
to TiddlyWiki
Hi Tobias

Hmm, guess I will try to use CSS then – this deals with final rendered content.

Thanks a lot!
Thomas

Josiah

unread,
Oct 6, 2016, 6:18:06 AM10/6/16
to TiddlyWiki
Ciao Tobias

That is useful.

FYI I will myself use it with a distinct separator. So that the extracted string meets requirements needed for specific purposes ... for example no longer than 140 characters so it can be Tweeted. Your solution fits well my kind of use case.

Best wishes
Josiah

David Szego

unread,
Oct 8, 2016, 9:22:12 PM10/8/16
to TiddlyWiki
Tobias, you never cease to amaze me. That is *so* perfect for a table of contents I was just creating! Thanks!
D.


On Wednesday, 5 October 2016 02:15:39 UTC-4, Tobias Beer wrote:
Hi everyone,

Here's a little How To for:

David Szego

unread,
Oct 8, 2016, 11:23:23 PM10/8/16
to TiddlyWiki
Try your normal TableOfContents with a twist...

For every Tiddler tagged with "TableOfContents", make it look like this:

This is what this subtopic is about~~~~

<$list filter="[tag[SubTopicTab]]">
<<fa circle 1>><$link><<currentTiddler>></$link><br>
 
<$list filter="[all[current]get[text]split:first[~~~~]addsuffix[...]]">

>//<<currentTiddler>>//
 
</$list>
</
$list>

And then for every Tiddler tagged with SubTopic, do this same...
And finally, for every Tiddler with some readable text, add ~~~~ after the first little bit...

You get a lovely Table Of Contents that looks like:


Family

Anything to do with the kids, cousins, even the dogs...

  • FamilyArchive

Capturing all our photos, videos, documents, and more......

  • FamilyTree

Tracing my history as far back as I can......

  •  Tiddler Without ~~~~'s
  • Isaac

My biggest boy......

  •  AnotherTiddlerWithoutTildes


...etc.


Note, if you don't have FontAwesome installed (why not?) use this, and remember the blank lines are important:

<$list filter="[tag[SubTopicTab]]">

*<$link><
<currentTiddler>></$link><br>
  <$list filter="[all[current]get[text]split:first[~~~~]addsuffix[...]]">

>//<
<currentTiddler>>//
  </$list>
</$list>


David Szego

unread,
Oct 8, 2016, 11:41:51 PM10/8/16
to TiddlyWiki
Oooh, this is even nicer... If you use this filter, you can delineate an excerpt in your Tiddler:

<$list filter="[tag[SomeTag]]">
<
<fa circle 1>><$link><<currentTiddler>></$link><br>
  <$list filter="[all[current]get[text]] +[split:first pos=2[~~~~]] +[addsuffix[...]]">

>//<
<currentTiddler>>//
  </$list>
</$list>

So if your Tiddler of Steve Job's Commencement Address looks like this:

This is the text of the Commencement address by Steve Jobs, CEO of Apple Computer and of Pixar Animation Studios, delivered on June 12, 2005:

I am honored to be
with you today at your commencement from one of the finest universities in the world. ~~~~I never graduated from college. Truth be told, this is the closest I've ever gotten to a college graduation. Today I want to tell you three stories from my life. That's it. No big deal. Just three stories.~~~~

The first story is about connecting the dots....


The table of contents (or whatever you use that <$list filter="[all[current]get[text]] +[split:first pos=2[~~~~]] +[addsuffix[...]]"> for) looks like this:

  • Steve Job's Commencement Address

I never graduated from college. Truth be told, this is the closest I've ever gotten to a college graduation. Today I want to tell you three stories from my life. That's it. No big deal. Just three stories....

Very nice indeed!

David Szego

unread,
Oct 8, 2016, 11:46:41 PM10/8/16
to TiddlyWiki
To do the same in a macro:

Tiddler: $:/macros/davidSzego/excerpt
Tag: $:/tags/Macro
Text:

\define excerpt(tiddler)
<$list filter="[title[$tiddler$]get[text]] +[split:first pos=2[~~~~]] +[addsuffix[...]]">

>//<<currentTiddler>>//
</$list>
\end

Usage:

<<excerpt "Steve Job's Commencement Address">>

Result (assuming that Tiddler is what I described above):

Tobias Beer

unread,
Oct 9, 2016, 5:26:42 AM10/9/16
to TiddlyWiki
Hi David,

Thanks for that.
Should've thought about that as well
to kinda round up the package.

Will add a demo macro
to the how to as well. 

Best wishes,

Tobias.

sini-Kit

unread,
Oct 9, 2016, 7:25:30 AM10/9/16
to tiddl...@googlegroups.com
Hi, Tobias. Nice plugin. I try to write filter without it

---
<$list filter="[{Extracting Introductions From Tiddlers}] +[splitbefore[~~~~]removesuffix[~~~~]addsuffix[...]]"> <<currentTiddler>> </$list>

---




среда, 5 октября 2016 г., 9:15:39 UTC+3 пользователь Tobias Beer написал:

Tobias Beer

unread,
Oct 9, 2016, 11:16:36 AM10/9/16
to tiddl...@googlegroups.com
Hi everyone,

based on the feedback of others,
especially David and sini-Kit,
I did some major rewriting of the article:
I have added a macro,
a bit different than David's,
which I now recommend for both
defining and retrieving multi-line introductions.

I also briefly mentioned
what I've been using mostly
before this little article:
a summary field, as explained here:

Conditional ViewTemplate Section @ tb5

Best wishes,

Tobias.

sini-Kit

unread,
Oct 10, 2016, 3:33:18 AM10/10/16
to TiddlyWiki
if our tiddler don't have any ~~~~ nothing will be shown. So it is necessary to add  emptyMessage to our $list in my variant  emptyMessage={{Extracting Introductions From Tiddlers}}

воскресенье, 9 октября 2016 г., 18:16:36 UTC+3 пользователь Tobias Beer написал:

Stefan Spycher

unread,
Oct 25, 2017, 3:44:15 AM10/25/17
to TiddlyWiki
Hi Tobias,

Quick question on a potential limitation of the split plug-in i just stumbled over:

the code

<ul>
<$list filter="[tag[excerpttest]]">
<li> <$link><<currentTiddler>></$link><br>
  <$list filter="[all[current]get[text]split:first[~~~~]addsuffix[...]]">
//<
<currentTiddler>>//

  </$list>
</li>
</$list>
</ul>

returns the first  instance of the marker...any subsequent excerpt in the same gets ignored. i understand the use case you're coming from, but would there be a way of extracting all snippets in the same tiddler?
Reply all
Reply to author
Forward
0 new messages