Nice hack!

Added to TW-Scripts

On Saturday, January 18, 2020 at 12:28:11 AM UTC+3:30, Eric Shulman wrote:
>
> On Friday, January 17, 2020 at 10:33:12 AM UTC-8, Damon Pritchett wrote:
>>
>> I have another question for ya'll. Is it possible to color certain table 
>> of contents entries based on a tiddler field? If so, does this also apply 
>> to the tocP macro? Here's my scenario. I have a collection of images. Some 
>> of these images are only downloaded and some of them I own hard copies of. 
>> Each image has its own tiddler with a lengthy description. I want to have 
>> the images I own show up as a different color in my table of contents.
>>
>
> Yes, it is possible.  Here's how:
>
> By default, the items in a TOC display use the *title* of each tiddler.  
> However, if you define a *caption* field for a tiddler, the TOC will use 
> that text instead.  This is most often used to bypass the CamelCase name of 
> the tiddler (e..g, "Hello there", instead of "HelloThere") or to provide a 
> longer, more prosaic alternative (e.g, "Greetings and Felicitations!").
>
> However, the caption text can also contain other wiki syntax, such as the 
> "@@" styling syntax, which lets you specify CSS classnames or inline 
> styles.  For example, suppose you want a TOC item to be displayed using red 
> text.  To do this, you could write the following in the caption field for 
> that tiddler:
> @@color:red; Text goes here@@
>
> Alternatively, for more "global" control over the appearance, you could 
> use a CSS classname (e.g., "myTOC"), like this:
> 1) First, define a stylesheet tiddler (tagged with $:/tags/Stylesheet), 
> containing
> .myTOC { color:red; }
> 2) Then, in the caption field of the desired TOC item, write:
> @@.myTOC Text goes here@@
>
> The advantage of the classname method is that you then have centralized 
> control over the styling for *all* similar TOC items, without having to 
> separately re-edit the caption entries of each item.  Thus, if you decide 
> to change the color, or add other CSS attributes, you only have to change 
> the stylesheet tiddler.  For example:
> .myTOC { color:green; font-size:150%; border:1px solid; }
>
> enjoy,
> -e
> Eric Shulman
> TiddlyTools: "Small Tools for Big Ideas!" (tm)
> InsideTiddlyWiki - http://www.TiddlyTools.com/InsideTW
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/757d780e-a0a2-433b-92b9-1a1f39590dcc%40googlegroups.com.

Reply via email to