1
mirror of https://github.com/rapid7/metasploit-framework synced 2024-11-12 11:52:01 +01:00

text compressing description

git-svn-id: file:///home/svn/incoming/trunk@2926 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
Matt Miller 2005-10-01 06:15:39 +00:00
parent 17a596186e
commit 13e8c4eeaf
2 changed files with 11 additions and 3 deletions

View File

@ -97,7 +97,7 @@ class ReadableText
# Description
output += "Description:\n"
output += word_wrap(mod.description)
output += word_wrap(Rex::Text.compress(mod.description))
output += "\n"
# References
@ -150,7 +150,7 @@ class ReadableText
# Description
output += "Description:\n"
output += word_wrap(mod.description)
output += word_wrap(Rex::Text.compress(mod.description))
output += "\n\n"
return output
@ -184,7 +184,7 @@ class ReadableText
# Description
output += "Description:\n"
output += word_wrap(mod.description)
output += word_wrap(Rex::Text.compress(mod.description))
output += "\n\n"
return output

View File

@ -298,6 +298,14 @@ module Text
raise ArgumentError, "Invalid class for value: #{value.class}"
end
end
#
# Compresses a string, eliminating all superfluous whitespace before and
# after lines and eliminating all lines.
#
def self.compress(str)
str.gsub(/\n/m, ' ').gsub(/\s+/, ' ').gsub(/^\s+/, '').gsub(/\s+$/, '')
end
end
end