In my form, I'm copying the content of a contenteditable `div` into a hidden field, which gets sent to the db.

```
<%= form_for(@comment, remote: true) do |f| %>
    <%= f.hidden_field :content, class: 'js-NewCommentContentShadow' %>
    <div class="js-NewCommentContentField" contenteditable="true"></div>
<% end %>

```

I'm rendering that data in the view like this

```
<div><%=raw comment.content %></div>

```

The problem is, pressing the enter key outputs this line break

```
<div>
    <br>
</div>

```

You can add multiple line breaks consecutively, which is fine. But at some point, I'd like to strip all consecutive line breaks, so just a single line break is allowed before or after text.

That can happen as the contenteditable content is being copied to the shadow input, or as the form is submitted, or in the view somehow...I'm not fussy.

Here are some examples of how I want to affect the output:

This:

```
Some text
<div>
  <br>
</div>
Some more text

```

is fine and should be left as it is.

This:

```
Some text
<div>
  <br>
</div>
<div>
  <br>
</div>
Some more text

```

should be changed to

```
Some text
<div>
  <br>
</div>
Some more text

```

This:

```
Some text
<div>
  <br>
</div>
<div>
  <br>
</div>
<div>
  <br>
</div>

```

should be changed to:

```
Some text

```