# Strip out RedCloth markup?

**URL:** <https://www.ruby-forum.com/t/strip-out-redcloth-markup/135650>\
**Category:** Redcloth\
**Created:** [April 23, 2008, 9:56pm UTC](https://www.ruby-forum.com/t/strip-out-redcloth-markup/135650 "2008-04-23T21:56:09Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![yardboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9de0a6/32.png) [@yardboy](https://www.ruby-forum.com/u/yardboy)\
**Post date:** [April 23, 2008, 9:56pm UTC](https://www.ruby-forum.com/t/strip-out-redcloth-markup/135650/1 "2008-04-23T21:56:09Z")

</div>

Is there a way in RedCloth to go from text with Textile markup in it to  
plain text without the markup? Not just

```
or that passes
it through, but actually strips out the textile markup glyphs so
something like

_word_

ends up just being

word

in the output?

thanks.
```

---

<div class="post-metadata">

**Author:** ![yardboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9de0a6/32.png) [@yardboy](https://www.ruby-forum.com/u/yardboy)\
**Post date:** [April 23, 2008, 10:26pm UTC](https://www.ruby-forum.com/t/strip-out-redcloth-markup/135650/2 "2008-04-23T22:26:11Z")

</div>

No, not currently. You could write a plain text formatter like the  
HTML formatter in (the forthcoming) RedCloth 4.0. Then you rewrite  
the methods so it passes through the text you want but doesn’t add HTML.

If you want to hack on it, fork the project on github and let me know  
when you have something interesting.

Out of curiousity, what are you using this for?

---

<div class="post-metadata">

**Author:** ![yardboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9de0a6/32.png) [@yardboy](https://www.ruby-forum.com/u/yardboy)\
**Post date:** [April 24, 2008, 4:08am UTC](https://www.ruby-forum.com/t/strip-out-redcloth-markup/135650/3 "2008-04-24T04:08:22Z")

</div>

The site I’m working on has a batch email function and I’d like the user  
to be able to user Textile for creating their HTML formatted email.  
However, I’ve set up action mailer to do multipart emails in case  
recipient is on a plain text client. So, for the HTML mailer template I  
use the .to\_html output for the body text, and for the plain text mailer  
template I want to strip out the markup.

Right now I’m just sending through the marked up text, which isn’t  
horrible if you keep it simple, but links, for instance, really come  
through badly.

Thanks for the input.

---

<div class="post-metadata">

**Author:** ![yardboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9de0a6/32.png) [@yardboy](https://www.ruby-forum.com/u/yardboy)\
**Post date:** [April 24, 2008, 3:21pm UTC](https://www.ruby-forum.com/t/strip-out-redcloth-markup/135650/4 "2008-04-24T15:21:51Z")

</div>

Okay, that’s what I suspected. I have had that need at times too.  
Maybe it would be nice, instead of just outputting the text with no  
formatting, to do a little plain text formatting exclusively for  
human consumption (unlike Textile or Markdown). Like:

# Header 1

This is a link ([http://code.whytheluckystiff.net/redcloth](http://code.whytheluckystiff.net/redcloth)) and  
perhaps some _bold_ text.

Now, you specifically _didn’t_ want the asterisks around bold  
phrases, didn’t you? What do you think?

---

<div class="post-metadata">

**Author:** ![yardboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9de0a6/32.png) [@yardboy](https://www.ruby-forum.com/u/yardboy)\
**Post date:** [April 24, 2008, 5:39pm UTC](https://www.ruby-forum.com/t/strip-out-redcloth-markup/135650/5 "2008-04-24T17:39:21Z")

</div>

Exactly. See the LaTeX formatter someone added and do likewise.

---

<div class="post-metadata">

**Author:** ![yardboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9de0a6/32.png) [@yardboy](https://www.ruby-forum.com/u/yardboy)\
**Post date:** [April 24, 2008, 6:19pm UTC](https://www.ruby-forum.com/t/strip-out-redcloth-markup/135650/6 "2008-04-24T18:19:07Z")

</div>

Jason G. wrote:

> Exactly. See the LaTeX formatter someone added and do likewise.

Coolio - will start working on that. Thanks for your help.

---

<div class="post-metadata">

**Author:** ![yardboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9de0a6/32.png) [@yardboy](https://www.ruby-forum.com/u/yardboy)\
**Post date:** [April 24, 2008, 4:59pm UTC](https://www.ruby-forum.com/t/strip-out-redcloth-markup/135650/7 "2008-04-24T16:59:45Z")

</div>

Not so much _I_ didn’t want the asterisks, but client does not like the  
output that way.

I think I see what you’re getting at, though - would this be a matter of  
setting up custom RedCloth rules to apply the “plain text” formatting  
they want to end up with, and then perhaps a custom method to apply  
those rules instead of the normal ones, such as “.to\_plain\_formatted”?

---

<div class="post-metadata">

**Author:** ![yardboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9de0a6/32.png) [@yardboy](https://www.ruby-forum.com/u/yardboy)\
**Post date:** [May 23, 2008, 7:56pm UTC](https://www.ruby-forum.com/t/strip-out-redcloth-markup/135650/8 "2008-05-23T19:56:02Z")

</div>

Excuses, excuses, where’s that box of excuses I keep around here  
somewhere…

No, I haven’t. The particular client I was working with when I posted  
the question decided to go with plain text for their email function. The  
project for me to work on that formatter subsequently got moved to the  
back-burner behind some higher priority work. I still have aims to do  
it, because I know it’ll be needed in the future - I’ll notify on this  
thread when I get there.

Jason G. wrote:

> Cayce, any luck building that plain text formatter? I’ve got a  
> “base” module that the other formatters build off of, but I’m  
> thinking, “Hey, why not let them build off of a plain text formatter?”

---

<div class="post-metadata">

**Author:** ![yardboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9de0a6/32.png) [@yardboy](https://www.ruby-forum.com/u/yardboy)\
**Post date:** [May 23, 2008, 4:59pm UTC](https://www.ruby-forum.com/t/strip-out-redcloth-markup/135650/9 "2008-05-23T16:59:35Z")

</div>

Cayce, any luck building that plain text formatter? I’ve got a  
“base” module that the other formatters build off of, but I’m  
thinking, “Hey, why not let them build off of a plain text formatter?”
