C# Class JsonFx.BuildTools.HtmlDistiller.HtmlDistiller

Parses HTML, repairing and scrubbing against various whitelist filters.
Note: this class is thread-safe (all external changes are locked first)
显示文件 Open project: pocket-playlab/jsonfx-v1 Class Usage Examples

Private Properties

Property Type Description
Advance void
EmptyBuffer void
EmptyBuffer void
FlushBuffer string
FlushBuffer string
IncTextCount void
Init void
IsNameChar bool
IsNameStartChar bool
MapEntityName char
Parse void
ParseAttributeName string
ParseAttributeValue object
ParseAttributes void
ParseBlock HtmlTag
ParseBlocks HtmlTag
ParseStyles void
ParseSyncPoint void
ParseTag HtmlTag
Peek char
PrevChar char
RenderCloseTag void
RenderTag void
SkipWhiteSpace void
WriteBuffer void
WriteLiteral void
WriteLiteral void

Public Methods

Method Description
BeginIncrementalParsing ( ) : void

Starts parsing to be performed incrementally

There is a performance hit for parsing in chunks.

DecodeHtmlEntities ( string source ) : string
DecodeHtmlEntity ( string source, int index, char &entity ) : int

Decodes HTML entities into special characters

EncodeHtmlEntity ( char ch ) : string

Encodes special characters into safe representation

EndIncrementalParsing ( ) : void

Stops incremental parsing and completes tag balancing, etc.

HtmlAttributeEncode ( string value, TextWriter writer ) : void

Encodes characters which cannot be inside HTML attributes into safe representation

HtmlDistiller ( ) : System

Ctor

HtmlDistiller ( int maxLength ) : System

Ctor

HtmlDistiller ( int maxLength, IHtmlFilter filter ) : System

Ctor

Parse ( string html, IHtmlFilter filter ) : string

Quick parsing utility for common usage.

Parse ( string html, IHtmlFilter filter, int maxLength ) : string

Quick parsing utility for common usage.

Parse ( string html ) : void

Parses the source using the current settings.

ParseSafe ( string html ) : string

Quick safe parsing.

ParseSafe ( string html, int maxLength, int maxWordLength, bool autoLink ) : string

Quick safe parsing.

PlainText ( string html ) : string

Quick conversion to plain text.

PlainText ( string html, int maxLength ) : string

Quick conversion to plain text.

Private Methods

Method Description
Advance ( ) : void
EmptyBuffer ( ) : void
EmptyBuffer ( int skipCount ) : void
FlushBuffer ( ) : string
FlushBuffer ( int skipCount ) : string
IncTextCount ( ) : void

Keeps running tally of the plain text length

Init ( string html ) : void

Reset state used for parsing

Does not SyncLock, call inside lock

IsNameChar ( char ch ) : bool

http://www.w3.org/TR/REC-xml/#NT-NameChar

IsNameStartChar ( char ch ) : bool

http://www.w3.org/TR/REC-xml/#NT-NameStartChar

MapEntityName ( string name ) : char
Parse ( ) : void
ParseAttributeName ( ) : string
ParseAttributeValue ( ) : object
ParseAttributes ( HtmlTag tag ) : void
ParseBlock ( string startDelim, string endDelim ) : HtmlTag

Parses for "unparsed blocks" (e.g. comments, code blocks)

This supports comments, DocType declarations, CDATA sections, and ASP/JSP-style blocks.

ParseBlocks ( ) : HtmlTag
ParseStyles ( HtmlTag tag, string style ) : void

ParseSyncPoint ( ) : void

Causes parsing to end preserving partial source

ParseTag ( ) : HtmlTag

Attempts to parse the next sequence as a tag

Peek ( int peek ) : char
PrevChar ( int peek ) : char

Gets a previous char whether buffered or written out

RenderCloseTag ( HtmlTag tag ) : void
RenderTag ( HtmlTag tag ) : void
SkipWhiteSpace ( ) : void

Remove whitespace from the input source

WriteBuffer ( ) : void
WriteLiteral ( string value ) : void
WriteLiteral ( string source, int start, int end ) : void

Method Details

BeginIncrementalParsing() public method

Starts parsing to be performed incrementally
There is a performance hit for parsing in chunks.
public BeginIncrementalParsing ( ) : void
return void

DecodeHtmlEntities() public static method

public static DecodeHtmlEntities ( string source ) : string
source string
return string

DecodeHtmlEntity() public static method

Decodes HTML entities into special characters
public static DecodeHtmlEntity ( string source, int index, char &entity ) : int
source string
index int
entity char
return int

EncodeHtmlEntity() public static method

Encodes special characters into safe representation
public static EncodeHtmlEntity ( char ch ) : string
ch char
return string

EndIncrementalParsing() public method

Stops incremental parsing and completes tag balancing, etc.
public EndIncrementalParsing ( ) : void
return void

HtmlAttributeEncode() public static method

Encodes characters which cannot be inside HTML attributes into safe representation
public static HtmlAttributeEncode ( string value, TextWriter writer ) : void
value string
writer System.IO.TextWriter
return void

HtmlDistiller() public method

Ctor
public HtmlDistiller ( ) : System
return System

HtmlDistiller() public method

Ctor
public HtmlDistiller ( int maxLength ) : System
maxLength int
return System

HtmlDistiller() public method

Ctor
public HtmlDistiller ( int maxLength, IHtmlFilter filter ) : System
maxLength int
filter IHtmlFilter
return System

Parse() public static method

Quick parsing utility for common usage.
public static Parse ( string html, IHtmlFilter filter ) : string
html string the source text
filter IHtmlFilter a custom HtmlFilter
return string

Parse() public static method

Quick parsing utility for common usage.
public static Parse ( string html, IHtmlFilter filter, int maxLength ) : string
html string the source text
filter IHtmlFilter a custom HtmlFilter
maxLength int the maximum text length
return string

Parse() public method

Parses the source using the current settings.
public Parse ( string html ) : void
html string
return void

ParseSafe() public static method

Quick safe parsing.
public static ParseSafe ( string html ) : string
html string the source text
return string

ParseSafe() public static method

Quick safe parsing.
public static ParseSafe ( string html, int maxLength, int maxWordLength, bool autoLink ) : string
html string the source text
maxLength int the maximum text length
maxWordLength int the maximum length of a single word before wrapping
autoLink bool the maximum text length
return string

PlainText() public static method

Quick conversion to plain text.
public static PlainText ( string html ) : string
html string the source text
return string

PlainText() public static method

Quick conversion to plain text.
public static PlainText ( string html, int maxLength ) : string
html string the source text
maxLength int the maximum text length
return string