mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-25 03:17:38 -07: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
1 changed files with 9 additions and 1 deletions
|
@ -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 a new issue