feat: add sqlite catalog web app
This commit is contained in:
@@ -32,6 +32,10 @@ function sponsorMarkerText(value: string): string | undefined {
|
||||
}
|
||||
|
||||
function blockTokens($: cheerio.CheerioAPI, node: any): Token[] {
|
||||
if (!node) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (node.type === 'text') {
|
||||
const text = compactText(node.data ?? '');
|
||||
return text ? [{ type: 'text', text }] : [];
|
||||
@@ -49,6 +53,10 @@ function blockTokens($: cheerio.CheerioAPI, node: any): Token[] {
|
||||
|
||||
function localContext($: cheerio.CheerioAPI, element: any, title: string): string {
|
||||
const block = $(element).closest('p,li,td,div').first();
|
||||
if (block.length === 0) {
|
||||
return title;
|
||||
}
|
||||
|
||||
const tokens = blockTokens($, block.get(0));
|
||||
const anchorIndex = tokens.findIndex(
|
||||
(token) => token.type === 'anchor' && token.element === element
|
||||
|
||||
Reference in New Issue
Block a user