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)
Afficher le fichier Open project: pocket-playlab/jsonfx-v1 Class Usage Examples

Private Properties

Свойство 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

Méthodes publiques

Méthode 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

Méthode 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 méthode

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

DecodeHtmlEntities() public static méthode

public static DecodeHtmlEntities ( string source ) : string
source string
Résultat string

DecodeHtmlEntity() public static méthode

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

EncodeHtmlEntity() public static méthode

Encodes special characters into safe representation
public static EncodeHtmlEntity ( char ch ) : string
ch char
Résultat string

EndIncrementalParsing() public méthode

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

HtmlAttributeEncode() public static méthode

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
Résultat void

HtmlDistiller() public méthode

Ctor
public HtmlDistiller ( ) : System
Résultat System

HtmlDistiller() public méthode

Ctor
public HtmlDistiller ( int maxLength ) : System
maxLength int
Résultat System

HtmlDistiller() public méthode

Ctor
public HtmlDistiller ( int maxLength, IHtmlFilter filter ) : System
maxLength int
filter IHtmlFilter
Résultat System

Parse() public static méthode

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

Parse() public static méthode

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
Résultat string

Parse() public méthode

Parses the source using the current settings.
public Parse ( string html ) : void
html string
Résultat void

ParseSafe() public static méthode

Quick safe parsing.
public static ParseSafe ( string html ) : string
html string the source text
Résultat string

ParseSafe() public static méthode

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
Résultat string

PlainText() public static méthode

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

PlainText() public static méthode

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