a11yist/app/helpers/pdf_helper.rb
david 63fc206c27
Some checks failed
/ Run tests (push) Successful in 8m56s
/ Run system tests (push) Failing after 1h0m48s
/ Build, push and deploy image (push) Successful in 7m47s
A lot :)
2024-09-05 22:54:38 +02:00

19 lines
541 B
Ruby

# frozen_string_literal: true
module PdfHelper
def prepare_rich_text(rich_text)
return rich_text
{ del: "strikethrough" }.each do |tag, replacement|
rich_text = rich_text.to_s.gsub("<#{tag}", "<#{replacement}")
rich_text = rich_text.to_s.gsub("</#{tag}>", "</#{replacement}>")
end
%w[div p del blockquote pre code].each do |tag|
rich_text = rich_text.to_s.gsub(%r{<#{tag}.*?>|</#{tag}>}, "")
end
rich_text.gsub!(/<h1.*?>/, "")
rich_text.gsub!(%r{</h1>}, "<br><br>")
rich_text
end
end