Ivan Sagalaev
unread,Sep 8, 2014, 7:06:22 PM9/8/14Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to highl...@googlegroups.com
Hello Marcelo,
Technically, you can do this: the result of hljs.highlightAuto()
provides the detected language. But it may not be a good idea. The point
of a highlighter is not to detect a language reliably but rather to
provide a good looking highlighting. In a snippet:
return 5;
… we don't care if it's ended up being highlighted with cpp, java,
python or whatever, we care that "return" is marked up as keyword. And
apart from being inherently unreliable on short code snippets our
heuristics is, frankly, not as well debugged as it may (and should) be.