From c982b3e90f709545405b12e986075fdc33396a49 Mon Sep 17 00:00:00 2001 From: Amit Haridas Date: Mon, 25 May 2026 00:32:27 +0530 Subject: [PATCH] chore(diagnostics): add logging to _renderPreview to trace markdown rendering This will help identify whether the issue is: 1. marked.parse returning a Promise instead of string 2. DOMPurify.sanitize failing 3. The preview element not existing 4. Libraries not being loaded Amit Haridas --- src/renderer.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/renderer.js b/src/renderer.js index 3e3b989..4515353 100644 --- a/src/renderer.js +++ b/src/renderer.js @@ -682,17 +682,26 @@ class TabManager { _renderPreview(tabId) { const tab = this.tabs.get(tabId); const preview = document.getElementById(`preview-${tabId}`); + console.log('[_renderPreview] tabId:', tabId, 'tab exists:', !!tab, 'preview exists:', !!preview, 'content length:', tab?.content?.length); if (!tab || !preview) return; try { // Check if libraries are available if (!marked || !DOMPurify) { + console.error('[_renderPreview] Libraries not available:', { marked: !!marked, DOMPurify: !!DOMPurify }); preview.innerHTML = '
⚠️
Libraries Not Loaded
Required libraries (marked/DOMPurify) could not be loaded. Please check your installation.
'; return; } + console.log('[_renderPreview] About to call marked.parse, content length:', tab.content.length); const html = marked.parse(tab.content); + console.log('[_renderPreview] marked.parse returned type:', typeof html, 'isPromise:', html instanceof Promise); + if (html instanceof Promise) { + console.error('[_renderPreview] marked.parse returned a Promise! Need to await it.'); + return; + } let sanitizedHtml = DOMPurify.sanitize(html); + console.log('[_renderPreview] DOMPurify.sanitize returned, length:', sanitizedHtml.length); // TOC generation if (sanitizedHtml.includes('[[toc]]') || sanitizedHtml.includes('[TOC]')) {