Got questions, comments, patches, etc.?
Contact Jason Woofenden
gitweb
/
peach-html5-editor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
pretty-print html: one-line mode for small blocks
[peach-html5-editor.git]
/
editor.coffee
diff --git
a/editor.coffee
b/editor.coffee
index
2d06854
..
d9b8ac5
100644
(file)
--- a/
editor.coffee
+++ b/
editor.coffee
@@
-145,6
+145,12
@@
dom_to_html = (dom, indent = '', parent_is_block = false) ->
switch el.type
when TYPE_TAG
is_block = is_display_block el.el
switch el.type
when TYPE_TAG
is_block = is_display_block el.el
+ if is_block
+ is_tiny_block = false
+ if el.children.length is 1
+ if el.children[0].type is TYPE_TEXT
+ if el.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
if is_block or (parent_is_block and i is 0)
ret += indent
ret += '<' + el.name
@@
-163,10
+169,10
@@
dom_to_html = (dom, indent = '', parent_is_block = false) ->
else
next_indent = indent
if el.children.length
else
next_indent = indent
if el.children.length
- if is_block
+ if is_block and not is_tiny_block
ret += "\n"
ret += "\n"
- ret += dom_to_html el.children, next_indent, is_block
- if is_block or (parent_is_block and i is dom.length - 1)
+ ret += dom_to_html el.children, next_indent, is_block and not is_tiny_block
+ if is_block and not is_tiny_block
ret += indent
ret += "</#{el.name}>"
if is_block or (parent_is_block and i is dom.length - 1)
ret += indent
ret += "</#{el.name}>"
if is_block or (parent_is_block and i is dom.length - 1)