Created
November 30, 2010 19:57
-
-
Save fnando/722283 to your computer and use it in GitHub Desktop.
Remove indentation from all lines, based on the first one.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class String | |
def unindent | |
_, spaces = *match(/^([\t ]+)/) | |
spaces ? gsub(%r[^#{spaces}]ms, "") : self | |
end | |
end | |
html = <<-CODE.unindent | |
THIS IS JUST A TEST | |
AND THIS A TEXT SNIPPET THAT SHOULD | |
BE INDENTED ONLY TWO SPACES FROM LEFT. | |
CODE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment