Project

htmlfilter

0.01
No commit activity in last 3 years
No release in over 3 years
Sanitize and sterilize HTML, also includes a CSS filter.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
 Project Readme

HTMLFilter

Website / Source Code

Description

HTML Filter library can be used to sanitize and sterilize HTML. A good idea if you let users submit HTML in comments, for instance.

This library also include CSSFilter. The CSSFilter class will clean-up a cascading style sheet. It can be used to remove whitespace and most importantly remove URLs.

Features

  • Based on well-worn PHP library.
  • Regular expression based filtering.
  • Very efficient for small snippets, like blog comments.
  • Pure-Ruby and no dependencies.
  • Also has library to clean and compact cascading stylesheets.

Synopsis

Via the class.

html = "<b>hello</b>"

HTMLFilter.new(options).filter(html)

Or using the String extension.

html.html_filter(options)  #=> "<b>hello</b>"

See API documentation for more information.

Installation

Of course, RubyGems is the answer:

$ gem install htmlfilter

Development

HTMLFilter is hosted on GitHub.

HTMLFilter is a Rubyworks project.

Acknowledgements

Thanks to Jang Kim for adding support for single quoted attributes.

HtmlFilter is a port of lib_filter.php, v1.15 by Cal Henderson cal@iamcal.com. This code is licensed under a Creative Commons Attribution-ShareAlike 2.5 License. See http://creativecommons.org/licenses/by-sa/2.5/.

Copyrights

  • Copyright (c) 2009 Rubyworks (BSD-2-Clause)
  • Copyright (c) 2007 Cal Henderson (CC-BY-SA)

See LICENSE.txt and NOTICE.md for details.