# QUESTION: Insert tags around highlighted text

**URL:** <https://www.ruby-forum.com/t/question-insert-tags-around-highlighted-text/107174>\
**Category:** Rails\
**Created:** [June 18, 2007, 8:01pm UTC](https://www.ruby-forum.com/t/question-insert-tags-around-highlighted-text/107174 "2007-06-18T20:01:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![joep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@joep](https://www.ruby-forum.com/u/joep)\
**Post date:** [June 18, 2007, 8:01pm UTC](https://www.ruby-forum.com/t/question-insert-tags-around-highlighted-text/107174/1 "2007-06-18T20:01:55Z")

</div>

Yello,

I have a textarea where the user can write a paragraph. I want to be  
able to let them highlight some of their text and then hit a “URL”  
button which will insert “[LINK]” before the highlighted text and  
“[/LINK]” after the text.

Does anyone know how to do this?

---

<div class="post-metadata">

**Author:** ![joep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@joep](https://www.ruby-forum.com/u/joep)\
**Post date:** [June 18, 2007, 8:31pm UTC](https://www.ruby-forum.com/t/question-insert-tags-around-highlighted-text/107174/2 "2007-06-18T20:31:58Z")

</div>

On Jun 18, 2007, at 2:01 PM, Joe P. wrote:

> Yello,
> 
> I have a textarea where the user can write a paragraph. I want to be  
> able to let them highlight some of their text and then hit a “URL”  
> button which will insert “[LINK]” before the highlighted text and  
> “[/LINK]” after the text.
> 
> Does anyone know how to do this?

[http://www.google.com/search?q=tiny+mce](http://www.google.com/search?q=tiny+mce)

Or use something like RedCloth (textile) to do the markup.

-Rob

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![joep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@joep](https://www.ruby-forum.com/u/joep)\
**Post date:** [June 18, 2007, 11:21pm UTC](https://www.ruby-forum.com/t/question-insert-tags-around-highlighted-text/107174/3 "2007-06-18T23:21:28Z")

</div>

While it’s going to be a little bit of overkill you can check out our  
Textile Editor Helper plugin to learn how to do what you’re asking.  
The javascript is pretty simple and straightforward.

[http://slateinfo.blogs.wvu.edu/plugins/textile\_editor\_helper](http://slateinfo.blogs.wvu.edu/plugins/textile_editor_helper)

On 6/18/07, Joe P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–

Proud supporter of DC United
