mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-25 10:45:41 +03:00
Fix double ## and scan all links instead
This commit is contained in:
parent
8d42e33f71
commit
861a596d4e
1 changed files with 2 additions and 4 deletions
|
@ -18,9 +18,7 @@ function enhanceContent(content, opts = {}) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Spanify un-spanned mentions
|
// Spanify un-spanned mentions
|
||||||
const notMentionLinks = Array.from(
|
const notMentionLinks = Array.from(dom.querySelectorAll('a[href]'));
|
||||||
dom.querySelectorAll('a[href]:not(.mention)'),
|
|
||||||
);
|
|
||||||
notMentionLinks.forEach((link) => {
|
notMentionLinks.forEach((link) => {
|
||||||
const text = link.innerText.trim();
|
const text = link.innerText.trim();
|
||||||
const hasChildren = link.querySelector('*');
|
const hasChildren = link.querySelector('*');
|
||||||
|
@ -33,7 +31,7 @@ function enhanceContent(content, opts = {}) {
|
||||||
}
|
}
|
||||||
// If text looks like #hashtag, then it's a hashtag
|
// If text looks like #hashtag, then it's a hashtag
|
||||||
if (/^#[^#]+$/g.test(text)) {
|
if (/^#[^#]+$/g.test(text)) {
|
||||||
if (!hasChildren) link.innerHTML = `#<span>${text}</span>`;
|
if (!hasChildren) link.innerHTML = `#<span>${text.slice(1)}</span>`;
|
||||||
link.classList.add('mention', 'hashtag');
|
link.classList.add('mention', 'hashtag');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue