TextFormatter ============= TextFormatter plugin allows you filter user input, before it is saved to the database. Setup ============ Install the plugin: ruby script\plugin install http://svn.railslodge.com/svn/plugins/text_formatter/ Install the following gems: gem install htmltokenizer gem install syntax gem install hpricot If you are using the syntax highlighting method, copy the css from /vender/plugins/text_formatter/stylesheets/text_formatter.css into your css file. Usage ============= The following methods can be used in your models: ===Remove HTML Tags Remove all html tags from the given fields tf_remove_html_tags :fieldname e.g. tf_remove_html_tags :title, :post ===Escape HTML Characters Escape all tags and special characters tf_escape_html_characters :fieldname e.g. tf_escape_all_html_characters :title, :post ===Escape Only Text Characters Escape all text except html tags tf_escape_text_characters :fieldname e.g. tf_escape_text_characters :title, :post ===Syntax Highlighting Add syntax highlighting to all text within pre tags tf_syntax_highlighting :fieldname e.g. tf_syntax_highlighting :title, :post ===Simple Text Markup Apply SimpleTextMarkup tf_simple_text_markup :fieldname e.g. tf_simple_text_markup :title, :post ===Content Formatter Remove all html tags, SimpleTextMarkup, encode tags within html tags, syntax highlighting tf_content_formatter :fieldname e.g. tf_content_formatter :title, :post ===Basic Formatter Remove all html tags, SimpleTextMarkup, encode tags within html tags tf_basic_formatter :fieldname e.g. tf_basic_formatter :title, :post Info ============= author: Scott Sherwood homepage: http://www.railslodge.com svn: http://svn.railslodge.com/svn/plugins/text_formatter/ license: MIT Thanks to ============= Henrik Nyh for providing the hpricot text transform extension. http://henrik.nyh.se/2007/03/transform-all-text-nodes-excepting-elements-with-hpricot RedCloth for some of the markup functions http://whytheluckystiff.net/ruby/redcloth/