Lemmy federates code blocks with additional <span> tags added in on each line which /kbin just treats as plaintext (it should really strip them out or treat them as tags, not plaintext).
See this comment for an example
This userscript for kbin.social tries to remove those tags and make Lemmy code blocks actually readable.
Probably doesn’t work in turbo mode, as it runs on page load and turbo mode is supposed to be a single page experience iirc.
You must log in or register to comment.
Would you like to add this to KES? You can use KES’ propagation feature to ensure it applies to comments loaded in on the fly when infinite scrolling is enabled without needing to worry about page load events.
May I also suggest something more idiomatic like the below?
const code = document.querySelectorAll('pre code'); const reg = /^\n<span>/g const reg2 = /\n<\/span><span>/g const reg3 = /<\/span>\n$/ code.forEach((block)=> { let str str = block.innerText; str = str.replaceAll(reg, ""); str = str.replaceAll(reg2, "\n"); str = str.replace(reg3, ""); block.innerText = str; }); ```</span></span>