mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-22 01:05:34 +03:00
Run prettier
This commit is contained in:
parent
321b60649f
commit
1a71917986
1 changed files with 19 additions and 25 deletions
|
@ -46,38 +46,32 @@ function _countEntities(p) {
|
||||||
// End if there's text
|
// End if there's text
|
||||||
throw false;
|
throw false;
|
||||||
}
|
}
|
||||||
}
|
} else if (node.tagName === 'BR') {
|
||||||
else if(node.tagName === 'BR') {
|
|
||||||
// Ignore <br />
|
// Ignore <br />
|
||||||
}
|
} else if (node.tagName === 'A') {
|
||||||
else if(node.tagName === 'A') {
|
|
||||||
// Check if the link has text
|
// Check if the link has text
|
||||||
const linkText = node.textContent.trim();
|
const linkText = node.textContent.trim();
|
||||||
|
|
||||||
if (!linkText) {
|
if (!linkText) {
|
||||||
// End if there's a link without text
|
// End if there's a link without text
|
||||||
throw false;
|
throw false;
|
||||||
}
|
} else if (!(linkText.startsWith('#') || linkText.startsWith('@'))) {
|
||||||
else if(!(
|
|
||||||
linkText.startsWith('#') || linkText.startsWith('@')
|
|
||||||
)) {
|
|
||||||
// End if there's a link that's not a mention or an hashtag
|
// End if there's a link that's not a mention or an hashtag
|
||||||
throw false;
|
throw false;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// This is an entity
|
// This is an entity
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
} else if (node.tagName === 'SPAN') {
|
} else if (node.tagName === 'SPAN') {
|
||||||
// If this is a span, we might need to go deeper
|
// If this is a span, we might need to go deeper
|
||||||
count += _countEntities(node)
|
count += _countEntities(node);
|
||||||
} else {
|
} else {
|
||||||
// There's something else here we should not touch
|
// There's something else here we should not touch
|
||||||
throw false;
|
throw false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return count
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _enhanceContent(content, opts = {}) {
|
function _enhanceContent(content, opts = {}) {
|
||||||
|
@ -277,10 +271,10 @@ function _enhanceContent(content, opts = {}) {
|
||||||
let entitiesCount = 0;
|
let entitiesCount = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
entitiesCount = _countEntities(p)
|
entitiesCount = _countEntities(p);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e === false) {
|
if (e === false) {
|
||||||
return false
|
return false;
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue