Sha256: 1754f500fff4fee71c00e43729d506101be849181d180782088c7a2997bca174

Contents?: true

Size: 377 Bytes

Versions: 2

Compression:

Stored size: 377 Bytes

Contents

class String
  # Returns a new string after stripping all html tags
  #
  #  string = "<hello>threre</hello>"
  #
  #  string.strip_html_tags => "there"
  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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
liquid_markdown-0.2.2 lib/liquid_markdown/core_ext/string/strip.rb
liquid_markdown-0.2.1 lib/liquid_markdown/core_ext/string/strip.rb