blob: 861dd118d6933f6b056d812ec65b5b01af346f7c (
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
|
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)
options = { fenced_code_blocks: true, highlight: true }
Redcarpet::Markdown.new(HTML.new(), options).render(text).html_safe
end
end
|