<FONT color=#0000ff><SPAN style="FONT-WEIGHT: bold; TEXT-DECORATION: underline">This is bold text.</SPAN></FONT>
I am using it with FreeTextBox to allow web users to edit the html. However, it does not allow the user to remove the font formatting, since it expects it in the following format
<FONT color=#0000ff><STRONG><U>This is bold text.</U></STRONG></FONT>
I would like the user be able to remove the formatting(bold/underline) of this text. How can I do that?
Hello!
Thank you for your interest to HTML export.
I probably see your question without clarification. You’d like to get output that is accepted by FreeTextBox. Instead CSS styles there should be (or ), and . This is a known issue. We’ll let you know when it’s implemented.
As a workaround you can post-process the HTML output to replace CSS formatting with those HTML elements. This needs a bit of parsing and hopefully can be done with regular expressions.
Please feel free to ask anything else. And correct me if I’m not on the right way.
Regards,
Yes, that’s correct. Any idea when this will work(weeks, months or years)?
I will work on post-processing the HTML. Do you have any ready code that would post-process the HTML? Otherwise, I’ll work on that myself here.
Thank you.
Hi Melissa,
Thanks for your request. Currently I cannot provide you any reliable estimate regarding this issue. You will be notified as soon as it is resolved.
Regarding workaround, I think, you can use regular expressions to pre-process your HTML. For example, you can use code like the following:
string html = "This is bold text.";
// Search for style attributes in Span
Regex regex = new Regex("]*(style=[\"'][^\"']*(FONT-WEIGHT:\\s*(?[^\\s;]*))[^\"']*(TEXT-DECORATION:\\s*(?[^\\s;]*))[^\"']*[\"'])[^>]*>\\s*(?.*)\\s*", RegexOptions.Singleline | RegexOptions.IgnoreCase);
Match match = regex.Match(html);
// Format HTML elements starts and ends
string start = match.Groups["bold"].Value.ToLower() == "bold" ? "" : "";
start += match.Groups["decoration"].Value.ToLower() == "underline" ? "" : "";
start = string.IsNullOrEmpty(start) ? "" : start;
string end = match.Groups["decoration"].Value.ToLower() == "underline" ? "" : "";
end += match.Groups["bold"].Value.ToLower() == "bold" ? "" : "";
end = string.IsNullOrEmpty(start) ? "" : end;
// Replace html.
html = html.Replace(match.Value, start + match.Groups["innerhtml"] + end);
// Print HTML
Console.WriteLine(html);
Hope this helps.
Best regards,
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.