When inserting code in Atto editor, useless HTML tags like <p></p> or <br> are created, messing with the way highlight.js works.
One common problem were single-line comments in C# or C++, where end-of-line was only detected in hljs on a "true" line break \n, but not at the tag.
I'm using a simple javascript (textify.js) to replace the contents of the <code> tag with its text contents, effectively stripping away all HTML tags with their plaintext representation. I've also moved the regex substitution of paragraphs with line-breaks to the Javascript - this is still necessary when e.g. line-height is large enough so a paragraph stop is converted to two instead of one line-break line in the text representation.
I've also updated highlight.js itself with a more recent version.
When inserting code in Atto editor, useless HTML tags like
<p></p>
or<br>
are created, messing with the way highlight.js works. One common problem were single-line comments in C# or C++, where end-of-line was only detected in hljs on a "true" line break \n, but not at thetag. I'm using a simple javascript (textify.js) to replace the contents of the
<code>
tag with its text contents, effectively stripping away all HTML tags with their plaintext representation. I've also moved the regex substitution of paragraphs with line-breaks to the Javascript - this is still necessary when e.g. line-height is large enough so a paragraph stop is converted to two instead of one line-break line in the text representation.I've also updated highlight.js itself with a more recent version.