C# 클래스 Subtext.Framework.Text.HtmlHelper

Static class used for parsing, formatting, and validating HTML.
파일 보기 프로젝트 열기: ayende/Subtext

공개 메소드들

메소드 설명
AppendAttributeValue ( WebControl control, string name, string value ) : void

Appends the attribute value to the control appropriately.

AppendCssClass ( WebControl control, string newClass ) : void

Appends a CSS class to a control.

CheckForUrl ( string text ) : Uri

Checks the text and prepends "http://" if it doesn't have it already.

ConvertHtmlToXHtml ( Entry entry ) : bool

Converts the entry body into XHTML compliant text. Returns false if it encounters a problem in doing so.

ConvertHtmlToXHtml ( string html, string>.Converter converter ) : string

Converts the specified html into XHTML compliant text.

ConvertToAllowedHtml ( NameValueCollection allowedHtmlTags, string text ) : string

Filters text to only allow defined HTML.

ConvertToAllowedHtml ( string text ) : string

Filters text to only allow defined HTML.

ConvertUrlsToHyperLinks ( string html ) : string

Wraps an anchor tag around all urls. Makes sure not to wrap already wrapped urls.

GetLinks ( string text ) : StringCollection

Returns a string collection of URLs within the specified text.

HasIllegalContent ( string s ) : bool

Tests the specified string looking for illegal characters or html tags.

ParseTags ( string html ) : List

Parses some html and returns a string collection of the tag names contained within the HTML.

ParseUri ( string uri ) : Uri

Parses the URI.

RemoveCssClass ( WebControl control, string classToRemove ) : void

Removes a CSS class to a control.

RemoveHtml ( string text ) : string

Strips HTML tags from the specified text.

RemoveHtmlAndComments ( string text ) : string

Strips HTML tags and comments from the specified text

RemoveHtmlComments ( string text ) : string

Strips HTML comments from the specified text

ReplaceHost ( string originalUrl, string newHost ) : string

Replaces the host in the given url with the new host.

SafeFormat ( string stringToTransform ) : string

The only HTML we will allow is hyperlinks. We will however, check for line breaks and replace them with

ShortenUrl ( string url, int max ) : string

Shortens a url for display.

StripRTB ( string text, string host ) : string

Strips the RTB, whatever that is.

비공개 메소드들

메소드 설명
ConvertHtmlToXHtml ( SgmlReader reader, string html, string>.Converter converter ) : string

Converts the specified html into XHTML compliant text.

FilterAttributes ( string tagName, Match match, NameValueCollection allowedHtml ) : string

Removes any non-permitted attributes for the given tagName. The permitted attributes are determined by the given allowedHtml collection.

This will be a high volume method, so make it as efficient as possible

GetAttributeNameValues ( Match match ) : NameValueCollection
HtmlSafe ( string text ) : string
RemoveNewLineBeforeCDATA ( string text ) : string

메소드 상세

AppendAttributeValue() 공개 정적인 메소드

Appends the attribute value to the control appropriately.
public static AppendAttributeValue ( WebControl control, string name, string value ) : void
control System.Web.UI.WebControls.WebControl
name string
value string
리턴 void

AppendCssClass() 공개 정적인 메소드

Appends a CSS class to a control.
public static AppendCssClass ( WebControl control, string newClass ) : void
control System.Web.UI.WebControls.WebControl The control.
newClass string The new class.
리턴 void

CheckForUrl() 공개 정적인 메소드

Checks the text and prepends "http://" if it doesn't have it already.
public static CheckForUrl ( string text ) : Uri
text string Text.
리턴 System.Uri

ConvertHtmlToXHtml() 공개 정적인 메소드

Converts the entry body into XHTML compliant text. Returns false if it encounters a problem in doing so.
public static ConvertHtmlToXHtml ( Entry entry ) : bool
entry Subtext.Framework.Components.Entry Entry.
리턴 bool

ConvertHtmlToXHtml() 공개 정적인 메소드

Converts the specified html into XHTML compliant text.
public static ConvertHtmlToXHtml ( string html, string>.Converter converter ) : string
html string html to convert.
converter string>.Converter The converter.
리턴 string

ConvertToAllowedHtml() 공개 정적인 메소드

Filters text to only allow defined HTML.
public static ConvertToAllowedHtml ( NameValueCollection allowedHtmlTags, string text ) : string
allowedHtmlTags System.Collections.Specialized.NameValueCollection The allowed html tags.
text string Text.
리턴 string

ConvertToAllowedHtml() 공개 정적인 메소드

Filters text to only allow defined HTML.
public static ConvertToAllowedHtml ( string text ) : string
text string Text.
리턴 string

ConvertUrlsToHyperLinks() 공개 정적인 메소드

Wraps an anchor tag around all urls. Makes sure not to wrap already wrapped urls.
public static ConvertUrlsToHyperLinks ( string html ) : string
html string Html containing urls to convert.
리턴 string

GetLinks() 공개 정적인 메소드

Returns a string collection of URLs within the specified text.
public static GetLinks ( string text ) : StringCollection
text string The text.
리턴 System.Collections.Specialized.StringCollection

HasIllegalContent() 공개 정적인 메소드

Tests the specified string looking for illegal characters or html tags.
public static HasIllegalContent ( string s ) : bool
s string S.
리턴 bool

ParseTags() 공개 정적인 메소드

Parses some html and returns a string collection of the tag names contained within the HTML.
public static ParseTags ( string html ) : List
html string
리턴 List

ParseUri() 공개 정적인 메소드

Parses the URI.
public static ParseUri ( string uri ) : Uri
uri string The URI.
리턴 System.Uri

RemoveCssClass() 공개 정적인 메소드

Removes a CSS class to a control.
public static RemoveCssClass ( WebControl control, string classToRemove ) : void
control System.Web.UI.WebControls.WebControl The control.
classToRemove string The new class.
리턴 void

RemoveHtml() 공개 정적인 메소드

Strips HTML tags from the specified text.
public static RemoveHtml ( string text ) : string
text string The text.
리턴 string

RemoveHtmlAndComments() 공개 정적인 메소드

Strips HTML tags and comments from the specified text
public static RemoveHtmlAndComments ( string text ) : string
text string The text
리턴 string

RemoveHtmlComments() 공개 정적인 메소드

Strips HTML comments from the specified text
public static RemoveHtmlComments ( string text ) : string
text string The text
리턴 string

ReplaceHost() 공개 정적인 메소드

Replaces the host in the given url with the new host.
public static ReplaceHost ( string originalUrl, string newHost ) : string
originalUrl string
newHost string
리턴 string

SafeFormat() 공개 정적인 메소드

The only HTML we will allow is hyperlinks. We will however, check for line breaks and replace them with
public static SafeFormat ( string stringToTransform ) : string
stringToTransform string
리턴 string

ShortenUrl() 공개 정적인 메소드

Shortens a url for display.
public static ShortenUrl ( string url, int max ) : string
url string The URL.
max int Maximum size for the url. Anything longer gets shortened.
리턴 string

StripRTB() 공개 정적인 메소드

Strips the RTB, whatever that is.
public static StripRTB ( string text, string host ) : string
text string Text.
host string Host.
리턴 string