private void AppendHyperlink(HtmlNode node, Paragraph paragraph, Span span)
{
Hyperlink hyperlink = new Hyperlink();
if (node.Attributes.Contains("href"))
{
string url = HttpUtility.HtmlDecode(node.Attributes["href"].Value);
hyperlink.Command = NavigationCommand;
hyperlink.CommandParameter = url;
hyperlink.Click += navigationHandler;
}
if (HyperlinkFontFamily != null)
hyperlink.FontFamily = HyperlinkFontFamily;
else if (hyperlink.FontFamily != this.FontFamily)
hyperlink.FontFamily = this.FontFamily;
if (HyperlinkFontSize != null)
hyperlink.FontSize = HyperlinkFontSize.Value;
else if (hyperlink.FontSize != this.FontSize)
hyperlink.FontSize = this.FontSize;
if (HyperlinkFontStretch != null)
hyperlink.FontStretch = HyperlinkFontStretch;
else if (hyperlink.FontStretch != this.FontStretch)
hyperlink.FontStretch = this.FontStretch;
if (HyperlinkFontStyle != null)
hyperlink.FontStyle = HyperlinkFontStyle;
else if (hyperlink.FontStyle != this.FontStyle)
hyperlink.FontStyle = this.FontStyle;
if (HyperlinkFontWeight != null)
hyperlink.FontWeight = HyperlinkFontWeight;
else if (hyperlink.FontWeight != this.FontWeight)
hyperlink.FontWeight = this.FontWeight;
if (HyperlinkForeground != null)
hyperlink.Foreground = HyperlinkForeground;
else if (hyperlink.Foreground != this.Foreground)
hyperlink.Foreground = this.Foreground;
if (span != null)
{
span.Inlines.Add(hyperlink);
}
else if (paragraph != null)
{
paragraph.Inlines.Add(hyperlink);
}
// my little hack to get rid of unnecessary space around the link
node.ChildNodes.First().InnerHtml = node.ChildNodes.First().InnerHtml.TrimStart();
node.ChildNodes.Last().InnerHtml = node.ChildNodes.Last().InnerHtml.TrimEnd();
RenderChildren(node, paragraph, hyperlink);
}