Class CKEDITOR.htmlParser
Provides an "event like" system to parse strings of HTML data.
Defined in: core/htmlparser.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Creates a CKEDITOR.htmlParser class instance.
|
Method Attributes | Method Name and Description |
---|---|
<static> |
CKEDITOR.htmlParser.cssStyle(elementOrStyleText)
Object presentation of CSS style declaration text.
|
onCDATA(cdata)
Function to be fired when CDATA section is found.
|
|
onComment(comment)
Function to be fired when a commend is found.
|
|
onTagClose(tagName)
Function to be fired when a tag closer is found.
|
|
onTagOpen(tagName, attributes, selfClosing)
Function to be fired when a tag opener is found.
|
|
onText(text)
Function to be fired when text is found.
|
|
parse(html)
Parses text, looking for HTML tokens, like tag openers or closers,
or comments.
|
Class Detail
CKEDITOR.htmlParser()
Since:
3.0
Creates a CKEDITOR.htmlParser class instance.
var parser = new CKEDITOR.htmlParser(); parser.onTagOpen = function( tagName, attributes, selfClosing ) { alert( tagName ); }; parser.parse( '<p>Some <b>text</b>.</p>' );
Method Detail
<static>
{Undefined}
CKEDITOR.htmlParser.cssStyle(elementOrStyleText)
Since:
3.0
Object presentation of CSS style declaration text.
Defined in: core/htmlparser/element.js.
Defined in: core/htmlparser/element.js.
NO EXAMPLE AVAILABLE
- Parameters:
- {CKEDITOR.htmlParser.element|String} elementOrStyleText
- A html parser element or the inline style text.
{Undefined}
onCDATA(cdata)
Since:
3.0
Function to be fired when CDATA section is found. This function
should be overriden when using this class.
var parser = new CKEDITOR.htmlParser(); parser.onCDATA = function( cdata ) { alert( cdata ); // e.g. "var hello;" }); parser.parse( "<script>var hello;</script>" );
- Parameters:
- {String} cdata
- The CDATA been found.
{Undefined}
onComment(comment)
Since:
3.0
Function to be fired when a commend is found. This function
should be overriden when using this class.
var parser = new CKEDITOR.htmlParser(); parser.onComment = function( comment ) { alert( comment ); // e.g. " Example " }); parser.parse( "<!-- Example --><b>Hello</b>" );
- Parameters:
- {String} comment
- The comment text.
{Undefined}
onTagClose(tagName)
Since:
3.0
Function to be fired when a tag closer is found. This function
should be overriden when using this class.
var parser = new CKEDITOR.htmlParser(); parser.onTagClose = function( tagName ) { alert( tagName ); // e.g. "b" }); parser.parse( "<!-- Example --><b>Hello</b>" );
- Parameters:
- {String} tagName
- The tag name. The name is guarantted to be lowercased.
{Undefined}
onTagOpen(tagName, attributes, selfClosing)
Since:
3.0
Function to be fired when a tag opener is found. This function
should be overriden when using this class.
var parser = new CKEDITOR.htmlParser(); parser.onTagOpen = function( tagName, attributes, selfClosing ) { alert( tagName ); // e.g. "b" }); parser.parse( "<!-- Example --><b>Hello</b>" );
- Parameters:
- {String} tagName
- The tag name. The name is guarantted to be lowercased.
- {Object} attributes
- An object containing all tag attributes. Each property in this object represent and attribute name and its value is the attribute value.
- {Boolean} selfClosing
- true if the tag closes itself, false if the tag doesn't.
{Undefined}
onText(text)
Since:
3.0
Function to be fired when text is found. This function
should be overriden when using this class.
var parser = new CKEDITOR.htmlParser(); parser.onText = function( text ) { alert( text ); // e.g. "Hello" }); parser.parse( "<!-- Example --><b>Hello</b>" );
- Parameters:
- {String} text
- The text found.
{Undefined}
parse(html)
Since:
3.0
Parses text, looking for HTML tokens, like tag openers or closers,
or comments. This function fires the onTagOpen, onTagClose, onText
and onComment function during its execution.
var parser = new CKEDITOR.htmlParser(); // The onTagOpen, onTagClose, onText and onComment should be overriden // at this point. parser.parse( "<!-- Example --><b>Hello</b>" );
- Parameters:
- {String} html
- The HTML to be parsed.