Commit c437e2d7 authored by Arthur Schreiber's avatar Arthur Schreiber

Switch to Redcarpet for Markdown Rendering.

This gives us Github Flavored Markdown, which is awesome.
parent 9ee34575
...@@ -18,12 +18,12 @@ gem "six" ...@@ -18,12 +18,12 @@ gem "six"
gem "therubyracer" gem "therubyracer"
gem "faker" gem "faker"
gem "seed-fu" gem "seed-fu"
gem "pygments.rb", "0.2.7" gem "pygments.rb", "~> 0.2.11"
gem "redcarpet", "~> 2.1.1"
gem "thin" gem "thin"
gem "unicorn" gem "unicorn"
gem "git" gem "git"
gem "acts_as_list" gem "acts_as_list"
gem "rdiscount"
gem "acts-as-taggable-on", "~> 2.1.0" gem "acts-as-taggable-on", "~> 2.1.0"
gem "drapper" gem "drapper"
gem "resque", "~> 1.20.0" gem "resque", "~> 1.20.0"
......
...@@ -169,7 +169,7 @@ GEM ...@@ -169,7 +169,7 @@ GEM
coderay (~> 1.0.5) coderay (~> 1.0.5)
method_source (~> 0.7) method_source (~> 0.7)
slop (>= 2.4.4, < 3) slop (>= 2.4.4, < 3)
pygments.rb (0.2.7) pygments.rb (0.2.11)
rubypython (~> 0.5.3) rubypython (~> 0.5.3)
pyu-ruby-sasl (0.0.3.3) pyu-ruby-sasl (0.0.3.3)
rack (1.4.1) rack (1.4.1)
...@@ -200,9 +200,9 @@ GEM ...@@ -200,9 +200,9 @@ GEM
thor (~> 0.14.6) thor (~> 0.14.6)
raindrops (0.8.0) raindrops (0.8.0)
rake (0.9.2.2) rake (0.9.2.2)
rdiscount (1.6.8)
rdoc (3.12) rdoc (3.12)
json (~> 1.4) json (~> 1.4)
redcarpet (2.1.1)
redis (2.2.2) redis (2.2.2)
redis-namespace (1.0.3) redis-namespace (1.0.3)
redis (< 3.0.0) redis (< 3.0.0)
...@@ -330,11 +330,11 @@ DEPENDENCIES ...@@ -330,11 +330,11 @@ DEPENDENCIES
mysql2 mysql2
omniauth-ldap omniauth-ldap
pry pry
pygments.rb (= 0.2.7) pygments.rb (~> 0.2.11)
rails (= 3.2.1) rails (= 3.2.1)
rails-footnotes rails-footnotes
rake rake
rdiscount redcarpet (~> 2.1.1)
resque (~> 1.20.0) resque (~> 1.20.0)
rspec-rails rspec-rails
sass-rails (= 3.2.3) sass-rails (= 3.2.3)
......
...@@ -22,7 +22,7 @@ td.linenos{ ...@@ -22,7 +22,7 @@ td.linenos{
vertical-align:top; vertical-align:top;
} }
.highlight{ .highlighttable .highlight{
background:none; background:none;
padding:10px 0px 0px 10px; padding:10px 0px 0px 10px;
margin-left:0px; margin-left:0px;
...@@ -31,7 +31,7 @@ td.linenos{ ...@@ -31,7 +31,7 @@ td.linenos{
} }
.linenodiv pre, .linenodiv pre,
.highlight pre{ .highlighttable .highlight pre{
margin:0; margin:0;
padding:0; padding:0;
background:none; background:none;
......
...@@ -72,7 +72,18 @@ module ApplicationHelper ...@@ -72,7 +72,18 @@ module ApplicationHelper
end end
def markdown(text) def markdown(text)
RDiscount.new(text, :autolink, :no_pseudo_protocols, :safelink, :smart, :filter_html).to_html.html_safe @__renderer ||= Redcarpet::Markdown.new(Redcarpet::Render::GitlabHTML.new(filter_html: true), {
no_intra_emphasis: true,
tables: true,
fenced_code_blocks: true,
autolink: true,
strikethrough: true,
lax_html_blocks: true,
space_after_headers: true,
superscript: true
})
@__renderer.render(text).html_safe
end end
def search_autocomplete_source def search_autocomplete_source
......
module WikisHelper module WikisHelper
def markdown_to_html(text)
RDiscount.new(text).to_html.html_safe
end
end end
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
%hr %hr
.wiki_content .wiki_content
= preserve do = preserve do
= markdown_to_html @wiki.content = markdown @wiki.content
%p.time Last edited by #{@wiki.user.name}, in #{time_ago_in_words @wiki.created_at} %p.time Last edited by #{@wiki.user.name}, in #{time_ago_in_words @wiki.created_at}
- if can? current_user, :admin_wiki, @project - if can? current_user, :admin_wiki, @project
......
class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
def block_code(code, language)
if Pygments::Lexer.find(language)
Pygments.highlight(code, :lexer => language)
else
Pygments.highlight(code)
end
end
end
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment