diff --git a/config/initializers/sanitization.rb b/config/initializers/sanitization.rb
index 8b602bcb4..a4e712142 100644
--- a/config/initializers/sanitization.rb
+++ b/config/initializers/sanitization.rb
@@ -1,3 +1,4 @@
Rails.application.config.after_initialize do
Rails::HTML5::SafeListSanitizer.allowed_tags.merge(%w[ s table tr td th thead tbody details summary ])
+ Rails::HTML5::SafeListSanitizer.allowed_attributes.merge(%w[ data-turbo-frame ])
end
diff --git a/lib/markdown_renderer.rb b/lib/markdown_renderer.rb
index 6f466434c..df9070bd5 100644
--- a/lib/markdown_renderer.rb
+++ b/lib/markdown_renderer.rb
@@ -36,9 +36,28 @@ class MarkdownRenderer < Redcarpet::Render::HTML
block_code(code, language) # call Rouge Redcarpet plugin
end
+ def link(url, title, content)
+ attributes = { href: url }
+ attributes[:title] = title if title
+ attributes["data-turbo-frame"] = "_top"
+
+ "#{content}"
+ end
+
+ def autolink(url, link_type)
+ attributes = { href: url }
+ attributes["data-turbo-frame"] = "_top"
+
+ "#{url}"
+ end
+
private
attr_reader :id_counts
+ def html_attributes(attributes)
+ attributes.map { |key, value| %Q(#{key}="#{value}") }.join(" ")
+ end
+
def unique_id(text)
text.parameterize.then do |base_id|
id_counts[base_id] += 1