tinymce.html.SaxParser
This class parses HTML code using pure JavaScript and executes various events for each item it finds. It will always execute the events in the right order for tag soup code like <b><p></b></p>. It will also remove elements and attributes that doesn't fit the schema if the validate setting is enabled.
Examples
var parser = new tinymce.html.SaxParser({
validate: true,
comment: function(text) {
console.log('Comment:', text);
},
cdata: function(text) {
console.log('CDATA:', text);
},
text: function(text, raw) {
console.log('Text:', text, 'Raw:', raw);
},
start: function(name, attrs, empty) {
console.log('Start:', name, attrs, empty);
},
end: function(name) {
console.log('End:', name);
},
pi: function(name, text) {
console.log('PI:', name, text);
},
doctype: function(text) {
console.log('DocType:', text);
}
}, schema);
Constructors
name | summary | defined by |
---|---|---|
SaxParser() | Constructs a new SaxParser instance. | tinymce.html.SaxParser |
Methods
name | summary | defined by |
---|---|---|
parse() | Parses the specified HTML string and executes the callbacks for each item it finds. | tinymce.html.SaxParser |
Constructors
SaxParser
public constructor function SaxParser(settings:Object, schema:tinymce.html.Schema)
Constructs a new SaxParser instance.
Parameters
- settings (Object) - Name/value collection of settings. comment, cdata, text, start and end are callbacks.
- schema (tinymce.html.Schema) - HTML Schema class to use when parsing.
Methods
parse
parse(html:String)
Parses the specified HTML string and executes the callbacks for each item it finds.
Examples
SaxParser({...}).parse('<b>text</b>');
Parameters
- html (String) - Html string to sax parse.
Can't find what you're looking for? Let us know.
Except as otherwise noted, the content of this page is licensed under the Creative Commons BY-NC-SA 3.0 License, and code samples are licensed under the Apache 2.0 License.