module Stripper

Public Class Methods

comments(str) click to toggle source

Strips both xml and ecma script comments.

# File lib/shed/stripper.rb, line 41
def comments(str)
  str = xml_comments(str)
  str = ecma_comments(str)
  str
end
ecma_comments(str) click to toggle source

Strips comments from the document.

# File lib/shed/stripper.rb, line 19
def ecma_comments(str)

  str.gsub!(/\/\*(?:.|([\r\n]))*?\*\//,'')

  # This is designed to leave whitespace in
  # place so the caret position remains correct.
  #do |s|
  #  if $1
  #    a = s.split("\n")
  #    r = "\n" * (a.length-1) if a.length > 1
  #    r
  #  end
  #end

  str.gsub!(/\/\/.*$/,'')
  str

end
xml_comments(str) click to toggle source

Strips xml comments from the document.

# File lib/shed/stripper.rb, line 10
def xml_comments(str)
  str.gsub!(/<!--(?:.|([\r\n]))*?-->/,'')
  str.gsub(/<!--.*-->/,'')
  str
end