@TW_Tones, @pmario: Thanks for the helpful input that put me on a good track.
In the space of an evening I whipped up a template that pretty much does what I need:
Any (and only) system tiddlers become linked, and tag references are replaced by proper tag pills. Note that links are only created for existing tiddlers or shadows, but not e.g. the parameter in the
addprefix
filter.
The template code is not very complicated or long:
\rules except dash
\whitespace trim
\define category() [is[tiddler]] ~[is[shadow]]
\define cleanup() [encodehtml[]search-replace:g[{],[{]search-replace:g[}],[}]search-replace:g[--],[‐‐]]
\define format-tag() <$list filter="[<__text__>subfilter<category>prefix[$:/tags/]]" emptyMessage="<$text text=<<__text__>> />" ><span class="mwi-code-tag"><<tag>></span></$list>
\define format-link(text) <$list filter="[<__text__>subfilter<category>!prefix[$:/tags/]]" emptyMessage=<<format-tag>> ><$link/></$list>
<style>
.mwi-code-tag .tc-tag-list-item {
display: inline-flex;
}
</style>
<pre>
<$let coreTiddlerRE="(\$:\/[\w\/-]+)"
replacementRE="""</code><<format-link "$1">><code>"""
text={{{ [all[current]get[text]] }}} >
<$list filter="[<text>splitregexp[\n]]" variable="line">
<$let parsedLine={{{ [<line>subfilter<cleanup>addprefix[<code>]addsuffix[</code>]search-replace:gi:regexp<coreTiddlerRE>,<replacementRE>] }}}>
<<parsedLine>><br>
</$let>
</$list>
</$let>
</pre>
I tried to deactivate the dash rule by pragma, but was unsuccessful and thus had to add a search-replace
for double-hyphens as they do appear in HTML comments. I had to escape a few other characters as well, in order not to cause unwanted changes in the output. Might’ve been done with rules, if they worked.
The style would normally go into the StyleSheet and is here just for completeness. Without the CSS rule, the tag pill has a height that is too large and moves when clicked. Didn’t care to find the cause and just quick’n’dirty jury-rigged it.
To use the template, just copy the code into a tiddler and set it in $:/config/ViewTemplateBodyFilters/system
.
This is the way of the Cascade.
Have a nice day
Yaisog