C# Класс Subtext.Framework.Text.HtmlHelper

Static class used for parsing, formatting, and validating HTML.
Показать файл Открыть проект

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

Метод Описание
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