2018-05-24 18:01:40 +02:00
|
|
|
module StringToHtmlHelper
|
2019-11-06 16:30:20 +01:00
|
|
|
def string_to_html(str, wrapper_tag = 'p')
|
|
|
|
html_formatted = simple_format(str, {}, { wrapper_tag: wrapper_tag })
|
2019-03-05 18:16:13 +01:00
|
|
|
with_links = html_formatted.gsub(URI.regexp, '<a target="_blank" rel="noopener" href="\0">\0</a>')
|
|
|
|
sanitize(with_links, attributes: ['target', 'rel', 'href'])
|
2018-05-24 18:01:40 +02:00
|
|
|
end
|
|
|
|
end
|