From 5a4c884f525cd0dd28cd7a26ef6d283863dfcb2c Mon Sep 17 00:00:00 2001 From: Jason Woofenden Date: Wed, 9 Mar 2016 02:29:18 -0500 Subject: [PATCH] code cleanup (just renames) --- editor.coffee | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/editor.coffee b/editor.coffee index 494108e..d885b7d 100644 --- a/editor.coffee +++ b/editor.coffee @@ -163,61 +163,61 @@ no_text_elements = { # these elements never contain text tbody: true } # FIXME terminology: s/dom/tree/; s/el/n/ -dom_to_html = (dom, indent = '', parent_is_block = false) -> +tree_to_html = (tree, indent = '', parent_is_block = false) -> ret = '' - for el, i in dom - switch el.type + for n, i in tree + switch n.type when TYPE_TAG - is_block = is_display_block el.el + is_block = is_display_block n.el if is_block is_tiny_block = false - if is_whitespace_significant el + if is_whitespace_significant n is_tiny_block = true else - if el.children.length is 1 - if el.children[0].type is TYPE_TEXT - if el.children[0].text.length < 35 + if n.children.length is 1 + if n.children[0].type is TYPE_TEXT + if n.children[0].text.length < 35 is_tiny_block = true if is_block or (parent_is_block and i is 0) ret += indent - ret += '<' + el.name + ret += '<' + n.name attr_keys = [] - for k of el.attrs + for k of n.attrs attr_keys.unshift k #attr_keys.sort() for k in attr_keys ret += " #{k}" - if el.attrs[k].length > 0 - ret += "=\"#{enc_attr el.attrs[k]}\"" + if n.attrs[k].length > 0 + ret += "=\"#{enc_attr n.attrs[k]}\"" ret += '>' - unless void_elements[el.name]? + unless void_elements[n.name]? if is_block next_indent = indent + ' ' else next_indent = indent - if el.children.length + if n.children.length if is_block and not is_tiny_block ret += "\n" - ret += dom_to_html el.children, next_indent, is_block and not is_tiny_block + ret += tree_to_html n.children, next_indent, is_block and not is_tiny_block if is_block and not is_tiny_block ret += indent - ret += "" - if is_block or (parent_is_block and i is dom.length - 1) + ret += "" + if is_block or (parent_is_block and i is tree.length - 1) ret += "\n" when TYPE_TEXT if parent_is_block and i is 0 ret += indent - ret += enc_text el.text - if parent_is_block and i is dom.length - 1 + ret += enc_text n.text + if parent_is_block and i is tree.length - 1 ret += "\n" when TYPE_COMMENT - ret += "" + ret += "" when TYPE_DOCTYPE - ret += " 0 - ret += " \"#{el.public_identifier}\"" - if el.system_identifier? and el.system_identifier.length > 0 - ret += " \"#{el.system_identifier}\"" + ret += " 0 + ret += " \"#{n.public_identifier}\"" + if n.system_identifier? and n.system_identifier.length > 0 + ret += " \"#{n.system_identifier}\"" ret += ">\n" return ret @@ -812,7 +812,7 @@ class PeachHTML5Editor @changed() changed: -> @in_el.onchange = null - @in_el.value = dom_to_html @tree + @in_el.value = tree_to_html @tree @in_el.onchange = => @load_html @in_el.value @iframe.style.height = "0" -- 1.7.10.4