mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-22 01:05:34 +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
|
||||
const notMentionLinks = Array.from(
|
||||
dom.querySelectorAll('a[href]:not(.mention)'),
|
||||
);
|
||||
const notMentionLinks = Array.from(dom.querySelectorAll('a[href]'));
|
||||
notMentionLinks.forEach((link) => {
|
||||
const text = link.innerText.trim();
|
||||
const hasChildren = link.querySelector('*');
|
||||
|
@ -33,7 +31,7 @@ function enhanceContent(content, opts = {}) {
|
|||
}
|
||||
// If text looks like #hashtag, then it's a hashtag
|
||||
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');
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue