mirror of
https://iceshrimp.dev/iceshrimp/iceshrimp
synced 2024-11-24 15:16:07 +09:00
[mastodon-client] Fix code block rendering
This doesn't work in all clients, but it works in more than the previous solution & matches what glitch-soc is doing.
This commit is contained in:
parent
efa2e501a4
commit
be28fae40f
@ -68,7 +68,15 @@ export class MfmHelpers {
|
||||
blockCode(node) {
|
||||
const pre = doc.createElement("pre");
|
||||
const inner = doc.createElement("code");
|
||||
inner.textContent = node.props.code;
|
||||
|
||||
const nodes = node.props.code
|
||||
.split(/\r\n|\r|\n/)
|
||||
.map((x) => doc.createTextNode(x));
|
||||
|
||||
for (const x of intersperse<FIXME | "br">("br", nodes)) {
|
||||
inner.appendChild(x === "br" ? doc.createElement("br") : x);
|
||||
}
|
||||
|
||||
pre.appendChild(inner);
|
||||
return pre;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user