Module: Qualys

Defined in:
lib/qualys/element.rb

Defined Under Namespace

Modules: Asset, WAS Classes: Element

Class Method Summary collapse

Class Method Details

.cleanup_html(source) โ‡’ Object

[View source]

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/qualys/element.rb', line 3

def self.cleanup_html(source)
  result = source.dup
  result.gsub!(/"/, '"')
  result.gsub!(/&lt;/, '<')
  result.gsub!(/&gt;/, '>')

  result.gsub!(/<p>/i, "\n\n")
  result.gsub!(/<br>/i, "\n")
  result.gsub!(/          /, "")
  result.gsub!(/<a href=\"(.*?)\"\s?target=\"_blank\">(.*?)<\/a>/i) { "\"#{$2.strip}\":#{$1.strip}" }
  result.gsub!(/<pre>(.*?)<\/pre>/im) { |m| "\n\nbc.. #{$1.strip}\n\np.  \n" }
  result.gsub!(/<b>(.*?)<\/b>/i) { "*#{$1.strip}*" }
  result.gsub!(/<b>|<\/b>/i, "")
  result.gsub!(/<i>(.*?)<\/i>/i) { "_#{$1.strip}_" }

  result.gsub!(/<dl>|<\/dl>/i, "\n")
  result.gsub!(/<dt>(.*?)<\/dt>/i) { "* #{$1.strip}" }
  result.gsub!(/<dd>(.*?)<\/dd>/i) { "** #{$1.strip}" }
  result
end