Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/liquid_markdown/core_ext/string/strip.rb

Instance Method Summary collapse

Instance Method Details

#strip_html_tagsObject

Returns a new string after stripping all html tags

string = "<hello>threre</hello>"

string.strip_html_tags => "there"


7
8
9
10
11
12
13
14
# File 'lib/liquid_markdown/core_ext/string/strip.rb', line 7

def strip_html_tags
  empty = ''.freeze
  self.to_s
      .gsub(/<script.*?<\/script>/m, empty)
      .gsub(/<!--.*?-->/m, empty)
      .gsub(/<style.*?<\/style>/m, empty)
      .gsub(/<.*?>/m, empty)
end