From 4f2a9f89112c515741d8c42c5962957591c1357e Mon Sep 17 00:00:00 2001 From: Johann150 Date: Thu, 25 Aug 2022 00:04:27 +0200 Subject: [PATCH] refactor: adjust HTML mention microformat Adjust the federated HTML microformat to the one that is documented at , namely adding the missing surrounding tag with the class `h-card`. --- packages/backend/src/mfm/to-html.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/mfm/to-html.ts b/packages/backend/src/mfm/to-html.ts index a16181d40..b1429f184 100644 --- a/packages/backend/src/mfm/to-html.ts +++ b/packages/backend/src/mfm/to-html.ts @@ -106,13 +106,18 @@ export function toHtml(nodes: mfm.MfmNode[] | null, mentionedRemoteUsers: IMenti }, mention(node) { + // Mastodon microformat: span.h-card > a.u-url.mention const a = doc.createElement('a'); const { username, host, acct } = node.props; const remoteUserInfo = mentionedRemoteUsers.find(remoteUser => remoteUser.username === username && remoteUser.host === host); a.href = remoteUserInfo?.url ?? remoteUserInfo?.uri ?? `${config.url}/${acct}`; a.className = 'u-url mention'; a.textContent = acct; - return a; + + const card = doc.createElement('span'); + card.className = 'h-card'; + card.appendChild(a); + return card; }, quote(node) {