mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-22 08:53:48 +01: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) {
|
blockCode(node) {
|
||||||
const pre = doc.createElement("pre");
|
const pre = doc.createElement("pre");
|
||||||
const inner = doc.createElement("code");
|
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);
|
pre.appendChild(inner);
|
||||||
return pre;
|
return pre;
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user