2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-11 12:40:12 +01:00
|
|
|
module HtmlToStringHelper
|
|
|
|
def html_to_string(html)
|
2017-12-12 10:06:50 +01:00
|
|
|
if html.blank?
|
|
|
|
html
|
|
|
|
else
|
|
|
|
string_with_tags = html
|
|
|
|
.gsub(/<br[ ]?[\/]?>/, "\n")
|
|
|
|
.gsub('</p>', "\n")
|
|
|
|
.gsub('<p>', '')
|
2017-12-11 12:40:12 +01:00
|
|
|
|
2017-12-12 10:06:50 +01:00
|
|
|
strip_tags(string_with_tags)
|
|
|
|
end
|
2017-12-11 12:40:12 +01:00
|
|
|
end
|
|
|
|
end
|