# Limiting Textile (RedCloth) Parsing

**URL:** <https://www.ruby-forum.com/t/limiting-textile-redcloth-parsing/67444>\
**Category:** Rails\
**Created:** [September 4, 2006, 2:44pm UTC](https://www.ruby-forum.com/t/limiting-textile-redcloth-parsing/67444 "2006-09-04T14:44:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dylan\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bc8723/32.png) [@Dylan\_B](https://www.ruby-forum.com/u/Dylan_B)\
**Post date:** [September 4, 2006, 2:44pm UTC](https://www.ruby-forum.com/t/limiting-textile-redcloth-parsing/67444/1 "2006-09-04T14:44:00Z")

</div>

Is there a way to limit Textile parsing? Textile is great, but I don’t  
want users leaving comments with the ability to add tables and so  
forth. Is there a way to limit what gets parsed? I’ve tried searching  
for a way to do this, but with not much luck.

I have no fear of diving in and getting my hard dirty, but I’m new to  
Ruby and to Rails and am just having a hard time finding the right  
direction to go in.

---

<div class="post-metadata">

**Author:** ![Dylan\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bc8723/32.png) [@Dylan\_B](https://www.ruby-forum.com/u/Dylan_B)\
**Post date:** [September 4, 2006, 2:44pm UTC](https://www.ruby-forum.com/t/limiting-textile-redcloth-parsing/67444/2 "2006-09-04T14:44:00Z")

</div>

On 9/3/06, Dylan B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is there a way to limit Textile parsing? Textile is great, but I don’t  
> want users leaving comments with the ability to add tables and so  
> forth. Is there a way to limit what gets parsed? I’ve tried searching  
> for a way to do this, but with not much luck.
> 
> I have no fear of diving in and getting my hard dirty, but I’m new to  
> Ruby and to Rails and am just having a hard time finding the right  
> direction to go in.

[http://redcloth.rubyforge.org/rdoc/](http://redcloth.rubyforge.org/rdoc/)

Look at RedCloth.new and Redcloth#to\_html

–  
Rick O.  
[http://weblog.techno-weenie.net](http://weblog.techno-weenie.net)  
[http://mephistoblog.com](http://mephistoblog.com)

---

<div class="post-metadata">

**Author:** ![Dylan\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bc8723/32.png) [@Dylan\_B](https://www.ruby-forum.com/u/Dylan_B)\
**Post date:** [September 4, 2006, 2:44pm UTC](https://www.ruby-forum.com/t/limiting-textile-redcloth-parsing/67444/3 "2006-09-04T14:44:01Z")

</div>

On Sun, Sep 03, 2006, Dylan B. wrote:

> Is there a way to limit Textile parsing? Textile is great, but I don’t  
> want users leaving comments with the ability to add tables and so  
> forth. Is there a way to limit what gets parsed? I’ve tried searching  
> for a way to do this, but with not much luck.

You can put the RedCloth parser into “lite mode” which disables  
block-level elements:

RedCloth.new( textile\_str, [:lite\_mode] ).to\_html

Check out the docs at [http://redcloth.rubyforge.org](http://redcloth.rubyforge.org) for more.

Ben

---

<div class="post-metadata">

**Author:** ![Dylan\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bc8723/32.png) [@Dylan\_B](https://www.ruby-forum.com/u/Dylan_B)\
**Post date:** [September 5, 2006, 4:20am UTC](https://www.ruby-forum.com/t/limiting-textile-redcloth-parsing/67444/4 "2006-09-05T04:20:51Z")

</div>

Thanks, Ben and Rick. I found what I need, which are the rules for the  
to\_html method. I found that I could simply not include one of the  
rules to determine what did or did not get processed.

However, I did run into one hitch, which was the glyphs processing  
rule. Fortunately, RedCloth is open source and I was able to look in  
the source to find out what the problem was. It turns out the RedCloth  
documentation is out of date. Also, fortunately, there’s a wiki entry  
on the [rubyonrails.org](http://rubyonrails.org) site for RedCloth, so I was able to add the data  
to the wiki about the problem (until they update the official  
documentation) so others don’t get stuck.

Thanks again for the help!

–Dylan
