# Some redcloth questions

**URL:** <https://www.ruby-forum.com/t/some-redcloth-questions/122197>\
**Category:** Rails\
**Created:** [December 5, 2007, 1:58pm UTC](https://www.ruby-forum.com/t/some-redcloth-questions/122197 "2007-12-05T13:58:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubynuby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ba9def/32.png) [@rubynuby](https://www.ruby-forum.com/u/rubynuby)\
**Post date:** [December 5, 2007, 1:58pm UTC](https://www.ruby-forum.com/t/some-redcloth-questions/122197/1 "2007-12-05T13:58:24Z")

</div>

1. Is there a way to strip a redcloth string of all redcloth tags? I  
need to display a snippet of the text in an index page and want all  
markings removed. I used RedCloth.new(‘a’).methods but didn’t find  
anything appropriate. For now, I’m converting to html then stripping  
tags.

2. what’s the best practice in term of storing user’s redcloth-  
formatted text? store in markup, and convert to html on the fly?  
store in markup and html both? store in html and convert to markup  
using clothred for editing?

---

<div class="post-metadata">

**Author:** ![rubynuby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ba9def/32.png) [@rubynuby](https://www.ruby-forum.com/u/rubynuby)\
**Post date:** [December 5, 2007, 8:02pm UTC](https://www.ruby-forum.com/t/some-redcloth-questions/122197/2 "2007-12-05T20:02:37Z")

</div>

1. I don’t know for sure, but I don’t think there is.

2. I store the text as the user typed in the database and then use  
RedCloth to textilize it when rendering. It uses more CPU ticks but at  
least that way I have the original comment stored. If a user wanted to  
edit his or her comment I wouldn’t have to try something sloppy like  
converting HTML back to markup but rather show them what they entered to  
begin with. You can possibly store both the textilized text and the  
original text for good measure (in case it needs to be parsed again  
later on for whatever reason). I personally don’t do that because I do  
a lot of modifications to the text in my helpers before and after it’s  
been converted to HTML.

rubynuby wrote:

> 1. Is there a way to strip a redcloth string of all redcloth tags? I  
> need to display a snippet of the text in an index page and want all  
> markings removed. I used RedCloth.new(‘a’).methods but didn’t find  
> anything appropriate. For now, I’m converting to html then stripping  
> tags.
> 
> 2. what’s the best practice in term of storing user’s redcloth-  
> formatted text? store in markup, and convert to html on the fly?  
> store in markup and html both? store in html and convert to markup  
> using clothred for editing?

---

<div class="post-metadata">

**Author:** ![rubynuby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ba9def/32.png) [@rubynuby](https://www.ruby-forum.com/u/rubynuby)\
**Post date:** [December 5, 2007, 10:51pm UTC](https://www.ruby-forum.com/t/some-redcloth-questions/122197/3 "2007-12-05T22:51:09Z")

</div>

I add another column to my table paralleling the original column,  
(i.e. body, filtered\_body), and then use the before\_save activerecord  
callback to convert the textile content to html, and store the result  
in filtered\_body for display. That way it gets updated whenever you  
make a change, but you aren’t doing it on every page load…

–matt

On 12/5/07, R. Elliott M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> later on for whatever reason). I personally don’t do that because I do
> 
> > 1. what’s the best practice in term of storing user’s redcloth-  
> > formatted text? store in markup, and convert to html on the fly?  
> > store in markup and html both? store in html and convert to markup  
> > using clothred for editing?
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

## – Matt W.

Thermal Creative  
[http://blog.thermalcreative.com](http://blog.thermalcreative.com)
