I'm working on a Wordpress blog and sometimes need to comment out blocks of intermingled PHP and HTML. Don't get me started on either PHP or interspersing code and markup. Anyhow, here's a hackish command that toggles an if(false) block:
#!/usr/bin/env ruby
lines = STDIN.readlines
php_regex = /\<\?php/i
if lines[0] =~ php_regex
lines.each{|l| puts l unless l =~ php_regex}
else
puts '<?php if(false) { ?>'
lines.each{|l| puts l}
puts '<?php } ?>'
end
Hope this is useful to someone...