mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-01-22 16:46:28 +01:00
Spanify un-spanned mentions
This commit is contained in:
parent
460e4a3cc4
commit
5598059715
1 changed files with 15 additions and 0 deletions
|
@ -15,6 +15,21 @@ function enhanceContent(content, opts = {}) {
|
|||
link.setAttribute('target', '_blank');
|
||||
});
|
||||
|
||||
// Spanify un-spanned mentions
|
||||
const mentionLinks = Array.from(dom.querySelectorAll('a[href].mention'));
|
||||
mentionLinks.forEach((link) => {
|
||||
if (link.querySelector('*')) {
|
||||
return;
|
||||
}
|
||||
const text = link.innerText;
|
||||
// If text looks like @username@domain, then it's a mention
|
||||
if (/^@[^@]+@[^@]+$/g.test(text)) {
|
||||
// Only show @username
|
||||
const username = text.split('@')[1];
|
||||
link.innerHTML = `@<span>${username}</span>`;
|
||||
}
|
||||
});
|
||||
|
||||
// EMOJIS
|
||||
// ======
|
||||
// Convert :shortcode: to <img />
|
||||
|
|
Loading…
Reference in a new issue