title: Ace editor (form) - Can I preserve line breaks/text format?
body: <p>Working on a project for my school building an MVC Sinatra application. I want to create a web app that can save and display back snippets/algos using ace editor.</p>
  
  <p>I figured out how to (seemingly) capture form input through ace editor by hiding the input field and assigning the value from ace on change with the snippet below.</p>
  
  <pre><code>//CAPTURE/SET VALUE
  var textarea = $('input[name="content"]');
  editor.getSession().on("change", function () {
      textarea.val(editor.getSession().getValue());
  });
  </code></pre>
  
  <p>my form looks like this</p>
  
  <pre><code>&lt;!--ACE EDITOR--&gt;
  &lt;div id="editor"&gt;&lt;/div&gt;
  To open settings panel, inside editor - CTRL+Q (Windows) | CMD+Q (Mac)
  &lt;!---------------------------------------------------------&gt;
  
  &lt;!--FORM--&gt;
  &lt;form action="/ace" method="POST"&gt; 
  
    &lt;!--normal--&gt;
    &lt;input type="text" name="content" style="display: none;" /&gt;
  
    &lt;!--submit--&gt;
    &lt;input type="submit" value="Save"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I can capture the params fine but the problem is it doen't preserve the line breaks so entering...</p>
  
  <pre><code>def something
  
  end
  </code></pre>
  
  <p>into ace editor and clicking submit gives me back</p>
  
  <pre><code>"def something  end"
  </code></pre>
  
  <p>when I would love in theory to get something like</p>
  
  <pre><code>"def something\n\nend"
  </code></pre>
  
  <p>or something of the sort.. you get the drift</p>
  
  <p>I need to be able to somehow use the editor to capture input, and on submit assign that to an object attribute so pseudo</p>
  
  <pre><code>snippet = Snippet.new(:content =&gt; params[:content])
  </code></pre>
  
  <p>then be able to call that back and display back on editor in the right format </p>
  
  <pre><code>snippet.content (preserves linebreaks) 
  </code></pre>
  
  <p>Full code and images <a href="https://docs.google.com/document/d/1M1bbWzEA9hDKKGosaa6OPqLCnEaXcI_6z6y7qQisVHk/edit?usp=sharing" rel="nofollow noreferrer">HERE</a> if you rather visuals.
  Any help would be appreciated and if there is anything I'm missing out please let me know.. hope I've supplied sufficient info and detailed properly. </p>