Retrospring/app/services/flavored_markdown.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
479 B
Ruby
Raw Normal View History

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