mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
render images (changer taille)
This commit is contained in:
parent
7fed2bb135
commit
4232afc57c
2 changed files with 17 additions and 1 deletions
|
|
@ -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.
|
||||
|
|
|
|||
14
client/src/markedConfig.ts
Normal file
14
client/src/markedConfig.ts
Normal 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;
|
||||
Loading…
Reference in a new issue