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
Incorrect code detection #334
Comments
You're concatenating all the lines without line breaks between them, it becomes completely mangled as a result. |
You're awesome!... It worked... I built http://code.nishantarora.in/langdetect.js/ over this... now I can detect code languages of multiple files I needed to profile!... Thanks! |
closing this! |
I should note that using highlight.js specifically for detecting languages might not be a good idea as our goal is to produce a useful highlighting, not detect a language. I.e., we don't consider it a bug if a snippet language is detected incorrectly but resulting highlighting looks okay. |
Makes sense, but I just needed a crude mechanism to profile thousands of source code files (withoutfile extensions or meta comments). I think I can live with a percentage of errors. Though as you say it might not detect the language correctly, as of now this is the closest thing I have... Thanks! |
Glad it worked for you :-) |
I was wondering with any possibilities to use this awesome library to detect code snippets. But I think there is some errors with even the test cases mentioned. I tried using many code snippets shown here http://highlightjs.org/static/test.html let's have a look at the ruby code. I added the following code to the highlight.pack.js:
On executing:
I was expecting the language to be ruby, but I got the output:
In case of java I get
These were cases from the test, I even tried using rather some random snippet (let's say: http://attachment.fbsbx.com/hackercup_source.php?sid=1402033520037632) I got:
I might be wrong with the usage, please correct me, or does this qualifies as a bug?
Thanks!
The text was updated successfully, but these errors were encountered: