Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change font color in Scribble (html backend)

Is there any way to change the font color in scribble with an HTML backend?

(More specifically, I want to put a large red WARNING label in the manual for a library.)

like image 985
Leif Andersen Avatar asked Oct 18 '25 15:10

Leif Andersen


2 Answers

It turns out you can do this directly in scribble without using a backend dependent solution. The trick is to use styles that have color-property.

Using elem to set the style, as shown here, you can create a colorize function, that sets the color of your text.

(define (colorize #:color c . content)
  (elem #:style (style #f (list (color-property c)))
        content))

And then you could use it like this:

@colorize[#:color "red"]{WARNING}

There is also background-color-property you can sue to set the background of the text.

like image 183
Leif Andersen Avatar answered Oct 22 '25 04:10

Leif Andersen


As Alexis mentioned, you can use a class paired with a Cascading Style Sheet (CSS) like so:

<head>
   <link rel="stylesheet" type="text/css" href="mystyle.css">
   <!-- that's to link our styles to the webpage. -->
</head>
<body>
   <!-- some time later... -->
   <p class = "example">test</p> 
   <!-- the rest of the website -->

And in mystyle.css:

.example{ /* select all tags with the "example" class */
     color: #FF0000; /* change font color using hex value */
     background-color: #552222; /* change background color using hex value */
}

Now, this would be great if we were able to use multiple files. But, if you want to have it all in one file, we can send that same information in a <style> tag:

<head>
   <!-- no need to link our styles, since they're embedded in the webpage. -->
</head>
<body>
   <style>
     .example{ /* select all tags with the "example" class */
        color: #FF0000; /* change font color using hex value */
        background-color: #552222; /* change background color using hex value */
     }
   </style>
   <!-- some time later... -->
   <p class = "example">test</p> 
   <!-- the rest of the website -->

There's another way to embed it, but you shouldn't use it. Ever. This is always the correct way.

See http://www.w3schools.com/css/css_examples.asp if you need anything more from the CSS side of things.

like image 22
Steven Hewitt Avatar answered Oct 22 '25 06:10

Steven Hewitt