demarches-normaliennes/app/helpers/string_to_html_helper.rb
Pierre de La Morinerie af5b36ea6a helpers: prevent some texts to be incorrectly detected as links
Users were having issues with texts like:

> Pour info: penser à faire cette action.

where `info:` was detected as being an URI.
2020-06-22 14:42:41 +02:00

7 lines
314 B
Ruby

module StringToHtmlHelper
def string_to_html(str, wrapper_tag = 'p')
html_formatted = simple_format(str, {}, { wrapper_tag: wrapper_tag })
with_links = Anchored::Linker.auto_link(html_formatted, target: '_blank', rel: 'noopener')
sanitize(with_links, attributes: ['target', 'rel', 'href'])
end
end