/// <summary>Visits the provided <paramref name="hyperlink"/> element.</summary> /// <param name="hyperlink">The <see cref="HyperlinkElement"/> to visit.</param> protected internal override void Visit(HyperlinkElement hyperlink) { BeginElementWithoutIndent("a"); WriteAttribute("href", hyperlink.Destination); foreach (var element in hyperlink.Content) { element.Accept(this); } EndElementWithoutIndent(); }
public void EscapesHtmlSpecialCharactersForHyperlinks(string text, string expectedHtml) { var actualHtml = new HyperlinkElement(text, new TextElement(text)).Accept(new HtmlWriterVisitor()); Assert.Equal(expectedHtml, actualHtml); }
private Element _GetCreoleElementFrom(TokenRange <CreoleTokenCode> tokens, CreoleRichTextElementNodeData nodeData) { Element result = null; switch (nodeData.ElementType) { case CreoleRichTextElementType.Code: result = new CodeElement( _GetContentFrom(tokens, nodeData) ); break; case CreoleRichTextElementType.Hyperlink: result = new HyperlinkElement( _GetUrlFrom(tokens, nodeData), _GetCreoleElements(tokens, nodeData.ContentStartIndex, nodeData.ContentEndIndex, nodeData.ChildNodes) ); break; case CreoleRichTextElementType.Image: if (nodeData.UrlEndIndex < nodeData.ContentStartIndex) { result = new ImageElement( _GetUrlFrom(tokens, nodeData), _GetContentFrom(tokens, nodeData) ); } else { result = new ImageElement( _GetUrlFrom(tokens, nodeData) ); } break; case CreoleRichTextElementType.Plugin: result = new PluginElement( _GetContentFrom(tokens, nodeData) ); break; case CreoleRichTextElementType.LineBreak: result = _creoleLineBreakElement; break; case CreoleRichTextElementType.InlineHyperlink: var url = _GetUrlFrom(tokens, nodeData); result = new HyperlinkElement(url, new[] { new TextElement(url) }); break; case CreoleRichTextElementType.EscapedInlineHyperlink: result = new TextElement( _GetUrlFrom(tokens, nodeData) ); break; case CreoleRichTextElementType.Emphasis: result = new EmphasisElement( _GetCreoleElements(tokens, nodeData.ContentStartIndex, nodeData.ContentEndIndex, nodeData.ChildNodes) ); break; case CreoleRichTextElementType.Strong: result = new StrongElement( _GetCreoleElements(tokens, nodeData.ContentStartIndex, nodeData.ContentEndIndex, nodeData.ChildNodes) ); break; } return(result); }
/// <summary>Visits the provided <paramref name="hyperlink"/> element.</summary> /// <param name="hyperlink">The <see cref="HyperlinkElement"/> to visit.</param> protected internal abstract void Visit(HyperlinkElement hyperlink);