})
}
+// no closing tag, cannot have children
void_elements = {
area: true,
base: true,
wbr: true
}
+// contents are not html encoded
+plaintext_elements = {
+ style: true,
+ script: true,
+ xmp: true,
+ iframe: true,
+ noembed: true,
+ noframes: true,
+ plaintext: true,
+ noscript: true
+}
+
// this does not pretty-print
function nodes_to_html (tree) {
var attr_keys, i, k, n, ret
}
break
case 'text':
- ret += enc_text(n.text)
+ if (n.parent != null ? plaintext_elements[n.parent.name] : false) {
+ ret += n.text
+ } else {
+ ret += enc_text(n.text)
+ }
break
case 'comment':
ret += "<!--" + n.text + "-->" // TODO encode?
// on_init: callback for when the editable content is in place
var css, opt_fragment, outer_bounds, outer_iframe_style, outer_wrap
this.options = options != null ? options : {}
+ this.pretty_print = options.pretty_print != null ? options.pretty_print : true
this.in_el = in_el
this.tree = null // array of Nodes, all editable content
this.tree_parent = null // this.tree is this.children. .el might === this.idoc.body
}
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)
+ if (this.pretty_print) {
+ this.in_el.value = this.pretty_html(this.tree)
+ } else {
+ this.in_el.value = nodes_to_html(this.tree)
+ }
this.in_el.onchange = (function(_this) { return function() {
return _this.load_html(_this.in_el.value)
}})(this)
}
break
case 'text':
- ret += enc_text(n.text)
+ if (n.parent != null ? plaintext_elements[n.parent.name] : false) {
+ ret += n.text
+ } else {
+ ret += enc_text(n.text)
+ }
break
case 'comment':
ret += "<!--" + n.text + "-->" // TODO encode?