Created
September 27, 2010 15:09
-
-
Save rondale-sc/599183 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
str = STDIN.read | |
start_marker, end_marker = "=begin\n", "\n=end" | |
out = '' | |
str.each_line do |line| | |
if str.split.shift == "=begin" | |
@uncomment = true | |
end | |
next if line[/^\=begin/] | |
next if line[/^\=end/] | |
next if line[/^\n/] | |
out << line | |
end | |
puts @uncomment? out : start_marker + out + end_marker |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Put in the toggle feature. Changed it from a custom start and end tag marker to ruby standard "=begin" "=end" syntax. Doing so removed the need for long 'if' statements. I'll probably make this into a little bundle at some point or another. TM by default allows code folding so adding the '=begin' '=end' syntax lets you fold multi-line comments. As an aside you could use this to comment and fold non-comment code which could be convenient. This prepends "=begin" and appends "=end" and removes them if they are found. Should be used with caution at this point. More to follow.