module StringToHtmlHelper def string_to_html(str) html_formatted = simple_format(str) with_links = html_formatted.gsub(URI.regexp, '\0') sanitize(with_links, attributes: %w(href target)) end end