import Parser from '@jocmp/mercury-parser'; import type { CheerioAPI } from 'cheerio'; import { load } from 'cheerio'; import type { Element } from 'domhandler'; import * as entities from 'entities'; import type { MiddlewareHandler } from 'hono'; import { convert } from 'html-to-text'; import markdownit from 'markdown-it'; import { RE2JS } from 're2js'; import sanitizeHtml from 'sanitize-html'; import { simplecc } from 'simplecc-wasm'; import { config } from '@/config'; import type { Data, DataItem } from '@/types'; import cache from '@/utils/cache'; import ofetch from '@/utils/ofetch'; const md = markdownit({ html: true, }); const resolveRelativeLink = ($: CheerioAPI, elem: Element, attr: string, baseUrl?: string) => { const $elem = $(elem); if (baseUrl) { try { const oldAttr = $elem.attr(attr); if (oldAttr) { // e.g. should leave