chrisbra / Colorizer

color hex codes and color names
547 stars 30 forks source link

highlight TOhtml output? #14

Closed teschmitz closed 11 years ago

teschmitz commented 11 years ago

Would it be possible to highlight colours when outputting to HTML with TOhtml?

chrisbra commented 11 years ago

Hi teschmitz!

On Mo, 03 Dez 2012, teschmitz wrote:

Would it be possible to highlight colours when outputting to HTML with TOhtml?

Interesting request. Try current head and use :ColorHighlight persist or set the variable g:colorizer_persist = 1

That seems to work for the simple test case, but for some reason chromium doesn't color all colors correctly, also the resulting html file looks good.

regards,

Christian

Weit ist der Weg vom Ohr zum Herzen, aber noch weiter ist der Weg zu den helfenden Händen. -- Josephine Baker

teschmitz commented 11 years ago

Ingenious!

But one wee bug fix is needed: you create class with names derived from the hex colour code. This fails for those colour codes which start with a decimal number:

A class name must begin with an underscore (_), a dash (-), or a letter(a–z), see http://stackoverflow.com/questions/448981/what-characters-are-valid-in-css-class-names

Maybe you want to prefix hex code class names with an "x"?

chrisbra commented 11 years ago

On Tue, December 4, 2012 00:38, teschmitz wrote:

Ingenious!

But one wee bug fix is needed: you create class with names derived from the hex colour code. This fails for those colour codes which start with a decimal number:

A class name must begin with an underscore (_), a dash (-), or a letter(a–z), see http://stackoverflow.com/questions/448981/what-characters-are-valid-in-css-class-names

Maybe you want to prefix hex code class names with an "x"?

Ah, that is the reason Chromium didn't color all groups.

I have fixed it and call the groups "Color_XXXXXX" where X is the HexCode.

regards, Christian

teschmitz commented 11 years ago

I have downloaded the zip file but this seems to be an old version pre-dating #14. I have no highlighting for TOhtml at all.

chrisbra commented 11 years ago

Hi teschmitz!

On Do, 06 Dez 2012, teschmitz wrote:

I have downloaded the zip file but this seems to be an old version pre-dating #14. I have no highlighting for TOhtml at all.

Hm, strange. I added the vimball plugin. Try downloading it. Installation is easy, simply open the Colorizer.vmb in Vim and source it :so % That will make Vim install it and place all files into the right directories. After a restart, syntax highlighting should work correctly.

Just in case it does not for your, a couple of things to check:

You did use :ColorHightlight syntax, right? Check, that echo getmatches() after coloring does not return anything (except user defined matches from other plugins or so). But :syn should output a whole bunch of

Color_d13632 xxx match /#d13632\c/ display excludenl containedin=ALL

which gets in turn be set to a css class by TOhtml like this:

.Color_d13632 { color: #ffffff; background-color: #d75f5f; }

regards,

Christian

Eine Frau ist wie ein Schatten: Folge ihr und sie flieht vor Dir. Fliehe vor ihr und sie folgt Dir. -- Nicolas Sébastien de Chamfort

teschmitz commented 11 years ago

I download via the ZIP button at the top left. master.zip contains autoload/Colorizer.vim, which is dated 6th Dec 12:15 but I can't tell what version this is. When I search for "persist", I get no search result. I don't think #14 is covered by this download.

chrisbra commented 11 years ago

On Fri, December 7, 2012 00:20, teschmitz wrote:

I download via the ZIP button at the top left. master.zip contains autoload/Colorizer.vim, which is dated 6th Dec 12:15 but I can't tell what version this is. When I search for "persist", I get no search result. I don't think #14 is covered by this download.

Sorry, I have renamed that variable to g:colorizer_syntax which makes more sense to me.

regards, Christian

teschmitz commented 11 years ago

On Fri, 07 Dec 2012 00:55:08 -0800 chrisbra notifications@github.com wrote:

I have renamed that variable to g:colorizer_syntax

I have added the following to .vimrc: let g:colorizer_syntax=1

This has no effect on :TOhtml.

If I activate syntax highlighting via :ColorHighlight syntax

the HTML code is generated with colour highlighting.

teschmitz http://my.mutterings.co.uk/

teschmitz commented 11 years ago

On Fri, 07 Dec 2012 00:55:08 -0800 chrisbra notifications@github.com wrote:

:ColorHighlight syntax

Does this have any adverse effects? Is there any good reason to use the default setting :ColorHighlight match ?

teschmitz http://my.mutterings.co.uk/

teschmitz commented 11 years ago

:ColorHighlight syntax

In syntax mode, the no syntax highlighting is displayed for the current line.

teschmitz http://my.mutterings.co.uk/

chrisbra commented 11 years ago

Hi teschmitz!

On Fr, 07 Dez 2012, teschmitz wrote:

On Fri, 07 Dec 2012 00:55:08 -0800 chrisbra notifications@github.com wrote:

:ColorHighlight syntax

Does this have any adverse effects? Is there any good reason to use the default setting :ColorHighlight match ?

Well, theoretically, there could be a syntax file, that declares e.g. black or white as syntax keywords and in this case, the highlighting would not work, as syntax keywords always have a higher precedence than syntax matches. Also I tend to think of the coloring as a special function, that is independent of the syntax highlighting and so should stay separate. And last, as script writer, using the matching() family of functions is a lot easier than to use syntax highlighting.

Other then that, you as user can of course use whatever you like.

regards, Christian

chrisbra commented 11 years ago

Hi teschmitz!

On Fr, 07 Dez 2012, teschmitz wrote:

On Fri, 07 Dec 2012 00:55:08 -0800 chrisbra notifications@github.com wrote:

I have renamed that variable to g:colorizer_syntax

I have added the following to .vimrc: let g:colorizer_syntax=1

This has no effect on :TOhtml.

If I activate syntax highlighting via :ColorHighlight syntax

the HTML code is generated with colour highlighting.

I see the problem and just pushed a fix.

regards,

Christian

Wie fängt man ein Kaninchen? Man setzt sich ins Gebüsch und macht das Geräusch einer wachsenden Möhre nach!

chrisbra commented 11 years ago

Hi teschmitz!

On Fr, 07 Dez 2012, teschmitz wrote:

:ColorHighlight syntax

In syntax mode, the no syntax highlighting is displayed for the current line.

I don't understand this problem.

regards,

Christian

Was nützt ein Gott, wenn er sich nicht herumspricht. -- Berthold Brecht

teschmitz commented 11 years ago

On Sun, 09 Dec 2012 05:45:51 -0800 chrisbra notifications@github.com wrote:

:ColorHighlight syntax

In syntax mode, no syntax highlighting is displayed for the current line.

I don't understand this problem.

My default setting is colourized background.

When I run :ColorHighlight syntax, the [background] ColourHighlight disappears on the cursorline.

The background colour also disppears when the highlight colour is applied to the foreground. Obviously, this problem does not affect the 3rd :ColorSwapFgBg setting where the background isn't colorized.

If you run :ColorHighlight syntax first, then :ColorSwapFgBg, the background colourization remains intact on the cursorline.

chrisbra commented 11 years ago

On Sun, December 9, 2012 21:23, teschmitz wrote:

On Sun, 09 Dec 2012 05:45:51 -0800 chrisbra notifications@github.com wrote:

:ColorHighlight syntax

In syntax mode, no syntax highlighting is displayed for the current line.

I don't understand this problem.

My default setting is colourized background.

When I run :ColorHighlight syntax, the [background] ColourHighlight disappears on the cursorline.

The background colour also disppears when the highlight colour is applied to the foreground. Obviously, this problem does not affect the 3rd :ColorSwapFgBg setting where the background isn't colorized.

If you run :ColorHighlight syntax first, then :ColorSwapFgBg, the background colourization remains intact on the cursorline.

I think this is expected (also for me the cursorline highlighting always overrules the background highlighting) and this is another drawback of using the syntax highlighting instead of matching highlighting.

I don't think, I can offer you anything here. This is just the way syntax highlighting works with vim.

regards, Christian

teschmitz commented 11 years ago

On Mon, 10 Dec 2012 23:05:50 -0800 chrisbra notifications@github.com wrote:

On Sun, December 9, 2012 21:23, teschmitz wrote:

On Sun, 09 Dec 2012 05:45:51 -0800 chrisbra notifications@github.com wrote:

:ColorHighlight syntax

In syntax mode, no syntax highlighting is displayed for the current line.

I don't think, I can offer you anything here. This is just the way syntax highlighting works with vim.

It's not a problem at all.