Does it also work when the syntax is outside of the diff context? I.e. think a html comment that started in an a prior insertion hunk? We had encountered a lot of edge cases whilst building the syntax highlighted diffs for https://www.tixef.com It is a tricky domain, hats of to you for attempting it in JavaScript!