Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
class String def indent(amount, string="\t") is_on = true self.split("\n").collect do |line| # indent line result = is_on ? string*amount + line : line # turn indenting on or off for lines with preformatted text if line =~ /<pre/ and line !~ /<\/pre>/ is_on = false elsif line !~ /<pre/ and line =~ /<\/pre>/ is_on = true end # return result result end.join("\n") end end
This paste will be private.
From the Design Piracy series on my blog: