This line is partially duplicated by line 123. What about switching the ordering?

```ruby
if indent.length > 0
  text.gsub!(/^#{indent}/, ''
end

text.lines.map.etc.etc.etc
```

This will reduce the number of code paths.