Skip to content
Snippets Groups Projects
Unverified Commit fd167732 authored by Sean Hatfield's avatar Sean Hatfield Committed by GitHub
Browse files

Fix markdown styling for rendered images (#2125)

fix md styling for rendered images
parent 99f2c25b
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment