ICSharpCode.AvalonEdit.Editing.Selection.CreateHtmlFragment C# (CSharp) Method

CreateHtmlFragment() public method

Creates a HTML fragment for the selected text.
public CreateHtmlFragment ( TextArea textArea, HtmlOptions options ) : string
textArea TextArea
options ICSharpCode.AvalonEdit.Highlighting.HtmlOptions
return string
        public string CreateHtmlFragment(TextArea textArea, HtmlOptions options)
        {
            if (textArea == null)
                throw new ArgumentNullException("textArea");
            if (options == null)
                throw new ArgumentNullException("options");
            DocumentHighlighter highlighter = textArea.GetService(typeof(DocumentHighlighter)) as DocumentHighlighter;
            StringBuilder html = new StringBuilder();
            bool first = true;
            foreach (ISegment selectedSegment in this.Segments) {
                if (first)
                    first = false;
                else
                    html.AppendLine("<br>");
                html.Append(HtmlClipboard.CreateHtmlFragment(textArea.Document, highlighter, selectedSegment, options));
            }
            return html.ToString();
        }