简体   繁体   中英

Converting HTML to markdown in jodit

In the below link i'm using jodit editor with react. On changing the text it returns html with the styles we have selected.On typing, below you can see the value that it returns. I need some help in printing them in markdown language, is it possible to do in it.

https://codesandbox.io/s/lively-haze-yfbug

Tried converting the returned html to markdown using https://www.npmjs.com/package/turndown ,

For example <p><span style="font-family: Impact, Charcoal, sans-serif; font-size: 16px;">ME typing</span></p> while trying the convert the above using turndown service it just returns ME typing styles are not present.

Thanks in advance

just use

<div dangerouslySetInnerHTML={{__html: value}}></div> .

it should load it in the right way

import dompurify from 'dompurify';
import { marked } from 'marked';

marked.setOptions({
    breaks: true,
    gfm: true,
    pedantic: false,
    renderer: new marked.Renderer(),
    smartLists: false,
    smartypants: false,
    xhtml: false,
});

export const convertMarkedDownToHtml = (content: string): string => {
    const parsedHTML = dompurify.sanitize(marked.parse(content));
    return parsedHTML;
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM