CreateHtmlFragment() public static method

Creates a HTML fragment from a part of a document.
public static CreateHtmlFragment ( TextDocument document, DocumentHighlighter highlighter, ISegment segment, HtmlOptions options ) : string
document ICSharpCode.AvalonEdit.Document.TextDocument The document to create HTML from.
highlighter DocumentHighlighter The highlighter used to highlight the document.
segment ISegment The part of the document to create HTML for. You can pass null to create HTML for the whole document.
options HtmlOptions The options for the HTML creation.
return string
Example #1
0
        public void PartOfHighlightedWordTest()
        {
            var segment = new TextSegment {
                StartOffset = 1, Length = 3
            };
            string html = HtmlClipboard.CreateHtmlFragment(document, highlighter, segment, new HtmlOptions());

            Assert.AreEqual("<span style=\"color: #008000; font-weight: bold; \">sin</span>", html);
        }
Example #2
0
		public void FullDocumentTest()
		{
			var segment = new TextSegment { StartOffset = 0, Length = document.TextLength };
			string html = HtmlClipboard.CreateHtmlFragment(document, highlighter, segment, new HtmlOptions());
			Assert.AreEqual("<span style=\"color: #008000; font-weight: bold; \">using</span>&nbsp;" +
			                "System<span style=\"color: #006400; \">.</span>Text<span style=\"color: #006400; \">;</span><br>" + Environment.NewLine +
			                "&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #ff0000; \">string</span>&nbsp;" +
			                "text =&nbsp;<span style=\"color: #191970; font-weight: bold; \">SomeMethod</span><span style=\"color: #006400; \">();</span>", html);
		}