Closed damianavila closed 11 years ago
I forgot to mention: with this implementation, we are potencialy able to guess ans highlight the following languages:
And the last one... if you test short snippets of code, because the wide available detection spectrum, you will probably not get the proper coloring, but if you paste or write more code, enough to kill the ambiguities, then you will get the right highlight ;-)
I liked this a lot. We stil need the combobox, specially to see which coloring was autoselected, but this is a very good start. Thanks!!
I will try to get the combobox soon... this week I have almost no time but I will try to do it this weekend. Thanks for merging!
Damián.
I decided to go with other kind of implementation to solve the problem of highlighting code in a automatic and intelligent way... I closed the PR (https://github.com/facundobatista/kilink/pull/9) of the previous implementation in favor of this one...
I this case I use the highlight.js library as a sort of sensor or detector to guess the language we are writing in the codemirror area. Then I pass this information to the codemirror library to set the mode according to the language detected. So, we use the best of the both worlds, detection by highligth.js and coloring by codemirror. If you look at the code... is very simple to understand: essentially I feed the
highlightAuto
function with the strings gotten from the editor to return an object containing the info about the predicted language, then I passed this language to the editor mode and voila... all is working ;-)Please test it and let me know how do you feel... I think is a better implementation than the other closed PR.
Abrazo. Damián.