2022-01-16 22:13:41 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-12-28 19:06:49 +01:00
|
|
|
class FlavoredMarkdown < Redcarpet::Render::HTML
|
|
|
|
include Rails.application.routes.url_helpers
|
2021-12-30 18:13:52 +01:00
|
|
|
include SharedMarkers
|
2014-12-28 19:06:49 +01:00
|
|
|
|
|
|
|
def preprocess(text)
|
|
|
|
wrap_mentions(text)
|
|
|
|
end
|
|
|
|
|
|
|
|
def wrap_mentions(text)
|
2022-01-16 22:13:41 +01:00
|
|
|
text.gsub(/(^|\s)(@[a-zA-Z0-9_]{1,16})/) do
|
2022-07-23 12:06:05 +02:00
|
|
|
"#{$1}[#{$2}](#{user_path $2.tr('@', '')})"
|
2014-12-28 19:06:49 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def header(text, _header_level)
|
2023-02-19 18:26:17 +01:00
|
|
|
"<p>#{text}</p>"
|
2014-12-28 19:06:49 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def raw_html(raw_html)
|
|
|
|
Rack::Utils.escape_html raw_html
|
|
|
|
end
|
2014-12-31 16:02:34 +01:00
|
|
|
end
|