diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-04-21 01:44:15 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-04-21 01:44:15 +0300 |
commit | 9cb51c6ea29660bfd3cca8fd4e64090cf2d5ac6e (patch) | |
tree | b49dcab12fb154963a54addd41728465c38ba29e | |
parent | 9c76bd95402dfb4fa49cca4876c9714f408c5122 (diff) | |
parent | c437e2d7d416dae73efdea248a34b452d912986e (diff) | |
download | gitlab-ce-9cb51c6ea29660bfd3cca8fd4e64090cf2d5ac6e.tar.gz |
Merge branch 'use_redcarpet_for_markdown' of https://github.com/arthurschreiber/gitlabhq into arthurschreiber-use_redcarpet_for_markdown
Conflicts:
Gemfile
Gemfile.lock
-rw-r--r-- | Gemfile | 2 | ||||
-rw-r--r-- | Gemfile.lock | 4 | ||||
-rw-r--r-- | app/assets/stylesheets/highlight.scss | 4 | ||||
-rw-r--r-- | app/helpers/application_helper.rb | 13 | ||||
-rw-r--r-- | app/helpers/wikis_helper.rb | 3 | ||||
-rw-r--r-- | app/views/wikis/show.html.haml | 2 | ||||
-rw-r--r-- | lib/redcarpet/render/gitlab_html.rb | 9 |
7 files changed, 27 insertions, 10 deletions
@@ -20,11 +20,11 @@ gem "faker" gem "seed-fu" gem "linguist", "~> 1.0.0", :git => "https://github.com/github/linguist.git" gem "pygments.rb", "0.2.11" +gem "redcarpet", "~> 2.1.1" gem "thin" gem "unicorn" gem "git" gem "acts_as_list" -gem "rdiscount" gem "acts-as-taggable-on", "~> 2.1.0" gem "drapper" gem "resque", "~> 1.20.0" diff --git a/Gemfile.lock b/Gemfile.lock index c852a8bd420..12d0ddd609f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -211,9 +211,9 @@ GEM thor (~> 0.14.6) raindrops (0.8.0) rake (0.9.2.2) - rdiscount (1.6.8) rdoc (3.12) json (~> 1.4) + redcarpet (2.1.1) redis (2.2.2) redis-namespace (1.0.3) redis (< 3.0.0) @@ -346,7 +346,7 @@ DEPENDENCIES rails (= 3.2.1) rails-footnotes rake - rdiscount + redcarpet (~> 2.1.1) resque (~> 1.20.0) rspec-rails sass-rails (= 3.2.3) diff --git a/app/assets/stylesheets/highlight.scss b/app/assets/stylesheets/highlight.scss index 0dbfc0ed964..8f71c4f57f2 100644 --- a/app/assets/stylesheets/highlight.scss +++ b/app/assets/stylesheets/highlight.scss @@ -22,7 +22,7 @@ td.linenos{ vertical-align:top; } -.highlight{ +.highlighttable .highlight{ background:none; padding:10px 0px 0px 10px; margin-left:0px; @@ -31,7 +31,7 @@ td.linenos{ } .linenodiv pre, -.highlight pre{ +.highlighttable .highlight pre{ margin:0; padding:0; background:none; diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0edd3125ee1..92f1680ef1f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -72,7 +72,18 @@ module ApplicationHelper end 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 def search_autocomplete_source diff --git a/app/helpers/wikis_helper.rb b/app/helpers/wikis_helper.rb index 0c24f57add6..bb168351b2a 100644 --- a/app/helpers/wikis_helper.rb +++ b/app/helpers/wikis_helper.rb @@ -1,5 +1,2 @@ module WikisHelper - def markdown_to_html(text) - RDiscount.new(text).to_html.html_safe - end end diff --git a/app/views/wikis/show.html.haml b/app/views/wikis/show.html.haml index 8ac4994a1b3..e7f879f9cec 100644 --- a/app/views/wikis/show.html.haml +++ b/app/views/wikis/show.html.haml @@ -9,7 +9,7 @@ %hr .wiki_content = 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} - if can? current_user, :admin_wiki, @project diff --git a/lib/redcarpet/render/gitlab_html.rb b/lib/redcarpet/render/gitlab_html.rb new file mode 100644 index 00000000000..29be478052a --- /dev/null +++ b/lib/redcarpet/render/gitlab_html.rb @@ -0,0 +1,9 @@ +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 |