3 * This is based loosely on tinymce
4 * @class Roo.htmleditor.TidySerializer
5 * https://github.com/thorn0/tinymce.html/blob/master/tinymce.html.js
8 * @param {Object} settings Name/value settings object.
12 Roo.htmleditor.TidySerializer = function(settings)
14 Roo.apply(this, settings);
16 this.writer = new Roo.htmleditor.TidyWriter(settings);
21 Roo.htmleditor.TidySerializer.prototype = {
24 * @param {boolean} inner do the inner of the node.
31 * Serializes the specified node into a string.
34 * new tinymce.html.Serializer().serialize(new tinymce.html.DomParser().parse('<p>text</p>'));
36 * @param {DomElement} node Node instance to serialize.
37 * @return {String} String with HTML based on DOM tree.
39 serialize : function(node) {
41 // = settings.validate;
42 var writer = this.writer;
48 writer.text(node.nodeValue, node);
52 writer.comment(node.nodeValue);
54 // Processing instruction
56 writer.pi(node.name, node.nodeValue);
60 writer.doctype(node.nodeValue);
64 writer.cdata(node.nodeValue);
68 node = node.firstChild;
74 node = node.nextSibling
79 1 != node.nodeType || this.inner ? this.handlers[11](node) : this.walk(node);
80 return writer.getContent();
85 var attrName, attrValue, sortedAttrs, i, l, elementRule,
86 handler = this.handlers[node.nodeType];
93 var name = node.nodeName;
94 var isEmpty = node.childNodes.length < 1;
96 var writer = this.writer;
97 var attrs = node.attributes;
100 writer.start(node.nodeName, attrs, isEmpty, node);
104 node = node.firstChild;
111 node = node.nextSibling;
117 // Serialize element and treat all non elements as fragments