Commit 9cb51c6ea29660bfd3cca8fd4e64090cf2d5ac6e

Authored by Dmitriy Zaporozhets
2 parents 9c76bd95 c437e2d7

Merge branch 'use_redcarpet_for_markdown' of https://github.com/arthurschreiber/…

…gitlabhq into arthurschreiber-use_redcarpet_for_markdown

Conflicts:
	Gemfile
	Gemfile.lock
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
1 1 module WikisHelper
2   - def markdown_to_html(text)
3   - RDiscount.new(text).to_html.html_safe
4   - end
5 2 end
... ...
app/views/wikis/show.html.haml
... ... @@ -9,7 +9,7 @@
9 9 %hr
10 10 .wiki_content
11 11 = preserve do
12   - = markdown_to_html @wiki.content
  12 + = markdown @wiki.content
13 13  
14 14 %p.time Last edited by #{@wiki.user.name}, in #{time_ago_in_words @wiki.created_at}
15 15 - if can? current_user, :admin_wiki, @project
... ...
lib/redcarpet/render/gitlab_html.rb 0 → 100644
... ... @@ -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
... ...