2014-12-28 10:06:49 -08:00
|
|
|
class FlavoredMarkdown < Redcarpet::Render::HTML
|
|
|
|
include Rails.application.routes.url_helpers
|
2021-12-30 09:13:52 -08:00
|
|
|
include SharedMarkers
|
2014-12-28 10:06:49 -08:00
|
|
|
|
|
|
|
def preprocess(text)
|
|
|
|
wrap_mentions(text)
|
|
|
|
end
|
|
|
|
|
|
|
|
def wrap_mentions(text)
|
2014-12-31 07:02:34 -08:00
|
|
|
text.gsub! /(^|\s)(@[a-zA-Z0-9_]{1,16})/ do
|
2014-12-28 10:06:49 -08:00
|
|
|
"#{$1}[#{$2}](#{show_user_profile_path $2.tr('@', '')})"
|
|
|
|
end
|
|
|
|
text
|
|
|
|
end
|
|
|
|
|
|
|
|
def header(text, _header_level)
|
|
|
|
paragraph text
|
|
|
|
end
|
|
|
|
|
|
|
|
def paragraph(text)
|
|
|
|
"<p>#{text}</p>"
|
|
|
|
end
|
|
|
|
|
|
|
|
def raw_html(raw_html)
|
|
|
|
Rack::Utils.escape_html raw_html
|
|
|
|
end
|
2014-12-31 07:02:34 -08:00
|
|
|
end
|