Greasy Fork

Fix kbin Code Blocks

Dirty fix for kbin code blocks federated from Lemmy. The latter is currently federating code blocks with weird span tags added in. This is fully legal in the spec, but kbin doesn't handle this currently and thinks Lemmy should fix it despite it not being Lemmy's problem. This means that code blocks federated from Lemmy contain weird <span> tags on every single line of the code, which really should be stripped out.

目前为 2023-11-14 提交的版本。查看 最新版本

作者
Pamasich
评分
0 0 0
版本
1.0
创建于
2023-11-14
更新于
2023-11-14
大小
1.5 KB
许可证
MIT
适用于

/kbin currently has an issue with code blocks federated from Lemmy.

someCode {

}

When federating the above Lemmy code block, Lemmy adds additional <span style="color=#323232"> tags and corresponding closing tags on each line for some reason. That's technically legal in HTML, but /kbin doesn't handle it correctly currently and just displays them in plaintext.

As such, the above code block displays on kbin like this:

<span style="color=#323232">someCode {
</span><span style="color=#323232">
</span><span style="color=#323232">}
</span>

This userscript strips out those extra tags, trying to reproduce the first code block instead.