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 | 20 | gem "seed-fu" |
| 21 | 21 | gem "linguist", "~> 1.0.0", :git => "https://github.com/github/linguist.git" |
| 22 | 22 | gem "pygments.rb", "0.2.11" |
| 23 | +gem "redcarpet", "~> 2.1.1" | |
| 23 | 24 | gem "thin" |
| 24 | 25 | gem "unicorn" |
| 25 | 26 | gem "git" |
| 26 | 27 | gem "acts_as_list" |
| 27 | -gem "rdiscount" | |
| 28 | 28 | gem "acts-as-taggable-on", "~> 2.1.0" |
| 29 | 29 | gem "drapper" |
| 30 | 30 | gem "resque", "~> 1.20.0" | ... | ... |
Gemfile.lock
| ... | ... | @@ -211,9 +211,9 @@ GEM |
| 211 | 211 | thor (~> 0.14.6) |
| 212 | 212 | raindrops (0.8.0) |
| 213 | 213 | rake (0.9.2.2) |
| 214 | - rdiscount (1.6.8) | |
| 215 | 214 | rdoc (3.12) |
| 216 | 215 | json (~> 1.4) |
| 216 | + redcarpet (2.1.1) | |
| 217 | 217 | redis (2.2.2) |
| 218 | 218 | redis-namespace (1.0.3) |
| 219 | 219 | redis (< 3.0.0) |
| ... | ... | @@ -346,7 +346,7 @@ DEPENDENCIES |
| 346 | 346 | rails (= 3.2.1) |
| 347 | 347 | rails-footnotes |
| 348 | 348 | rake |
| 349 | - rdiscount | |
| 349 | + redcarpet (~> 2.1.1) | |
| 350 | 350 | resque (~> 1.20.0) |
| 351 | 351 | rspec-rails |
| 352 | 352 | sass-rails (= 3.2.3) | ... | ... |
app/assets/stylesheets/highlight.scss
| ... | ... | @@ -22,7 +22,7 @@ td.linenos{ |
| 22 | 22 | vertical-align:top; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -.highlight{ | |
| 25 | +.highlighttable .highlight{ | |
| 26 | 26 | background:none; |
| 27 | 27 | padding:10px 0px 0px 10px; |
| 28 | 28 | margin-left:0px; |
| ... | ... | @@ -31,7 +31,7 @@ td.linenos{ |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | .linenodiv pre, |
| 34 | -.highlight pre{ | |
| 34 | +.highlighttable .highlight pre{ | |
| 35 | 35 | margin:0; |
| 36 | 36 | padding:0; |
| 37 | 37 | background:none; | ... | ... |
app/helpers/application_helper.rb
| ... | ... | @@ -72,7 +72,18 @@ module ApplicationHelper |
| 72 | 72 | end |
| 73 | 73 | |
| 74 | 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 | 87 | end |
| 77 | 88 | |
| 78 | 89 | def search_autocomplete_source | ... | ... |
app/helpers/wikis_helper.rb
app/views/wikis/show.html.haml
| ... | ... | @@ -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 | 10 | \ No newline at end of file | ... | ... |