There are two lines these change would need to be made on:
m = l.match /^[ ]*/ # find leading spaces 0 or more
and
re = Regexp.new "^[ ]{#{min_space}}" #match the minimum spaces of the line
Please be specific about white spacing (i.e. use [ \t]), using \s may cause unicode white-space ghosts past, present and future to come back and kick your ass.