Explore the simplest way to display hardline break feeds with a single carriage return

use Dynamic css to show hardlinebreaks via tags/stylesheet or /tags/ViewTemplate
1." data-tiddler-title^="<$view field=title/>" " or " data-tiddler-title="<$view field=title/>" " correct (with or without ^)?Q: How can I use a custom field to style a tiddler?
2. This works, but I suspect there is a massive performance penalty! image|690x250. How can I optimize?

Add a tiddler tagged $:/tags/ClassFilters/TiddlerTemplate such that the story tiddler template for every tiddler with the given creator is given a custom class name. Then use that class name in your CSS.

See https://tiddlywiki.com/#SystemTag%3A%20%24%3A%2Ftags%2FClassFilters%2FTiddlerTemplate

1 Like

I’d forgotten that this mechanism existed. But now I have a question. Why does it not seem to work with the conditional shortcut syntax?

That is, using this stylesheet:

title: My Style
tags: $:/tags/Stylesheet

.blue {background-color: #eef;}

Why does this version work correctly:

title: My Class Filter
tags: $:/tags/ClassFilters/TiddlerTemplate

<$text text={{{ [<storyTiddler>match[HelloThere]then[blue]] }}} /

(You can see it working by downloading ClassFilters_v1.json and dragging it onto tiddlywiki.com. The HelloThere tiddler will get a light blue background.)

But this one does not:

title: My Class Filter
tags: $:/tags/ClassFilters/TiddlerTemplate

<% if [<storyTiddler>match[HelloThere]] %>blue<% endif %>

(Ditto with ClassFilters_v2.json.)

Did I make a silly mistake with the conditional shortcut syntax? Is this not expected to work with such syntax? Or is this a bug?

1 Like

@Scott_Sauyet this mechanism supports filter expressions and not arbitrary wikitext.

Your example would thus be stated as:

[<storyTiddler>match[HelloThere]then[blue]]

2 Likes

Ahh, thank you.

Now it’s a little surprising that the first example worked. But I’m not too worried about that

Cheers!

Evaluated as a filter, there is a valid filter expression in there that returns the correct result in this instance. I would imagine some stray characters are probably also added as CSS classes with that code.

For my own understanding, does that mean:

<$text text={{{ [<storyTiddler>match[HelloThere]then[blue]] }}} /
adds the classes <$text, text={{{, the result of [<storyTiddler>match[HelloThere]then[blue]], and }}} (or the css-escaped versions of those things)?

And <% if [<storyTiddler>match[HelloThere]] %>blue<% endif %>

adds the classes <%, if, the possibly HelloThere, %>blue<%, endif, and %> (or the css-escaped versions)?

(In other words, they add whatever would come out if you put it into the Filter tab of the Advanced Search, except for that the variables are different?)

I will just add here for completeness that a block of text surrounded by triple quotes honors wiki text and does not need double line breaks for a new line, nor does it wrap.

"""
Block
of
text
"""

I have created a editor toolbar button to apply this, I can share.

See Block Mode WikiText

Yes, that is correct.

My current [<storyTiddler>creator[HydroWood]!prefix[Projectify]then[hardlinebreaks]] works. If I want to set the conditional filter to [all[tiddlers]tag[a]] + [all[tiddlers]tag[b]] How should I write it?

By the plus-sign, do you mean that you want all tiddlers with BOTH tags? Or, do you mean all tiddlers with the first tag, plus also all (further) tiddlers that have the b tag?

[all[tiddlers]tag[a]tag[b]then[hardlinebreaks] gets you the hardlinebreaks result only for tiddlers that carry both tags (the intersection of the two sets).

[all[tiddlers]tag[a]] [all[tiddlers]tag[b]] +[then[hardlinebreaks]] gets you the hardlinebreaks result for tiddlers that have either tag (the union of the two sets).

(In practice, I don’t see the need for starting with all[tiddlers] though. [tag[a]tag[b]then[class]] should work, etc.)

Yes, I need the either tag (the union of the two sets).
But [<storyTiddler>[all[tiddlers]!creator[HydroWood]] [all[tiddlers]prefix[Projectify]] +[then[hardlinebreaks]]] doesn’t work, while [<storyTiddler>creator[HydroWood]!the prefix[Projectify]then[hardlinebreaks]] can work, and at the same time, no other code is changed.

if not starting with all[toddlers] , Is the code below correct?

[<storyTiddler>[creator[HydroWood]!prefix[Projectify]] [!prefix[$:/Import]]  +[then[hardlinebreaks]]]  

That should give you, in addition to the special ones picked out by the first filter run, every tiddler with a title that doesn’t begin $:/Import — so pretty much everything!

But my apologies, I had been looking only at your own filter drafts, and not at the context of this discussion, which requires starting with [<storyTiddler>....

Try this:

[<storyTiddler>!creator[Hydrowood]] [<storyTiddler>prefix[Projectify]] +[then[hardlinebreaks]]
  • The first filter run will return the storyTiddler if it’s not created by you.
  • The second filter run will return the storyTiddler if its title starts with Projectify
    ** (Note if the storyTiddler meets both conditions, that doesn’t matter, because filter syntax removes duplicates).
  • The third step considers all that has come before (because of the + prefix, which is short for :and), and based on what’s there it yields “hardlinebreaks” (as the css class to apply) for each value that is present by the time the whole filter expression gets to that step.

Thank you very much! It works well. By the way where did you learn that from? I checked the tiddlywiki.org and googled a lot but got nothing useful.

Do you mean tiddlywiki.com? There’s a great deal there about filters, how filter syntax works, etc. But it does take practice to get the hang of it. I find that the documentation is great for technical points, but it’s sometimes hard to know how to find the help you need there.

One highly-recommended tutorial is Grok TiddlyWiki.

It’s designed to be a pretty thorough step-by-step orientation to TiddlyWiki with tasks, quizzes, and “try it” examples along the way, building from complete beginner to power user. And it’s a fun tutorial because it’s a guided tour of TiddlyWiki that is implemented in TiddlyWiki. At any rate, here’s the beginning of the section on filters:

https://groktiddlywiki.com/read/#Using%20Filter%20Expressions

It runs on 5.2.1 — not the most recent version of TiddlyWiki — so there are some recent features that are not part of its tour. Still, everything in TW5 is backward compatible, and the basic concepts and mechanisms (such as how filters work) haven’t changed at all.

1 Like