Project

formatize

0.02
No commit activity in last 3 years
No release in over 3 years
Gem containing the textilize, textilize_without_paragraph, and markdown helper methods removed from Rails.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

~> 2.2
~> 4.2
 Project Readme

Formatize

ABANDONED. I'm sorry, but this project is no longer active. Feel free to fork the repo, copy the code, release the code under a different gem or whatever you need

As of version 3, Rails doesn't have the textilize, textilize_without_paragraph, and markdown helper methods. Formatize brings them back. Drop it into the old application you're upgrading and it'll smoothen the process just that little bit more.

Build status badge

Installation

Put gem 'formatize' into your Gemfile and do a bundle install, and that's it. Formatize depends on RedCloth and bluecloth so you will not have to worry about those.

Usage

The textilize & textilize_without_paragraph helper methods

The textilize helper method accepts a string of Textile and one or more flags. Often, the default behavior will be suitable and you will not have to pass it any flags:

textilize("*This is Textile!*  Rejoice!")
# => "<p><strong>This is Textile!</strong>  Rejoice!</p>"

When necessary, flags are listed as such:

textilize("(snip)", :flag1, :flag2, :flag3)
# => "(snip)"

The RedCloth documentation lists the available flags. The textilize_without_paragraph method delegates to textilize but strips the surrounding <p> tags.

The markdown helper method

The markdown helper method accepts a string of Markdown and one or more flags. Often, the default behavior will be suitable and you will not have to pass it any flags:

markdown("We are using __Markdown__ now!")
# => "<p>We are using <strong>Markdown</strong> now!</p>"

When necessary, flags are listed as such:

markdown("(snip)", :flag1, :flag2, :flag3)
# => "(snip)"

The bluecloth documentation lists the available flags.

Sanitization

Both textilize and markdown sanitizes the input using Rails' sanitize prior to parsing. Since both gems can do this themselves, it's useful to be able to bypass the pre-parsing sanitization. Two ways:

  1. Pass a string that has been marked HTML safe. (Preferred).
  2. Use the special :safe flag, which is not passed on to the parser. (Deprecated in 1.1, removed in 2.0).

With Rails' sanitize, if you don't bypass it, you can choose which tags and attributes to allow as described in the documentation.

Compatibility

Feel free to try other versions. Minor patches to support other versions are welcome.

Ruby versions

  • 1.9.3-p125
  • 1.8.7-p358

Latest versions in the 1.8 and 1.9 series. Generally, Formatize will not jump through hoops to support other versions. 1.8 support may be dropped eventually.

Rails versions

  • 3.2.2
  • 3.1.4
  • 3.0.12

The latest versions in all the 3.0 series. This is likely to change when 4.0 is released.

Dependencies

  • RedCloth gem
  • bluecloth gem

Dependency status badge

Copyright & Licensing

Copyright (c) 2012 David Trasbo

Released under the MIT License. See LICENSE for details.