Tags:
create new tag
view all tags
It would be nice to specify the color of text. This already can be done using HTML, but a simple way of defining colors with a new WikiSyntax would be better. Ideas?

-- PeterThoeny - 19 Dec 2000

At my instalation I decided this was a needed feature so I went ahead and added the following simple syntax rule: Treat anything between ^/ and /^modifier as a special case. That way I could set up a generic set of rules with the same basic syntax, right now I have implemented basic color modifiers like:

G - green GB - green bold Y - Yellow YB - yellow bold
R - red RB - red bold

rrggbb - rgb color code (letters in all-caps)

But you can see the potential of this simple structure, not to mention that it is consistent and easy to remember. Part of my original vision was to set a modifier-to-HTML-tag table in a wiki variable, that could be accessed from the WebPreferences pages, but I decided on the quick but not so dirty solution.

Here is my code in case you want to give it a try:

   #To be added to the text processing rules (I added it in wikicfg.pm inside extendGetRenderedVersionOutsidePRE)
   # render ^/text/^xxx as defined by the GTLN extensions:
   s#(^|\s)\^/(([^\^/]|[^/]\^|/[^\^])*?)/\^(\w+)([\s\,\.\;\:\!\?]|$)#&handleGTLNformats($2,$4,$1,$5)#geo;
Note that this has no major constraints on what can follow the tags or what can be inside them, as long as it is not the /^sequence itself.
# To be added elsewhere in the file
# GTLN extension =========================
sub handleGTLNformats
{
   my( $gtlnstr, $modifier, $pre, $post ) = @_;
   my $tx = "xxx";
   for( $modifier ) {
      if    (/RB/) { $tx = "<FONT COLOR=\"red\"><B>$gtlnstr</B></FONT>"; }  # red bold text:
      elsif (/R/)  { $tx = "<FONT COLOR=\"red\">$gtlnstr</FONT>"; }     # red text:
      elsif (/GB/) { $tx = "<FONT COLOR=\"green\"><B>$gtlnstr</B></FONT>"; } # green bold text:
      elsif (/G/)  { $tx = "<FONT COLOR=\"green\">$gtlnstr</FONT>"; }   # green text:
      elsif (/YB/) { $tx = "<FONT COLOR=#FFCC00><B>$gtlnstr</B></FONT>"; }  # yellow bold text:
      elsif (/Y/)  { $tx = "<FONT COLOR=#FFCC00>$gtlnstr</FONT>"; }     # yellow text:
      elsif (/[A-F\d]{6,6}/) { $tx = "<FONT COLOR=#$modifier>$gtlnstr</FONT>"; } #any color:
      else         { $tx = "^/$gtlnstr/^$modifier"; } ;
   }
   
    return "$pre$tx$post";
}


-- EdgarBrown - 05 Feb 2001

It's been a long time. Anything new on this front? I was about to post this as an idea but Peter beat me to it by nearly four years.

-- VickiBrown - 12 Nov 2004

Is there some problem with doing it this way?

-- CrawfordCurrie - 12 Nov 2004

Crawford is referring to the colors defined in TWikiPreferences

-- PeterThoeny - 12 Nov 2004

Shouldn't this topic be marked FeatureDone?

-- RafaelAlvarez - 12 Nov 2004

I can specify color from a small palette, but I still don't see a convenient shorthand for sspecifying a random color from the complete 256 ccolor "Web Safe" palette (let alone the rest of the possible values).

I can say %RED% but how do I say <font color="#990033">

This functionaity could be made more... general... without requiring the user to set up a correspondence table of 256 color names.

-- VickiBrown - 18 Nov 2004

Can you suggest a syntax, Vicki?

-- MartinCleaver - 18 Nov 2004

How about %COLOR{#xxxxxx}%?

-- LynnwoodBrown - 19 Nov 2004

Lynnwood's recommendation looks very "fitting"

-- VickiBrown - 16 Dec 2004

The easiest method to both implement and understand from the users point of view: use made up constructs like <red> this is red </red> and <green> this is green </green>. All you need to make this work in any browser I know of with a modicum of css support (haven't tested NS4) is create a style sheet like this:

<style type="text/css">
red {color:red}
green {color:green}
</style>
this way you don't need variables, it's moderately easy to type, and it's very easy to read when in edit mode.

btw, this isn't my brainchild, proper credit goes to Main.ColasNahaboo on #twiki

  • named-colours.css: 124 named colours (supposed to 140?). You could stuff this in your pub directory and include it along with the rest of your stylesheets. It could use some work, particularily in choosing appropriate matching background colours. In reality I expect only the top 16 would ever get used much.

later: hmmmm, I can't get to work with IE on twiki.org. Perhaps ColasNahaboo can see what I did wrong

-- MattWilkie - 16 Dec 2004

perhaps he used it in conjunction with the PseudoXmlPlugin ?

-- WillNorris - 17 Dec 2004

Thank you Matt... but I did say I don't want to set up a correspondence table of 256 names :/

-- VickiBrown - 03 Jan 2005

you don't have to, 124 are already done (attached).:) If you really need more "on the spot" customisation than that, using <font color="#990033"> is at least as easy to type and remember as any TWikiML %CONTRUCT{#990033}% ...

But my suggestion is all moot if it doesn't work for IE anyway. : (

-- MattWilkie - 04 Jan 2005

I am sorry, it seemed I have dreamed this feature frown It only works on mozilla-based renderers frown

-- ColasNahaboo - 04 Jan 2005

Topic attachments
I Attachment History Action Size Date Who Comment
Cascading Style Sheet filecss named-colours.css r1 manage 3.3 K 2004-12-16 - 22:50 UnknownUser 124 named colours (supposed to 140?)
Edit | Attach | Watch | Print version | History: r16 < r15 < r14 < r13 < r12 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r16 - 2005-01-04 - ColasNahaboo
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.