Module: Stripper
- Defined in:
- lib/shed/stripper.rb
Class Method Summary collapse
-
.comments(str) ⇒ Object
Strips both xml and ecma script comments.
-
.ecma_comments(str) ⇒ Object
Strips comments from the document.
-
.xml_comments(str) ⇒ Object
Strips xml comments from the document.
Class Method Details
.comments(str) ⇒ Object
Strips both xml and ecma script comments.
41 42 43 44 45 |
# File 'lib/shed/stripper.rb', line 41 def comments(str) str = xml_comments(str) str = ecma_comments(str) str end |
.ecma_comments(str) ⇒ Object
Strips comments from the document.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# 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) ⇒ Object
Strips xml comments from the document.
10 11 12 13 14 |
# File 'lib/shed/stripper.rb', line 10 def xml_comments(str) str.gsub!(/<!--(?:.|([\r\n]))*?-->/,'') str.gsub(/<!--.*-->/,'') str end |