nsIScriptableUnescapeHTML 编辑

parser/html/nsIScriptableUnescapeHTML.idlScriptable This interface is a utility interface that exposes the kind of markup parser behavior that the feed service needs. 1.0 66 Introduced Gecko 1.8 Obsolete Gecko 14.0 Inherits from: nsISupports Last changed in Gecko 1.8 (Firefox 1.5 / Thunderbird 1.5 / SeaMonkey 1.0) Note: As of Firefox 14, this interface is obsolete (but still available for compatibility with legacy extensions) and all its functionality is available with more configuration options via the nsIParserUtils interface.

Implemented by: @mozilla.org/feed-unescapehtml;1 as a service:

var scriptableUnescapeHTML = Components.classes["@mozilla.org/feed-unescapehtml;1"]
                             .getService(Components.interfaces.nsIScriptableUnescapeHTML);

Method overview

nsIDOMDocumentFragment parseFragment(in AString fragment, in PRBool isXML, in nsIURI baseURI, in nsIDOMElement element);
AString unescape(in AString src);

Methods

parseFragment()

Parses a string of HTML or XML source into a sanitized DocumentFragment.

This is equivalent to calling nsIParserUtils::parseFragment(fragment, 0, isXML, baseURI,element). You should call nsIParserUtils::parseFragment() instead of calling this method.

nsIDOMDocumentFragment parseFragment(
  in AString fragment,
  in PRBool isXML,
  in nsIURI baseURI,
  in nsIDOMElement element
);
Parameters
fragment
A string of HTML or XML source to parse as a fragment.
isXML
Set this to true if the fragment is an XML string; otherwise set it to false.
baseURI
Pointer to the base URI against which to resolve any URIs included in the fragment. This parameter is ignored if isXML is false.
element
The nsIDOMElement to be used as the context node for the purposes of the fragment parsing algorithm.
Return value

An nsIDOMDocumentFragment of the element with the new text appended.

Exceptions thrown
NS_ERROR_FAILURE
Unable to append the text to the element.

unescape()

Convents HTML source into plain text.

This is equivalent to calling nsIParserUtils::convertToPlainText(src,nsIDocumentEncoder::OutputSelectionOnly |nsIDocumentEncoder::OutputAbsoluteLinks, 0). You should call nsIParserUtils::convertToPlainText() instead of calling this method.

AString unescape(
  in AString src
);
Parameters
src
The HTML string to convert into plain text.
Return value

The result of the plain text conversion.

Exceptions thrown
NS_ERROR_FAILURE
Unable to convert the string.

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:113 次

字数:5653

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文