_plugins/filters.rb
# remove all HTML tags and smart quotes
remove all HTML tags and smart quotes
remove all HTML tags and smart quotes
def strip_tags(html, decode=true)
    begin
      out = CGI.unescapeHTML(html.
        gsub(/<(script|style|pre|code|figure).*?>.*?<\/\1>/im, '').
        gsub(/<!--.*?-->/m, '').
        gsub(/<(img|hr|br).*?>/i, " ").
        gsub(/<(dd|a|h\d|p|small|b|i|blockquote|li)( [^>]*?)?>(.*?)<\/\1>/i, " \\3 ").
        gsub(/<\/?(dt|a|ul|ol)( [^>]+)?>/i, " ").
        gsub(/<[^>]+?>/, '').
        gsub(/\[\d+\]/, '').
        gsub(/&#8217;/,"'").gsub(/&.*?;/,' ').gsub(/;/,' ').
        gsub(/\u2028/,'')
      ).lstrip
      if decode
        out.force_encoding("ASCII-8BIT").gsub("\xE2\x80\x98","'").gsub("\xE2\x80\x99","'").gsub("\xCA\xBC","'").gsub("\xE2\x80\x9C",'"').gsub("\xE2\x80\x9D",'"').gsub("\xCB\xAE",'"').squeeze(" ")
      else
        out.squeeze(" ")
      end
    rescue
      CGI.unescapeHTML(html)
    end
  end
def strip_tags ( html , decode = true ) begin out = CGI . unescapeHTML ( html . gsub ( / <(script|style|pre|code|figure).*?>.*?< \/ \1 > /im , '' ) . gsub ( / <!--.*?--> /m , '' ) . gsub ( / <(img|hr|br).*?> /i , " " ) . gsub ( / <(dd|a|h \d |p|small|b|i|blockquote|li)( [^>]*?)?>(.*?)< \/ \1 > /i , " \\3 " ) . gsub ( / < \/ ?(dt|a|ul|ol)( [^>]+)?> /i , " " ) . gsub ( / <[^>]+?> / , '' ) . gsub ( / \[ \d + \] / , '' ) . gsub ( / &#8217; / , "'" ) . gsub ( / &.*?; / , ' ' ) . gsub ( / ; / , ' ' ) . gsub ( / \u2028 / , '' ) ) . lstrip if decode out . force_encoding ( "ASCII-8BIT" ) . gsub ( "\xE2\x80\x98" , "'" ) . gsub ( "\xE2\x80\x99" , "'" ) . gsub ( "\xCA\xBC" , "'" ) . gsub ( "\xE2\x80\x9C" , '"' ) . gsub ( "\xE2\x80\x9D" , '"' ) . gsub ( "\xCB\xAE" , '"' ) . squeeze ( " " ) else out . squeeze ( " " ) end rescue CGI . unescapeHTML ( html ) end end
remove all HTML tags and smart quotes
remove all HTML tags and smart quotes
html
<not_specific>
decode
<not_specific>