Search code examples
javascriptruby-on-railsruby-on-rails-4redactorredactor.js

Rails Redactor Gem, rich text editor adding annoying 'br' tags


Trying to use this gem, and I've got it installed correctly, however, it always adds <br> tags and I'm trying to figure out how to remove it.

$('.redactor-go').redactor 
  'buttonHide': ['image'],
  'deniedTags': ['br']

I tried something like this above, but it doesn't work. Am I doing this wrong?


Solution

  • I found a workaround using .gsub and regex...

    = auto_link(@user.notes.html_safe.gsub(/<br\s*\/?>/, ""),html: { target: '_blank' } )
    

    I believe this eliminates all br tags: <br>, <br />, <br/>