1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

Cleaning up the find_and_preserve code.

git-svn-id: svn://hamptoncatlin.com/haml/trunk@601 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
nex3 2007-09-05 19:38:09 +00:00
parent b0b52623b6
commit f3d4bfe83b

View file

@ -46,10 +46,9 @@ module Haml
# to convert any endlines inside them into HTML entities for endlines.
def find_and_preserve(input)
input = input.to_s
input.scan(/<(textarea|code|pre)[^>]*>(.*?)<\/\1>/im) do |tag, contents|
input = input.gsub(contents, preserve(contents))
input.gsub(/<(textarea|code|pre)([^>]*)>(.*?)(<\/\1>)/im) do
"<#{$1}#{$2}>#{preserve($3)}</#{$1}>"
end
input
end
# Takes any string, finds all the endlines and converts them to