C# Класс Tp.Utils.Html.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.
Наследование: Sanitizer
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
_newLineStarted bool
_whiteSpaceStarted bool

Открытые методы

Метод Описание
RenderToPlainText ( string input, string newLine = "\n" ) : 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!

Защищенные методы

Метод Описание
AfterDocument ( TextWriter result ) : void
BeforeDocument ( TextWriter result ) : void
RenderText ( TextWriter result, string value ) : void
StartNewLine ( TextWriter result ) : void
WriteCData ( TextWriter result, string value ) : void
WriteElement ( TextWriter result, string name, string>.Dictionary attributes, bool empty ) : void
WriteEndElement ( TextWriter result, string name ) : void
WriteText ( TextWriter result, string value ) : void

Описание методов

AfterDocument() защищенный Метод

protected AfterDocument ( TextWriter result ) : void
result System.IO.TextWriter
Результат void

BeforeDocument() защищенный Метод

protected BeforeDocument ( TextWriter result ) : void
result System.IO.TextWriter
Результат void

RenderText() защищенный Метод

protected RenderText ( TextWriter result, string value ) : void
result System.IO.TextWriter
value string
Результат void

RenderToPlainText() публичный статический Метод

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 newLine = "\n" ) : string
input string Input HTML. May be null.
newLine string The line terminator string
Результат string

StartNewLine() защищенный Метод

protected StartNewLine ( TextWriter result ) : void
result System.IO.TextWriter
Результат void

WriteCData() защищенный Метод

protected WriteCData ( TextWriter result, string value ) : void
result System.IO.TextWriter
value string
Результат void

WriteElement() защищенный Метод

protected WriteElement ( TextWriter result, string name, string>.Dictionary attributes, bool empty ) : void
result System.IO.TextWriter
name string
attributes string>.Dictionary
empty bool
Результат void

WriteEndElement() защищенный Метод

protected WriteEndElement ( TextWriter result, string name ) : void
result System.IO.TextWriter
name string
Результат void

WriteText() защищенный Метод

protected WriteText ( TextWriter result, string value ) : void
result System.IO.TextWriter
value string
Результат void

Описание свойств

_newLineStarted защищенное свойство

If new line has already been written.
protected bool _newLineStarted
Результат bool

_whiteSpaceStarted защищенное свойство

Whether currently outputing whitespace.
protected bool _whiteSpaceStarted
Результат bool