This is a migrated thread and some comments may be shown as answers.

HtmlFormatProvider Italics

1 Answer 80 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Chris Ward
Top achievements
Rank 1
Chris Ward asked on 20 May 2015, 08:41 PM

The question is about the output of this code:

Telerik.WinForms.Documents.FormatProviders.Html.HtmlFormatProvider fmt =
    new Telerik.WinForms.Documents.FormatProviders.Html.HtmlFormatProvider();
fmt.ExportSettings.StylesExportMode = Telerik.WinForms.Documents.FormatProviders.Html.StylesExportMode.Inline;
RadDocument rad = fmt.Import("The following word is <i>italic</i>.");
string html = fmt.Export(rad);

The HTML output contains:

<span style="font-family: 'Times New Roman';font-style: Italic;font-size: 16px;">italic</span>

It seems as though some HTML parsers don't regard "font-style: Italic" as a valid font-style. However, if I replace it with "font-style: italic" it works just fine. The client in question is GMail's HTML email viewer, but I'm sure there are others.

The only standard I can find related to this is the SVG 1.1 standard which states:

Keyword values, such as italic in font-style="italic", are also case-sensitive and must be specified using the exact case used in the specification which defines the given keyword.
http://www.w3.org/TR/SVG/styling.html Section 6.7 Paragraph 2

Obviously the DOCTYPE is xhtml, not an SVG file, but the premise that certain standards expect this particular word to be lowercase lends to the fact that in certain situations "Italic" vs. "italic" does matter.

 For the time being I'll just manually replace this substring in all of my HTML documents, but it would be nice if the RadDocument / HtmlFormatProvider guys could implement a permanent fix for this.

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 21 May 2015, 01:37 PM
Hello Chris,

Thank you for writing.

Indeed this is how a RadDocument gets exported to HTML. At the moment, if you would like to have the italic property start with a lower case you would need to manually change it. I think the easiest way would be to use a Regex: 
RadDocument rad = fmt.Import("The following word is <i>Italic</i>.");
string html = fmt.Export(rad);
string pattern = "font-style: Italic";
string replace = "font-style: italic";
string result = Regex.Replace(html, pattern, replace);

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Chris Ward
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or