# Properly parsing carriage returns in Rails so javascript doesn't freak out

**URL:** <https://www.ruby-forum.com/t/properly-parsing-carriage-returns-in-rails-so-javascript-doesnt-freak-out/125558>\
**Category:** Rails\
**Created:** [January 10, 2008, 3:23am UTC](https://www.ruby-forum.com/t/properly-parsing-carriage-returns-in-rails-so-javascript-doesnt-freak-out/125558 "2008-01-10T03:23:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnhutch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e9bcb4/32.png) [@johnhutch](https://www.ruby-forum.com/u/johnhutch)\
**Post date:** [January 10, 2008, 3:23am UTC](https://www.ruby-forum.com/t/properly-parsing-carriage-returns-in-rails-so-javascript-doesnt-freak-out/125558/1 "2008-01-10T03:23:19Z")

</div>

I’ve got some code that “quotes” the contents of a blog post and  
inserts it into a comment box wrapped in a blockquote. You can view it  
here:

[http://pastie.caboo.se/137533](http://pastie.caboo.se/137533)

Problem is, every time I try to quote a block of text with more than  
one line in it, the javascript freaks out. Can anyone tell me how I  
should be parsing these line breaks properly? thanks!

---

<div class="post-metadata">

**Author:** ![johnhutch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e9bcb4/32.png) [@johnhutch](https://www.ruby-forum.com/u/johnhutch)\
**Post date:** [January 10, 2008, 10:41am UTC](https://www.ruby-forum.com/t/properly-parsing-carriage-returns-in-rails-so-javascript-doesnt-freak-out/125558/2 "2008-01-10T10:41:28Z")

</div>

Hi,

I just call the escape function (js) and it works fine e.g.

```
            <%= link_to_remote "Try it!",:url => { :action

```

=\> :test\_rule },  
:with =\> “‘code=’+escape(rule\_rule\_body.value)  
+’&input\_data=’+escape(input\_data.value)  
+’&business\_type=’+escape(rule\_business\_type.value)” %\>

which passes a block of text for evaluation to the server.

Chris
