Skip to main content
Glama
test-mermaid-render.js1.25 kB
import { JSDOM } from 'jsdom'; import DOMPurify from 'dompurify'; import mermaid from 'mermaid'; // Setup like in our code const dom = new JSDOM('<!DOCTYPE html><body></body>'); const window = dom.window; global.document = window.document; global.window = window; globalThis.document = window.document; globalThis.window = window; const purify = DOMPurify(window); window.DOMPurify = purify; global.DOMPurify = purify; globalThis.DOMPurify = purify; console.log('DOMPurify setup complete'); console.log('purify.sanitize type:', typeof purify.sanitize); console.log('global.DOMPurify.sanitize type:', typeof global.DOMPurify.sanitize); // Initialize mermaid await mermaid.initialize({ theme: 'default', startOnLoad: false, securityLevel: 'loose', logLevel: 'error' }); console.log('\nAfter mermaid.initialize:'); console.log('global.DOMPurify type:', typeof global.DOMPurify); console.log('global.DOMPurify.sanitize type:', typeof global.DOMPurify?.sanitize); // Try to render try { const { svg } = await mermaid.render('test-diagram', 'graph TD\n A --> B'); console.log('\n✅ SUCCESS! SVG generated, length:', svg.length); } catch (error) { console.log('\n❌ ERROR:', error.message); console.log('Stack:', error.stack); }

Latest Blog Posts

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/Narasimhaponnada/mcp-mermiad'

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