render images (changer taille)

This commit is contained in:
C. Fuhrman 2025-01-26 16:31:47 -05:00
parent 7fed2bb135
commit 4232afc57c
2 changed files with 17 additions and 1 deletions

View file

@ -1,4 +1,6 @@
import { marked } from 'marked';
// import { marked } from 'marked';
import marked from 'src/markedConfig';
import katex from 'katex';
import { TextFormat } from 'gift-pegjs';
import DOMPurify from 'dompurify'; // cleans HTML to prevent XSS attacks, etc.

View file

@ -0,0 +1,14 @@
import { marked, Renderer } from 'marked';
const renderer = new Renderer();
renderer.image = ({href, title, text}) => {
const [width, height] = title?.startsWith('=') ? title.slice(1).split('x').map(v => v.trim()).filter(Boolean) : [];
return `<img src="${href}" alt="${text}"${width ? ` width="${width}"` : ''}${height ? ` height="${height}"` : ''}>`;
}
marked.use({
renderer: renderer
});
export default marked;