Commit c437e2d7d416dae73efdea248a34b452d912986e
1 parent
9ee34575
Exists in
master
and in
4 other branches
Switch to Redcarpet for Markdown Rendering.
This gives us Github Flavored Markdown, which is awesome.
Showing
7 changed files
with
30 additions
and
13 deletions
Show diff stats
Gemfile
... | ... | @@ -18,12 +18,12 @@ gem "six" |
18 | 18 | gem "therubyracer" |
19 | 19 | gem "faker" |
20 | 20 | gem "seed-fu" |
21 | -gem "pygments.rb", "0.2.7" | |
21 | +gem "pygments.rb", "~> 0.2.11" | |
22 | +gem "redcarpet", "~> 2.1.1" | |
22 | 23 | gem "thin" |
23 | 24 | gem "unicorn" |
24 | 25 | gem "git" |
25 | 26 | gem "acts_as_list" |
26 | -gem "rdiscount" | |
27 | 27 | gem "acts-as-taggable-on", "~> 2.1.0" |
28 | 28 | gem "drapper" |
29 | 29 | gem "resque", "~> 1.20.0" | ... | ... |
Gemfile.lock
... | ... | @@ -169,7 +169,7 @@ GEM |
169 | 169 | coderay (~> 1.0.5) |
170 | 170 | method_source (~> 0.7) |
171 | 171 | slop (>= 2.4.4, < 3) |
172 | - pygments.rb (0.2.7) | |
172 | + pygments.rb (0.2.11) | |
173 | 173 | rubypython (~> 0.5.3) |
174 | 174 | pyu-ruby-sasl (0.0.3.3) |
175 | 175 | rack (1.4.1) |
... | ... | @@ -200,9 +200,9 @@ GEM |
200 | 200 | thor (~> 0.14.6) |
201 | 201 | raindrops (0.8.0) |
202 | 202 | rake (0.9.2.2) |
203 | - rdiscount (1.6.8) | |
204 | 203 | rdoc (3.12) |
205 | 204 | json (~> 1.4) |
205 | + redcarpet (2.1.1) | |
206 | 206 | redis (2.2.2) |
207 | 207 | redis-namespace (1.0.3) |
208 | 208 | redis (< 3.0.0) |
... | ... | @@ -330,11 +330,11 @@ DEPENDENCIES |
330 | 330 | mysql2 |
331 | 331 | omniauth-ldap |
332 | 332 | pry |
333 | - pygments.rb (= 0.2.7) | |
333 | + pygments.rb (~> 0.2.11) | |
334 | 334 | rails (= 3.2.1) |
335 | 335 | rails-footnotes |
336 | 336 | rake |
337 | - rdiscount | |
337 | + redcarpet (~> 2.1.1) | |
338 | 338 | resque (~> 1.20.0) |
339 | 339 | rspec-rails |
340 | 340 | 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 | ... | ... |