module HTStyle

Main re-indent module for HTStyle. See github.com/technion/htstyle

Main re-indent module for HTStyle. See github.com/technion/htstyle

Constants

VERSION

Public Instance Methods

indenter(handle = STDIN) click to toggle source
# File lib/htstyle.rb, line 5
def indenter(handle = STDIN)
  accum = 0
  handle.each_line do |line|
    line.lstrip!
    line.chomp!
    accum += 4 if line[-1] == '{'
    accum -= 4 if line[-1] == '}'
    white = 80 - line.length - accum
    white = 0 if white < 0
    puts " " * white + line
  end
end