Hi, I am trying to create simple HTML editor that will let user create html content limited to few options and the requirement here is to produce html with only <p> <u> <em> <strong> <font color="#XXXXXX"> without any spans, class or any other inline styles. I know how to limit it from UI so user can only use a few button to bold text, underscore, etc but I don't know how to get rig of these spans and other elements in export html.
Attached picture shows exported html when in RadRichTextBox I only added two texts, one is bold, second is italic.
I would like to have exported html like this: <p><strong>test</strong></p><p><i>test</i></p>
Any ideas?
5 Answers, 1 is accepted
Hi Jakub,
You can achieve the desired result with the help of the ExportSettings exposed by the HtmlFormatProvider and especially the ExportBoldAsStrong and ExportItalicAsEm properties:
HtmlFormatProvider provider = new HtmlFormatProvider();
HtmlExportSettings htmlExportSettings = new HtmlExportSettings();
htmlExportSettings.ExportBoldAsStrong = true;
htmlExportSettings.ExportItalicAsEm = true;
provider.ExportSettings = htmlExportSettings;
For additional information check all the exposed ExportSettings Properties.
Regards,
Martin
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
Thank you Martin.
I knew about this two properties to export bold as strong and italic as em.
The problem is how to get rid of the spans with style atrribute and from other tags like p.
Do I need to loop through all the tree/items and remove styles?
The RichTextBox doesn't provide APIs for removing spans and paragraphs and if you need to do so, you will need to create a custom parser which to remove the unwanted elements.
Regards,
Martin
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
Hi Jakub,
I am afraid we don't have such an example but when browsing the web I found out there are such discussions that could be helpful (e.g. remove HTML tags).
Regards,
Martin
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.