We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Adding html to the markdown editor

We are actually using a markdown editor with two screens 1 for the markdown input and the other for preview .  we convert the markdown to html and feed it to the preview window. our markdown editor also takes raw html sometimes

when we try to add raw html in the markdown editor we get a good preview, as it works for most cases  but not for the style tag= <style> . this ignores the style tags completely in the preview and none of the styles are added . 

I also tested out the demo on your page and it does not seem to work - https://blazor.syncfusion.com/demos/rich-text-editor/markdown-overview?theme=bootstrap4.

would be great to have some assistance 

Thanks ym


1 Reply

VY Vinothkumar Yuvaraj Syncfusion Team March 8, 2023 05:39 PM UTC

Hi Ym,


To resolve this issue, we recommend setting the EnableHtmlSanitizer property to false into preview, which will allow you to add raw HTML and ensure that the styles are properly applied in the preview. Please note that by default, EnableHtmlSanitizer is set to true to avoid cross-scripting site attacks.

To implement this solution, please use the following code:


<SfRichTextEditor EnableHtmlSanitizer="false>

</SfRichTextEditor>


We have also attached a sample for your reference. You can find more information about EnableHtmlSanitizer in our API documentation, which is available at this

link: https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.RichTextEditor.SfRichTextEditor.html#Syncfusion_Blazor_RichTextEditor_SfRichTextEditor_EnableHtmlSanitizer

If you prefer not to disable the EnableHtmlSanitizer property for the preview, you can always add your styles into the application end.


Regards,

Vinothkumar


Attachment: BlazorApp1_c3416877_2904a40c.zip

Loader.
Live Chat Icon For mobile
Up arrow icon