Skip to main content
Glama

Deepwiki MCP Server

by regenrek
htmlToMarkdown.ts1 kB
import type { ModeEnum } from '../schemas/deepwiki' import { parseHTML } from 'linkedom' import rehypeParse from 'rehype-parse' import rehypeRemark from 'rehype-remark' import rehypeSanitize from 'rehype-sanitize' import remarkGfm from 'remark-gfm' import remarkStringify from 'remark-stringify' import { unified } from 'unified' import { rehypeRewriteLinks } from '../lib/linkRewrite' import { sanitizeSchema } from '../lib/sanitizeSchema' export async function htmlToMarkdown( html: string, mode: typeof ModeEnum._type, ): Promise<string> { // Ensure a DOM is available for rehype-parse with LinkeDOM const { document } = parseHTML('<!doctype html>') globalThis.document = document const file = await unified() .use(rehypeParse, { fragment: true }) .use(rehypeSanitize, sanitizeSchema) .use(rehypeRewriteLinks, { mode }) .use(rehypeRemark) .use(remarkGfm) .use(remarkStringify, { fences: true, bullet: '-', rule: '-' }) .process(html) return String(file) }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/regenrek/deepwiki-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server