Hard-replace macros at tiddler save

142 views
Skip to first unread message

Anjar

unread,
May 14, 2021, 6:04:01 AM5/14/21
to TiddlyWiki
Hi,

Somewhere in the thread on permalinks it was suggested to have a macro that is actually replaced when the tiddler is saved. Say <<<a macro>>> will actually be replaced by the wikified output of the macro, whereas <<a macro>> is only replaced at rendering, as it is now

Why would this be useful?
- When sharing a tiddler with someone who doesn't have <<a macro>> in their tiddlywiki
- Enhanced performance (?)
- You are guaranteed that the output will not change. In the permalink case, I think, the example would be to replace <<hardlink "aTitle">> with something like <$button><$list filter="[created[..aTitle!!created..]]"><$action-navigate $to=<<currentTiddler>> /></$list>aTitle</$button> where ..aTitle!!created.. is not a reference but the actual value


Thoughts?


Best,
Anders

PMario

unread,
May 14, 2021, 10:31:33 AM5/14/21
to TiddlyWiki
On Friday, May 14, 2021 at 12:04:01 PM UTC+2 Anjar wrote:

- You are guaranteed that the output will not change. In the permalink case, I think, the example would be to replace <<hardlink "aTitle">> with something like <$button><$list filter="[created[..aTitle!!created..]]"><$action-navigate $to=<<currentTiddler>> /></$list>aTitle</$button> where ..aTitle!!created.. is not a reference but the actual value

Thoughts?

I think in general this is a sensible idea. ... But I also think it's "over-engineering" ...

If exporting "connected" tiddler is a problem, we may need to improve the "export" mechanisms. Which imo would be the right place to tackle this specific problem.

just a thought.
mario


Anjar

unread,
May 15, 2021, 5:51:33 AM5/15/21
to TiddlyWiki
Another use case was just posted (on how to combine the text from several tiddlers into a single tiddler so that the original tiddlers can be deleted): https://groups.google.com/g/tiddlywiki/c/xTCzMIj0uqs Good solutions were suggested, but it would also be very simple to just write <<<insertTiddlerText "..somefilter...">>> and have it replaced with the text of those tiddlers or  <<insertTiddlerText "..somefilter...">> if one wants to keep transcluding

Best,
Anders

Taylor Jensen

unread,
May 21, 2021, 7:09:10 PM5/21/21
to TiddlyWiki
I'm interested, but I'm not sure how to go about it. How can I run a macro on tiddler save to make what is essentially text substitutions?

Soren Bjornstad

unread,
May 21, 2021, 7:26:46 PM5/21/21
to TiddlyWiki
In terms of use cases, in MediaWiki similar functionality is called template substitution, and they've listed some applications at Wikipedia.

Taylor Jensen

unread,
May 21, 2021, 8:29:27 PM5/21/21
to TiddlyWiki
What I really need is mechanically, how do I get code to run on-save in TiddlyWiki.

TW Tones

unread,
May 21, 2021, 9:23:34 PM5/21/21
to TiddlyWiki
Perhaps in a related solution I created a snapshot tool. It converts what a tiddler displays into html and saves it in another tiddler, then displays the snap shot in the original tiddler. 

The reason was to capture content at a point in time,  and to save processing by not regenerating the tiddler until a refresh is requested. This snapshot can be dragged to any wiki and will; look the same, because the data and macros in the original where captured in the snapshot as fixed html. If you are using special CSS you may need to incorporate that with the snapshot.

I mention this because you could design your own snapshot method to include what you want in it, ie run macros and produce results, and capture the results.

The quick hack is to install the Internals core plugin, then use the preview in a tiddler editor, and look at the RAW HTML preview, select and copy the actual html, and paste this html into Another tiddler.

Regards
Tones

Frédéric Demers

unread,
May 21, 2021, 11:17:12 PM5/21/21
to TiddlyWiki
@t one option is to replace the save button as in this example: https://ibnishak.github.io/Tesseract/pluginsandmacros/hashtag2tag.html

Probably not super clean and it cripples the keyboard short cut when saving tiddlers...

Taylor Jensen

unread,
May 25, 2021, 6:14:59 PM5/25/21
to TiddlyWiki
This seems like it could be modifiable into what I'm after, can you link it?

-TCJ

Frédéric Demers

unread,
May 25, 2021, 9:00:50 PM5/25/21
to tiddl...@googlegroups.com
Hi Taylor, I linked it in my previous post: https://ibnishak.github.io/Tesseract/pluginsandmacros/hashtag2tag.html
or were you looking for something different?

The other option to run code upon tiddler save is to add wikitext processing as in this example: https://danielorodriguez.com/TW5-AutoTag/


--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/crnjiJ4Spq4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/7b80a6fd-9ed1-450c-8232-610bec0ce7cbn%40googlegroups.com.

Taylor Jensen

unread,
May 25, 2021, 11:37:38 PM5/25/21
to TiddlyWiki
Oh sorry, I'm just blind. I'll see if I can make this into something that works for me, thanks!

Reply all
Reply to author
Forward
0 new messages