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

Support detecting a language from content only #2

Open
CodeMyst opened this issue May 26, 2020 · 5 comments
Open

Support detecting a language from content only #2

CodeMyst opened this issue May 26, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@CodeMyst
Copy link

Looks like the CLI version doesn't support detecting a language from just content, but the main repo does.

@bzz
Copy link
Member

bzz commented May 29, 2020

Thank you for the suggestion!

Do you have an example in mind, how do you think this should work with the CLI interface?

@CodeMyst
Copy link
Author

Providing a simple CLI option and providing the code through either a file or stdin (or allowing both).

@bzz bzz added the enhancement New feature or request label Jun 15, 2020
@pvonmoradi
Copy link

pvonmoradi commented Jan 17, 2021

Yes it seems it doesn't support https://github.com/go-enry/go-enry/#by-text . Actually I guess currently only guessing by extension is supported by the tool.
There is a -mode option but it seems doesn't change the outcome.
To test, copy a C file and change its extension to py or go. enry detects py and go respectively. Even when the file has no extension, none of the -mode options report anything other than text

jeremy-jameson added a commit to jeremy-jameson/BlogML2Hugo that referenced this issue Mar 21, 2021
Note that the CLI version of enry (https://github.com/go-enry/enry) does not currently support determining the language of a file based on the file content only (go-enry/enry#2).

Therefore I used a private build of the enry CLI (jeremy-jameson/enry@b7a5521).

To get my "preferred" language names (e.g. "C#" instead of "csharp"), I added a "mapping" class to ReverseMarkdown (jeremy-jameson/reversemarkdown-net@09ee8e3).
@gregnis
Copy link

gregnis commented Dec 9, 2022

I was looking at your change at jeremy-jameson@b7a5521 since I also need to detect by text. I ended up testing your build on Windows, and it's almost working for my purposes. However, I need to add a few more languages to your list, and I'm struggling to understand how to build it. Any pointers would be much appreciated.

@bzz
Copy link
Member

bzz commented Dec 22, 2022

I'm struggling to understand how to build it.

Usually, running go build . from the checkout is enough. And, indeed, creating a custom binary that supports your use case is the simplest way to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

4 participants