[IDEA] Extract Feature in The TiddlyWiki Core

If you search this forum or the old Google group, you will find many discussions users looking for a simple way to extract a substring from an input string e.g. tiddler fields (by default the text field). All the time workarounds or complex solutions are given.

My initial proposal is to add an extract feature to the TiddlyWiki core (written in JS for speed).

The extract should accept an input, and one or two delimiters. The best approach may be a filter operator like:
[all[current]extract[start-delimiter],[end-delimiter]]

Please give your thoughts/solutions here.


Few References

2 Likes

Have you tried a custom function?

No! share your solution please!

Indeed, I think some solution for this should be featured in the standard distro. It is IMO a very “basic” thing to do and rhymes well with how TW is used.

I created the Cherrypicker plugin many suns ago which is unpolished but conceptually neat. I particularly like that the user is allowed to freely make up custom markers on the fly, to encapsulate what is to be extracted.

2 Likes

Yes, I have seen it! similar solutions are find macro from kookma, and extract from Elmiger!
Added to the reference list in the first post!

1 Like

https://tiddlywiki.com/#allbefore%20Operator

https://tiddlywiki.com/#allafter%20Operator

Using those you could write your own .extract[] operator.

This is a user-defined filter operator in pure wikitext. However, I hope that TiddlyWiki can have its core filter operator written in JavaScript.

The User Defined Extract Filter Operator - Tips & Tricks - Talk TW (tiddlywiki.org)

Please share your thoughts/solution for this user defined extract filter operator.

  • No need as you did it, yes?

I suggest we test the “custom filter operator” and versions of it, and see if it really needs to be javascript from a performance perspective, rather than assume.

  • Any filter committed to Javascript may need to handle nesting etc… and missing closures (Since they are legal in TW) implied at the end of tiddler.

It would be interesting to run this after render on a tiddler for the <p></p> delimiters to see what happens, and it may also put in perspective the value of post render.

  • For example perhaps extracting
    • <section>Content in a section that otherwise looks normal</section> or
    • <abstract>an abstract of the current tiddler or a block of content</abstract>
    • even <footer style.display="none">footer details</footer> A footer not visible in view one in editor that a view template places in an appropriate place in the view template.

See the two wikitext solutions here and there.