automatic programmins language identification by highlight.js

39 views
Skip to first unread message

Shaul Zevin

unread,
Aug 20, 2016, 12:09:42 PM8/20/16
to highlight.js
Would it be fair to say that highlight.js uses the success-rate of highlighting process to identify the language?

Any insights would be greatly appreciated.

Ivan Sagalaev

unread,
Aug 20, 2016, 10:47:42 PM8/20/16
to highl...@googlegroups.com
Yes, this is pretty much how it works. Nicely summed up :-)

"Pretty much" stands for additional tweaks. Some language construct have
more weight, if they're rare among different languages. Some have no
weight (like common numbers). And there are also things defined as
illegal that cause the parser to drop the highlighting attempt for a
given language (if you happen upon `</` outside of strings or comments,
this is definitely not, say, C++).
Reply all
Reply to author
Forward
0 new messages