Closed allejo closed 4 years ago
Ran some benchmarks on calling splitCodeIntoArray
200000 times on different code snippets and the differences in performance are negligible.
test_original : 35.122 sec.
test_xpath : 36.956 sec.
test_original : 35.362 sec.
test_xpath : 35.501 sec.
test_original : 54.900 sec.
test_xpath : 55.953 sec.
test_original : 24.244 sec.
test_xpath : 22.913 sec.
The
splitCodeIntoArray
function was generating broken HTML when there were deeply nested\n
characters because it wasn't closing the correct number of<span>
tags.Marking this as a draft to see what the performance impact is by using XPath.Originally,
splitCodeIntoArray
was working off the assumption that<span>
s would only nest one level deep when splitting on new lines. Notice thespan.hljs-params
element is a child tospan.hljs-function
. Because of this assumption, we were closing thehljs-params
span but not thehljs-function
span.Output from
highlight
Current
splitCodeIntoArray
output:What it should look like (fix in this PR):
See https://github.com/westonruter/syntax-highlighting-code-block/issues/193