C# Class Tp.Web.Extensions.Components.PlainTextRenderer

A specialized sanitizer which outputs formatted plain text instead of HTML.
The renderer removes extra whitespace, and converts block level HTML elements to lines of plain text.
Inheritance: Sanitizer
Datei anzeigen Open project: TargetProcess/Tp.HelpDesk Class Usage Examples

Protected Properties

Property Type Description
_newLineStarted bool
_whiteSpaceStarted bool

Public Methods

Method Description
RenderToPlainText ( string input ) : string

Converts HTML to plain text.

Warning, the returned text may contain HTML fragments!!! For example, the original HTML code is: <p>&lt;hello&lt;>/p> Then, the converted text will be: <hello> So if you intend to output the stripped text in HTML, you need encode it first!

Protected Methods

Method Description
After ( TextWriter result ) : void
Before ( TextWriter result ) : void
RenderText ( TextWriter result, string value ) : void
StartNewLine ( TextWriter result ) : void
WriteCData ( TextWriter result, string value ) : void
WriteElement ( TextWriter result, string name, StringDictionary attributes, bool empty ) : void
WriteEndElement ( TextWriter result, string name ) : void
WriteString ( TextWriter result, string value ) : void

Method Details

After() protected method

protected After ( TextWriter result ) : void
result System.IO.TextWriter
return void

Before() protected method

protected Before ( TextWriter result ) : void
result System.IO.TextWriter
return void

RenderText() protected method

protected RenderText ( TextWriter result, string value ) : void
result System.IO.TextWriter
value string
return void

RenderToPlainText() public static method

Converts HTML to plain text.
Warning, the returned text may contain HTML fragments!!! For example, the original HTML code is: <p>&lt;hello&lt;>/p> Then, the converted text will be: <hello> So if you intend to output the stripped text in HTML, you need encode it first!
public static RenderToPlainText ( string input ) : string
input string Input HTML. May be null.
return string

StartNewLine() protected method

protected StartNewLine ( TextWriter result ) : void
result System.IO.TextWriter
return void

WriteCData() protected method

protected WriteCData ( TextWriter result, string value ) : void
result System.IO.TextWriter
value string
return void

WriteElement() protected method

protected WriteElement ( TextWriter result, string name, StringDictionary attributes, bool empty ) : void
result System.IO.TextWriter
name string
attributes System.Collections.Specialized.StringDictionary
empty bool
return void

WriteEndElement() protected method

protected WriteEndElement ( TextWriter result, string name ) : void
result System.IO.TextWriter
name string
return void

WriteString() protected method

protected WriteString ( TextWriter result, string value ) : void
result System.IO.TextWriter
value string
return void

Property Details

_newLineStarted protected_oe property

If new line has already been written.
protected bool _newLineStarted
return bool

_whiteSpaceStarted protected_oe property

Whether currently outputing whitespace.
protected bool _whiteSpaceStarted
return bool