[mastodon-client] Omit paragraph tags for user profile fields

This commit is contained in:
Laura Hausmann 2023-10-12 16:29:48 +02:00
parent 8c93f7eb68
commit 9167ba593c
Signed by: zotan
GPG key ID: D044E84C5BE01605
2 changed files with 4 additions and 3 deletions

View file

@ -110,7 +110,7 @@ export class UserConverter {
private static encodeField(f: Field): MastodonEntity.Field {
return {
name: f.name,
value: MfmHelpers.toHtml(mfm.parse(f.value)) ?? escapeMFM(f.value),
value: MfmHelpers.toHtml(mfm.parse(f.value), undefined, true) ?? escapeMFM(f.value),
verified_at: f.verified ? (new Date()).toISOString() : null,
}
}

View file

@ -7,7 +7,8 @@ import mfm from "mfm-js";
export class MfmHelpers {
public static toHtml(
nodes: mfm.MfmNode[] | null,
mentionedRemoteUsers: IMentionedRemoteUsers = []
mentionedRemoteUsers: IMentionedRemoteUsers = [],
inline: boolean = false
) {
if (nodes == null) {
return null;
@ -203,6 +204,6 @@ export class MfmHelpers {
appendChildren(nodes, doc.body);
return `<p>${doc.body.innerHTML}</p>`;
return inline ? doc.body.innerHTML : `<p>${doc.body.innerHTML}</p>`;
}
}