Skip to content
This repository has been archived by the owner on Jul 21, 2018. It is now read-only.

Changing default background and font colors in HTML ? #11

Open
DolphinDream opened this issue Nov 9, 2017 · 3 comments
Open

Changing default background and font colors in HTML ? #11

DolphinDream opened this issue Nov 9, 2017 · 3 comments

Comments

@DolphinDream
Copy link

DolphinDream commented Nov 9, 2017

Is there a way to set the background and text colors to other values? I wanted my html pages to be created with light text on a dark background. Perhaps a good extension would be to allow the command line parameters to set these colors or even better to allow to use an external CSS file that can be passed to the app via command line argument.

@andre-simon
Copy link
Owner

You can define a path to a CSS stylesheet using -r to change the background color.

The basic ANSI color set can be adjusted with a color map file (--map option).
This text configuration overrides these color codes:

Normal: Black (0), Red (1), Green (2), Yellow (3), Blue (4), Magenta (5), 
        Cyan (6), Gray (7)
Bright: DarkGray (8), Red (9), Green (10), Yellow (11), Blue (12), Magenta (13),
        Cyan (14), White (15)

File format:

<0..15> = <HTML color code>

Example file content:

1= #0000aa
2= #00aa00
3= #00aaaa
4= #aa0000
5= #aa00aa
6= #aa5500
7= #aaaaaa
8= #555555
9= #5555ff
10= #55ff55
11= #55ffff
12= #ff5555
13= #ff55ff
14= #ffff55
15= #ffffff

@DolphinDream
Copy link
Author

It would be cool if the html parser would create CSS classes for each color instead of setting the color directly in the spans. This way you could use the CSS alone to change the colors without having to rely on the mapfile. This would also allow you to not have to regenerate the html file every time you change the colors as you can simply update the CSS and reload the html.

e.g. bright red color => brightRed class, normal blue color => normalBlue class

.brightRed { color: #ff0000; font-weight: bold; }
.normalBlue { color: #0000ff; } 

then

<span class="brightRed"> My text in red </span>

instead of

<span style="font-weight:bold;color:#ff0000;"> My text in red </span>

Or perhaps use generic class names .color0.. to .colorF, since .brightRed name can become semantically incorrect if you define it as #00ff00 (which is green) :)

@andre-simon
Copy link
Owner

That is a good point. I'll think about how to deal with 256/truecolor modes. As normally only a few color combinations would appear in a text, ansifilter could enumerate css class names while processing and output a separate CSS file at the end.

@andre-simon andre-simon reopened this Nov 29, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants