Opened 7 years ago

Last modified 7 years ago

#9271 new enhancement

Using the Color Macro on Wiki Links

Reported by: Benjamin Lau Owned by: Mikael Relbe
Priority: normal Component: WikiExtrasPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.11


So I'm trying to create links that has a different color to have a feature like spoiler text as found on TvTropes... but applied to links.

I thought the obvious syntax would be something like:

[[Color([wiki:SandBox testing 1 2 3],white)]]

But this comes out as normal link color...

After some digging I now understand why... which is that the <a> tag generated for the link has a class of "wiki" defined which is overriding the <span> created by the color macro.

Is this something that can be fixed? Or is this just going to be a limitation of the macro? I tried a couple of things in the code... but ran into a different issue... but maybe I'm going about it the wrong way:

            html = Markup(format_to_html(self.env, formatter.context, text).replace('class="wiki"',''))                                                      

This managed to remove the class definition... but introduced some paragraph elements... which broke things again... but maybe I'm missing something obvious (and I don't think what I did above is the right solution to this particular problem).

Attachments (0)

Change History (1)

comment:1 Changed 7 years ago by Mikael Relbe

I understand your concern, but I think intervening with the class assignments defined by Markup is a wrong (dangerous) path.

I use the color macro myself mostly for highlighting text with a background color:

[[Color(Yellow background, even behind links as WikiStart, /yellow)]]

If the link color would be affected by a foreground color, the link would not be distinguished from ordinary text. That could be solved by splitting up the text in several color-sections, if link color would be affected.

But I think it would be better to introduce a new macro that collapses a section, like attachment sections in Trac 0.13dev (and perhaps 0.12.x too).

But you could put spoiler text in a subpage...

Modify Ticket

Change Properties
Set your email in Preferences
as new The owner will remain Mikael Relbe.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.