Commit 9cb51c6ea29660bfd3cca8fd4e64090cf2d5ac6e
Exists in
master
and in
4 other branches
Merge branch 'use_redcarpet_for_markdown' of https://github.com/arthurschreiber/…
…gitlabhq into arthurschreiber-use_redcarpet_for_markdown Conflicts: Gemfile Gemfile.lock
Showing
7 changed files
with
27 additions
and
10 deletions
Show diff stats
Gemfile
@@ -20,11 +20,11 @@ gem "faker" | @@ -20,11 +20,11 @@ gem "faker" | ||
20 | gem "seed-fu" | 20 | gem "seed-fu" |
21 | gem "linguist", "~> 1.0.0", :git => "https://github.com/github/linguist.git" | 21 | gem "linguist", "~> 1.0.0", :git => "https://github.com/github/linguist.git" |
22 | gem "pygments.rb", "0.2.11" | 22 | gem "pygments.rb", "0.2.11" |
23 | +gem "redcarpet", "~> 2.1.1" | ||
23 | gem "thin" | 24 | gem "thin" |
24 | gem "unicorn" | 25 | gem "unicorn" |
25 | gem "git" | 26 | gem "git" |
26 | gem "acts_as_list" | 27 | gem "acts_as_list" |
27 | -gem "rdiscount" | ||
28 | gem "acts-as-taggable-on", "~> 2.1.0" | 28 | gem "acts-as-taggable-on", "~> 2.1.0" |
29 | gem "drapper" | 29 | gem "drapper" |
30 | gem "resque", "~> 1.20.0" | 30 | gem "resque", "~> 1.20.0" |
Gemfile.lock
@@ -211,9 +211,9 @@ GEM | @@ -211,9 +211,9 @@ GEM | ||
211 | thor (~> 0.14.6) | 211 | thor (~> 0.14.6) |
212 | raindrops (0.8.0) | 212 | raindrops (0.8.0) |
213 | rake (0.9.2.2) | 213 | rake (0.9.2.2) |
214 | - rdiscount (1.6.8) | ||
215 | rdoc (3.12) | 214 | rdoc (3.12) |
216 | json (~> 1.4) | 215 | json (~> 1.4) |
216 | + redcarpet (2.1.1) | ||
217 | redis (2.2.2) | 217 | redis (2.2.2) |
218 | redis-namespace (1.0.3) | 218 | redis-namespace (1.0.3) |
219 | redis (< 3.0.0) | 219 | redis (< 3.0.0) |
@@ -346,7 +346,7 @@ DEPENDENCIES | @@ -346,7 +346,7 @@ DEPENDENCIES | ||
346 | rails (= 3.2.1) | 346 | rails (= 3.2.1) |
347 | rails-footnotes | 347 | rails-footnotes |
348 | rake | 348 | rake |
349 | - rdiscount | 349 | + redcarpet (~> 2.1.1) |
350 | resque (~> 1.20.0) | 350 | resque (~> 1.20.0) |
351 | rspec-rails | 351 | rspec-rails |
352 | sass-rails (= 3.2.3) | 352 | sass-rails (= 3.2.3) |
app/assets/stylesheets/highlight.scss
@@ -22,7 +22,7 @@ td.linenos{ | @@ -22,7 +22,7 @@ td.linenos{ | ||
22 | vertical-align:top; | 22 | vertical-align:top; |
23 | } | 23 | } |
24 | 24 | ||
25 | -.highlight{ | 25 | +.highlighttable .highlight{ |
26 | background:none; | 26 | background:none; |
27 | padding:10px 0px 0px 10px; | 27 | padding:10px 0px 0px 10px; |
28 | margin-left:0px; | 28 | margin-left:0px; |
@@ -31,7 +31,7 @@ td.linenos{ | @@ -31,7 +31,7 @@ td.linenos{ | ||
31 | } | 31 | } |
32 | 32 | ||
33 | .linenodiv pre, | 33 | .linenodiv pre, |
34 | -.highlight pre{ | 34 | +.highlighttable .highlight pre{ |
35 | margin:0; | 35 | margin:0; |
36 | padding:0; | 36 | padding:0; |
37 | background:none; | 37 | background:none; |
app/helpers/application_helper.rb
@@ -72,7 +72,18 @@ module ApplicationHelper | @@ -72,7 +72,18 @@ module ApplicationHelper | ||
72 | end | 72 | end |
73 | 73 | ||
74 | def markdown(text) | 74 | def markdown(text) |
75 | - RDiscount.new(text, :autolink, :no_pseudo_protocols, :safelink, :smart, :filter_html).to_html.html_safe | 75 | + @__renderer ||= Redcarpet::Markdown.new(Redcarpet::Render::GitlabHTML.new(filter_html: true), { |
76 | + no_intra_emphasis: true, | ||
77 | + tables: true, | ||
78 | + fenced_code_blocks: true, | ||
79 | + autolink: true, | ||
80 | + strikethrough: true, | ||
81 | + lax_html_blocks: true, | ||
82 | + space_after_headers: true, | ||
83 | + superscript: true | ||
84 | + }) | ||
85 | + | ||
86 | + @__renderer.render(text).html_safe | ||
76 | end | 87 | end |
77 | 88 | ||
78 | def search_autocomplete_source | 89 | def search_autocomplete_source |
app/helpers/wikis_helper.rb
app/views/wikis/show.html.haml
@@ -9,7 +9,7 @@ | @@ -9,7 +9,7 @@ | ||
9 | %hr | 9 | %hr |
10 | .wiki_content | 10 | .wiki_content |
11 | = preserve do | 11 | = preserve do |
12 | - = markdown_to_html @wiki.content | 12 | + = markdown @wiki.content |
13 | 13 | ||
14 | %p.time Last edited by #{@wiki.user.name}, in #{time_ago_in_words @wiki.created_at} | 14 | %p.time Last edited by #{@wiki.user.name}, in #{time_ago_in_words @wiki.created_at} |
15 | - if can? current_user, :admin_wiki, @project | 15 | - if can? current_user, :admin_wiki, @project |
@@ -0,0 +1,9 @@ | @@ -0,0 +1,9 @@ | ||
1 | +class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML | ||
2 | + def block_code(code, language) | ||
3 | + if Pygments::Lexer.find(language) | ||
4 | + Pygments.highlight(code, :lexer => language) | ||
5 | + else | ||
6 | + Pygments.highlight(code) | ||
7 | + end | ||
8 | + end | ||
9 | +end | ||
0 | \ No newline at end of file | 10 | \ No newline at end of file |