# \[ANN\] New plugin - Text Formatter

**URL:** <https://www.ruby-forum.com/t/ann-new-plugin-text-formatter/114296>\
**Category:** Rails\
**Created:** [September 11, 2007, 1:00am UTC](https://www.ruby-forum.com/t/ann-new-plugin-text-formatter/114296 "2007-09-11T01:00:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ss\_1982](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@ss\_1982](https://www.ruby-forum.com/u/ss_1982)\
**Post date:** [September 11, 2007, 1:00am UTC](https://www.ruby-forum.com/t/ann-new-plugin-text-formatter/114296/1 "2007-09-11T01:00:12Z")

</div>

TextFormatter plugin allows you filter user input, use the syntax gem,  
before it is saved to the database.

If anyone has any suggestions or constructive feedback on these new  
plugins, please send them over.

[http://www.railslodge.com/blogs/12](http://www.railslodge.com/blogs/12)

Install the plugin:

ruby script\plugin install  
[http://svn.railslodge.com/svn/plugins/text\_formatter/](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.

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

---

<div class="post-metadata">

**Author:** ![ss\_1982](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@ss\_1982](https://www.ruby-forum.com/u/ss_1982)\
**Post date:** [September 12, 2007, 4:48am UTC](https://www.ruby-forum.com/t/ann-new-plugin-text-formatter/114296/2 "2007-09-12T04:48:00Z")

</div>

I like it. thanks very much.

On Sep 10, 7:00 pm, Scott A S [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
