Search code examples
highlight.js

does highlight.js check syntax as well


In addition to highlighting syntax (which I suppose means indentation, color etc.), does highlight.js check syntax as well. For eg. if I write the following code in javascript

function {
}

Would highlight.js show error that the function name is missing. I know that ace.js does this. I want to replace ace.js with highlight.js.


Solution

  • No, Highlight.js does not check syntax, it only highlights code (with pattern matching). Often incorrect syntax is simply ignored, or could cause your code to be highlighted funny.

    It MIGHT be possible to write a 3rd party grammar that did have some ability to detect (and highlight) syntax errors, but this is not something the core library is interested in doing.

    [Disclaim: I'm the current Highlight.js maintainer.]