Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get color from "parent language" if there is no definition for the language itself #252

Closed
alexanderadam opened this issue Feb 27, 2020 · 6 comments · Fixed by go-enry/go-enry#2

Comments

@alexanderadam
Copy link

alexanderadam commented Feb 27, 2020

I opened this issue because of a corresponding issue in gitea.

Gitea uses enry for the language bar and some colors can't be fetched.

IMHO Linguist uses groups for this and properties are inherited from the parent group. For example Haml inherits from HTML.

So I guess it would help if the color mapping would work similar.

PS: Just some examples to point out what it looks like in gitea:

Screenshot_20200226_140920

Screenshot_20200226_141331

@lunny
Copy link

lunny commented Mar 17, 2020

Maybe @mcuadros would like also to move this project to go-git organization?

@bzz
Copy link
Contributor

bzz commented Mar 18, 2020

That would be a simple change to the

enry/utils.go

Line 78 in 697929e

func GetColor(language string) string {
if group information would have been stored somewhere in the data generated from .yml

A naive approach to implement that is to add a new internal/code-generator asset that would output a map Language -> Group so the new GetColor impl would do a lookup in there.

Originally, enry did not have a use case for colors, so implementation of the GetColor was done by @lafriks under #233.

@lafriks
Copy link
Contributor

lafriks commented Mar 18, 2020

when enry is hard forked to go-enry organization I could probably implement this

@bzz
Copy link
Contributor

bzz commented Mar 19, 2020

JFYI I'm not related to the plans of forking enry to a go-enry org.

Meanwhile I have just pushed a https://pkg.go.dev/github.com/bzz/enry/v2 and will be happy to assist adding this feature, if needed.

@bzz
Copy link
Contributor

bzz commented Mar 31, 2020

This has been implemented by @lafriks and is included in latest https://github.com/go-enry/go-enry/releases/tag/v2.3.0

@alexanderadam
Copy link
Author

Awesome, thank you folks!

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 a pull request may close this issue.

4 participants