Skip to content

Conversation

HugoNikanor
Copy link
Contributor

This colors all CSS color codes found alone in inline code blocks to the color they mention.
So #00cc00 Would show up as green, but _#00cc00 would show up as normal (probably gray).

Two commits are included, one simply changes the background color, while the other also calculates the inverse of the color and sets that as the text color.

I have set up a demo at http://wiki.hornquist.se/Colors.html.

@hq6
Copy link
Contributor

hq6 commented Mar 15, 2019

@Nudin @ranebrown , Since this is new feature which has not yet received the attention of other maintainers, I'd like to get your thoughts on whether to merge it.

@ranebrown
Copy link
Contributor

My initial thought is why not use something like colorizer that also works for files outside of vimwiki?

@hq6
Copy link
Contributor

hq6 commented Mar 15, 2019

@ranebrown , I think this PR is not about syntax highlighting inside Vim. It's about the generated HTML from Vimwiki2HTML, which does not overlap with colorizer, as far as I can tell.

@ranebrown
Copy link
Contributor

Ah, that makes more sense. I haven't had a chance to test it myself but the changes seem pretty minimal. I'll give it a try this weekend but if there aren't any issues I think we should merge it.

@hq6 hq6 assigned hq6 and unassigned hq6 Mar 15, 2019
@HugoNikanor
Copy link
Contributor Author

@ranebrown It's pretty much that plugin, but for the HTML output.

P.S. Thanks for showing me that plugin, I was looking for one!

@Nudin
Copy link
Member

Nudin commented Mar 16, 2019

I like the feature and the code looks good. Was first a bit hesitated if that might cause a regression for someone since not all hex-codes might be colors. But I'm not sure how big the chance is that someone uses them after a # in a inline code block without anything else. Instead of using the inverse color for the text we might want to use black or white depending on the luminosity of the color. See here. We might also want to document this feature with a short sentence in the help-page.

@ranebrown
Copy link
Contributor

I gave this a spin and it seems to work as advertised. I agree that it needs a better scheme for determining the font color. A few colors that the font is difficult to see are #808000 and #808080 and #ffe119. I'm sure there are plenty of other examples as well.

@HugoNikanor can you update this to use something like @Nudin suggested for determining the font color and add a short note in the documentation? Thanks!

@HugoNikanor
Copy link
Contributor Author

Fixed foreground colors and added documentation, and also updated the preview at http://wiki.hornquist.se/Colors.html.

(I also see that GitHub has added the same functionality...)

@hq6 hq6 merged commit da52523 into vimwiki:dev Mar 18, 2019
hq6 added a commit that referenced this pull request Mar 18, 2019
This colors all CSS color codes found alone in inline code blocks to the
color they mention.
@HugoNikanor HugoNikanor deleted the colorcodes branch March 18, 2019 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants