blob: 14d56cf1fe23ae1e501b47ae6bb2bcc123945368 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
require 'redcarpet'
require 'rouge'
require 'rouge/plugins/redcarpet'
module ApplicationHelper
class HTML < Redcarpet::Render::HTML
include Rouge::Plugins::Redcarpet # yep, that's it.
end
def title(text)
content_for :title, text
end
def sortable(col, title = nil)
title ||= col.titleize
css_class = (col == sort_column) ? "current #{sort_direction}" : nil
direction = (col == sort_column and sort_direction == "asc") ? "desc" : "asc"
link_to title, {:sort => col, :dir => direction}, {:class => css_class}
end
def markdown(text, params = {})
options = { fenced_code_blocks: true, highlight: true }
html_options = {}
if params[:restricted]
html_options[:filter_html] = true
end
Redcarpet::Markdown.new(HTML.new(html_options), options).render(text).html_safe
end
end
|