private static void OnHtmlToInlinesPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is Paragraph)
{
if (e.NewValue == null)
(d as Paragraph).Inlines.Clear();
else
{
var splits = Regex.Split(e.NewValue as string, htmlLineBreakRegex, RegexOptions.IgnoreCase | RegexOptions.ECMAScript);
foreach (var line in splits)
{
string text = Regex.Replace(line, htmlStripperRegex, string.Empty);
Regex regex = new Regex(@"[ ]{2,}", RegexOptions.None);
if (!string.IsNullOrWhiteSpace(text))
{
text = regex.Replace(text, @" "); //Remove multiple spaces
text = text.Replace(""", "\""); //Unencode quotes
text = text.Replace(" ", " "); //Unencode spaces
(d as Paragraph).Inlines.Add(new Run() { Text = text });
(d as Paragraph).Inlines.Add(new LineBreak());
}
}
}
}
}