         });
                    pdf.addImage(imgData, 'JPEG', 0, 0, canvas.width, canvas.height);
                    pdf.save('mindmap.pdf');
                };
                img.src = 'data:image/svg+xml;base64,' + svgBase64;
            } else if (format === 'markdown') {
                const viewer = document.getElementById('mindmap-viewer');
                const currentMindmap = JSON.parse(viewer.dataset.currentMindmap || '{}');
                if (currentMindmap.markdown) {
                    co