track: true,
wbr: true
}
+
+// this does not pretty-print
+function nodes_to_html (tree) {
+ var attr_keys, i, k, n, ret
+ ret = ''
+ for (i = 0; i < tree.length; ++i) {
+ n = tree[i]
+ switch (n.type) {
+ case 'tag':
+ ret += '<' + n.name
+ attr_keys = []
+ for (k in n.attrs) {
+ ret += " " + k
+ if (n.attrs[k].length > 0) {
+ ret += "=\"" + (enc_attr(n.attrs[k])) + "\""
+ }
+ }
+ ret += '>'
+ if (void_elements[n.name] == null) {
+ if (n.children.length) {
+ ret += nodes_to_html(n.children)
+ }
+ ret += "</" + n.name + ">"
+ }
+ break
+ case 'text':
+ ret += enc_text(n.text)
+ break
+ case 'comment':
+ ret += "<!--" + n.text + "-->" // TODO encode?
+ break
+ case 'doctype':
+ ret += "<!DOCTYPE " + n.name
+ if ((n.public_identifier != null) && n.public_identifier.length > 0) {
+ ret += " \"" + n.public_identifier + "\""
+ }
+ if ((n.system_identifier != null) && n.system_identifier.length > 0) {
+ ret += " \"" + n.system_identifier + "\""
+ }
+ ret += ">"
+ }
+ }
+ return ret
+}
+
// TODO make these always pretty-print (on the inside) like blocks
// TODO careful though: whitespace might get pushed to parent, which might be rendered
no_text_elements = { // these elements never contain text
PeachHTML5Editor.prototype.changed = function() {
this.in_el.onchange = null
this.in_el.value = this.pretty_html(this.tree)
+ // TODO make option for not pretty-printing: nodes_to_html(tree)
this.in_el.onchange = (function(_this) { return function() {
return _this.load_html(_this.in_el.value)
}})(this)
if (run == null) {
return
}
+ // merge consecutive text elements
if (run.length > 1) {
i = 1
prev = run[0]
if (need_preserve) {
// do we have it already?
ws = this.computed_style(n, 'white-space') // FIXME implement this
- if (ws_props[ws] == null ? true : ws_props[ws].space == null) {
+ if (ws_props[ws] != null ? !ws_props[ws].space : true) {
// 2nd arg is ideal target for css rule
ws = this.preserve_space(n, block)
}