There is a useful trick that we use in the docs in a few places – the typed block syntax works by embedding an entire wikitext context, which allows macro definitions. For example:
Some text at the top
$$$text/vnd.tiddlywiki
\define something() else
<$text text=<<something>>/>
$$$