Spaces:
Running
Running
Improve frontend image and Mermaid rendering
Browse filesFiles changed (3)
216 unmodified lines217218219220221222223216 unmodified linesraise HTTPException(status_code=403, detail="workspace file path is outside the workspace") from excif not resolved.is_file():raise HTTPException(status_code=404, detail="workspace file does not exist")if resolved.suffix.lower() not in {".png", ".jpg", ".jpeg", ".gif", ".webp", ".bmp"}:raise HTTPException(status_code=415, detail="only workspace image files can be displayed inline")return resolved216 unmodified lines217218219220221222223216 unmodified linesraise HTTPException(status_code=403, detail="workspace file path is outside the workspace") from excif not resolved.is_file():raise HTTPException(status_code=404, detail="workspace file does not exist")if resolved.suffix.lower() not in {".png", ".jpg", ".jpeg", ".gif", ".webp", ".bmp", ".svg"}:raise HTTPException(status_code=415, detail="only workspace image files can be displayed inline")return resolved
466 unmodified lines4674684694704714724 unmodified lines47747847948048148240 unmodified lines52352452552652752875 unmodified lines604605606607608609610611612613614615616466 unmodified lines}.message-body {padding: 14px 16px;}4 unmodified lines}.event-body-inner {padding: 14px 16px;}40 unmodified lines}.markdown-body {line-height: 1.6;word-break: break-word;}75 unmodified lines.markdown-body img {display: block;max-width: 100%;height: auto;margin: 0.65rem 0;border-radius: 14px;}.mermaid-chart {margin: 0.85rem 0;overflow-x: auto;}466 unmodified lines4674684694704714724734744 unmodified lines47948048148248348448548640 unmodified lines52752852953053153253353453575 unmodified lines611612613614615616617618619620621622623624625626466 unmodified lines}.message-body {min-width: 0;max-width: 100%;padding: 14px 16px;}4 unmodified lines}.event-body-inner {min-width: 0;max-width: 100%;padding: 14px 16px;}40 unmodified lines}.markdown-body {min-width: 0;max-width: 100%;overflow-wrap: anywhere;line-height: 1.6;word-break: break-word;}75 unmodified lines.markdown-body img {display: block;width: auto;max-width: 100%;height: auto;margin: 0.65rem 0;border-radius: 14px;object-fit: contain;}.mermaid-chart {max-width: 100%;margin: 0.85rem 0;overflow-x: auto;}
197 unmodified lines19819920020120220327 unmodified lines23123223323423523623715 unmodified lines253254255256257258259197 unmodified linesreturn template.innerHTML;}function unwrapFullMarkdownFence(text) {var source = String(text || "").trim();var match = /^(```|~~~)[ \t]*(markdown|md|gfm)[^\n]*\n([\s\S]*?)\n\1[ \t]*$/i.exec(source);27 unmodified linesconsole.warn("Mermaid initialization failed.", e);return;}container.querySelectorAll(".markdown-body pre code.language-mermaid").forEach(function (code) {var pre = code.closest("pre");if (!pre) return;var source = code.textContent || "";15 unmodified linesreturn "<pre>" + escapeHtml(text) + "</pre>";}try {var protectedMath = protectMathSegments(unwrapFullMarkdownFence(text));var rawHtml = window.marked.parse(protectedMath.text, { gfm: true, breaks: false, async: false });rawHtml = rewriteWorkspaceImageSources(rawHtml);var safeHtml = window.DOMPurify.sanitize(rawHtml, { USE_PROFILES: { html: true } });197 unmodified lines19819920020120220320420520620720820921021121227 unmodified lines24024124224324424524624724824925015 unmodified lines266267268269270271272273197 unmodified linesreturn template.innerHTML;}function normalizeMarkdownImageDestinations(text) {return String(text || "").replace(/!\[([^\]\n]*)\]\(([^)\n]+)\)/g, function (match, alt, target) {var src = String(target || "").trim();if (!src || src[0] === "<" || !/\s/.test(src) || isRemoteOrInlineImageSrc(src)) return match;if (/[<>]/.test(src)) return match;return "";});}function unwrapFullMarkdownFence(text) {var source = String(text || "").trim();var match = /^(```|~~~)[ \t]*(markdown|md|gfm)[^\n]*\n([\s\S]*?)\n\1[ \t]*$/i.exec(source);27 unmodified linesconsole.warn("Mermaid initialization failed.", e);return;}container.querySelectorAll(".markdown-body pre code").forEach(function (code) {var className = String(code.className || "").toLowerCase();if (!className.split(/\s+/).some(function (name) {return name === "language-mermaid" || name === "lang-mermaid" || name === "language-mmd" || name === "lang-mmd";})) return;var pre = code.closest("pre");if (!pre) return;var source = code.textContent || "";15 unmodified linesreturn "<pre>" + escapeHtml(text) + "</pre>";}try {var normalizedText = normalizeMarkdownImageDestinations(unwrapFullMarkdownFence(text));var protectedMath = protectMathSegments(normalizedText);var rawHtml = window.marked.parse(protectedMath.text, { gfm: true, breaks: false, async: false });rawHtml = rewriteWorkspaceImageSources(rawHtml);var safeHtml = window.DOMPurify.sanitize(rawHtml, { USE_PROFILES: { html: true } });
frontend/local_server.py+1-1
frontend/static/app.css+10
frontend/static/app.js+16-2