Italicize tag iff there's no tiddler there (tag itself is "missing")

It would be so straightforward and consistent if the tag pill would display in italics for tags whose home-tiddler does not exist, as in this graphic:

Quick demo of this tiny tweak: 🎯 Quick demo — ... of tag-pill italics iff missing

While using “off-the-shelf” TiddlyWiki, one has to click on the tag pill, and look at the drop-down, in order to see whether the tag’s governing tiddler appears in italics or not.

I realize that some TiddlyWiki users don’t tend to put actual content into the tiddlers that serve as tags. Perhaps those folks would not care about this behavior, but would anyone specifically prefer not to incorporate this info? (Even if you don’t usually interact directly with these tag-governing tiddlers, the italics could confirm at a glance that there’s no info there, including in its list field.)

What do you think, @TW_Tones? This strikes me as a natural mini-feature of reimagine-tags (or is it reimagin-tags?)…

In 5.3.2+, the tweak is super-easy, thanks to conditional shortcut syntax:

In $:/core/macros/tag the string <$view tiddler=<<__tag__>> field="title" format="text" /> is replaced by:

<%if [<__tag__>!is[missing]] %>	<$view tiddler=<<__tag__>> field="title" format="text" />
<% else %>
//<$view tiddler=<<__tag__>> field="title" format="text" />//
<% endif %>
4 Likes

This is really nice, I like how well it pairs with the tag counts as well, but is it possible to make this using filter syntax so it can be used on older tiddlywiki?

Of course it’s possible! The conditional shortcut is — after all — just a shortcut.

That’s a relief, I’m gonna take a crack at making it, with any luck I’ll include it here :grinning_face_with_smiling_eyes:

(To be perfectly honest, I still haven’t dug much into the shortcut syntax things, so I wasn’t 100% sure if it was :sweat_smile:)

Edit: Ok!

So here is what I got for any older TW to use.

  1. you can either replace the default $:/core/macros/tag or clone it and add the list-after field with the value of $:/core/macros/tag in it.

  2. locate the string <$view tiddler=<<__tag__>> field="title" format="text" />

  3. Replace with the following:

	<$wikify name="view" text="{{{ [<__tag__>!is[missing]then<tag-present>else<tag-missing>] }}}" mode=inline>
		<<view>>
	</$wikify>
  1. At the top of the tiddler, add the folllowing two definitions, which are used in the wikify widget.
\define tag-present()<$view tiddler=<<__tag__>> field="title" format="text" />
\define tag-missing()//<$view tiddler=<<__tag__>> field="title" format="text" />//

And boom, nice formatted tag text like @Springer 's awesome demo.

Edit 2: For a cleaner approach, @EricShulman has worked his magic once again, please see further below :grinning_face_with_smiling_eyes:

1 Like

I agree this little indicator would be useful but it could be toggled on by those interested.

If I have it my way in the long run most tags will have tiddlers as they will contain a display condition and others features.

But with the posibilities @Springer and I have discussed to make more use of missing tiddlers a little more info is a great idea.

But I could also look at doing something similar in my filter tags solution by actualy having tiddlers for them. Filter tiddlers.

Here’s a way to code this that doesn’t use $wikify or extra macros that contain mostly identical code (and are also globally-defined since $:/core/macros/tag is itself tagged with $:/tags/Macro):

<span style={{{ [<__tag__>is[missing]then[font-style:italic;]] }}}>
<$view tiddler=<<__tag__>> field="title" format="text" />
</span>

enjoy,
-e

4 Likes

I do use them for content, and would love for this tweak to be in core!

1 Like

As do I very regularly, and the italized text is a wonderful way to tell what I have linked to a topic a lot but haven’t yet visited. (in combination with the tag-count plugin, I should add.)

Brilliant!

I knew the hack could be done without the conditional shortcut syntax, but did not see how an approach without that syntax could also be much more elegant and efficient.

Just a little rider, this <__tag__> and this <<__tag__>> is valid now because the current tag macro is \defined as a macro and not a procedure.

  • If this macro (tag macro) is due a rewrite like @pmario recently suggested it will most likely become a procedure.
  • We may also dump the view widget
  • such a rewrite of the tags macro would be a good time to introduce the italics for missing tag tiddlers tag pill feature.
1 Like

@Springer I have added this feature to my latest version of reimagine-tags but I had to do it a little differently because I allow a label as well, in this case if the tag does not exist the label if in use will also be italic.

<$element-tag$
	$element-attributes$
	class="tc-tag-label tc-btn-invisible"
	style=<<tag-pill-styles>>
>$actions$<$transclude tiddler="""$icon$"""/><$list filter="[<__tag__>!is[missing]]" emptyMessage="""//<$text text={{{ [[$label$]!is[blank]else<__tag__>]}}}/>//""" variable=~><$text text={{{ [[$label$]!is[blank]else<__tag__>]}}}/></$list></$element-tag$>

As illustrated here https://conditional-elements.tiddlyhost.com/ I hope any rewrite of the tags macros will also

  • check if the tag tiddler has a condition field before displaying it on the view template.
  • allow a title to be used instead of the tag tiddler, kind of a caption for the tag pill but not the tag tiddler.
2 Likes

I did create a GH issue, so it will not be forgotten: [IDEA] Proposal to format missing tag pill text in italic if tiddler is missing · Issue #7950 · Jermolene/TiddlyWiki5 · GitHub

1 Like

There should be a preview-version soon at: add tc-tag-missing or tc-tag-exists to tag pills including docs by pmario · Pull Request #7951 · Jermolene/TiddlyWiki5 · GitHub

4 Likes