Browse files

Don't break around text lines

  • Loading branch information...
1 parent 68afd2e commit 7bd6839b5c5572ff0745228c30144440202c0912 @rubys committed Apr 25, 2012
Showing with 5 additions and 4 deletions.
  1. +5 −4 tools/web2script.rb
View
9 tools/web2script.rb
@@ -146,6 +146,7 @@ def code(element, indent='', flat=false)
method = (text.include? '<' or text.include? '&') ? '_?' : '_'
flow_text "#{indent} #{method} #{text.enquote}",
"\" +\n #{indent}\""
+ first = true # stop break
elsif child.comment?
flow_text "#{indent} _.comment #{child.text.strip.enquote}",
"\" +\n #{indent}\""
@@ -155,11 +156,11 @@ def code(element, indent='', flat=false)
# insert a blank line if either this or the previous block was large
if $group and start + $group < $q.length
- $q[start].sub! /^(\s+_\w+)([! .])/, '\1_\2'
- $q.insert(start,'') if not first and breakable
- blank = true
+ $q[start].sub! /^(\s+_\w+)([! .])/, '\1_\2' if breakable
+ $q.insert(start,'') if not first
+ blank = !child.text?
else
- $q.insert(start,'') if blank and breakable
+ $q.insert(start,'') if blank
blank = false
end
start = $q.length

0 comments on commit 7bd6839

Please sign in to comment.