θΏ™ζ˜―indexlocζδΎ›ηš„ζœεŠ‘οΌŒδΈθ¦θΎ“ε…₯任何密码
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion frontend/src/utils/chat/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,19 @@ const markdown = markdownIt({
"</pre></div>"
);
},
}).use(markdownItKatex);
});

// Custom renderer for responsive images rendered in markdown
markdown.renderer.rules.image = function (tokens, idx) {
const token = tokens[idx];
const srcIndex = token.attrIndex("src");
const src = token.attrs[srcIndex][1];
const alt = token.content || "";

return `<div class="w-full max-w-[800px]"><img src="${src}" alt="${alt}" class="w-full h-auto" /></div>`;
};

markdown.use(markdownItKatex);

export default function renderMarkdown(text = "") {
return markdown.render(text);
Expand Down