refactor: adjust HTML mention microformat
Some checks failed
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-client Pipeline failed
ci/woodpecker/push/test Pipeline failed

Adjust the federated HTML microformat to the one that is documented
at <https://docs.joinmastodon.org/spec/microformats/>, namely adding
the missing surrounding tag with the class `h-card`.
This commit is contained in:
Johann150 2022-08-25 00:04:27 +02:00
parent f119914b98
commit 4f2a9f8911
Signed by: Johann150
GPG key ID: 9EE6577A2A06F8F1

View file

@ -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) {