Accepting html line breaks <br> on custom pages

Hi,

if I create custom pages and try to format the text with normal line breaks (with Shift+Enter - not a paragraph) the view doesn’t render it correctly.

I guess it’s somewhere in wysiwyg_sanitizer.rb or admin_wysiwyg_sanitizer.rb, where allowed tags are defined. These files have no “custom” possibility. What would be the best solution to allow <br> also?

Hi, @Jan :smile:.

As you mention, customizing files under the lib/ folder is tricky. You can change the config/application.rb file and add config.autoload_paths << Rails.root.join("lib/custom") before the line saying config.autoload_paths << Rails.root.join("lib").

Then you can create a file in lib/custom/admin_wysiwyg_sanitizer.rb with the following content:

require_dependency Rails.root.join("lib", "admin_wysiwyg_sanitizer").to_s

class AdminWYSIWYGSanitizer
  alias_method :consul_allowed_tags, :allowed_tags

  def allowed_tags
    consul_allowed_tags + ["br"]
  end
end

Having said that, the reason why the <br> tag isn’t allowed by default is that, although it has some usages, like splitting the lines of a poem, it’s very rare to find these usages in the context of CONSUL.

Thank you very much,