Skip to content

Commit

Permalink
Merge branch 'use_redcarpet_for_markdown' of https://github.com/arthu…
Browse files Browse the repository at this point in the history
…rschreiber/gitlabhq into arthurschreiber-use_redcarpet_for_markdown

Conflicts:
	Gemfile
	Gemfile.lock
  • Loading branch information
dzaporozhets committed Apr 20, 2012
2 parents 9c76bd9 + c437e2d commit 9cb51c6
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions app/assets/stylesheets/highlight.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ td.linenos{
vertical-align:top;
}

.highlight{
.highlighttable .highlight{
background:none;
padding:10px 0px 0px 10px;
margin-left:0px;
Expand All @@ -31,7 +31,7 @@ td.linenos{
}

.linenodiv pre,
.highlight pre{
.highlighttable .highlight pre{
margin:0;
padding:0;
background:none;
Expand Down
13 changes: 12 additions & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,18 @@ def grouped_options_refs(destination = :tree)
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
Expand Down
3 changes: 0 additions & 3 deletions app/helpers/wikis_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
module WikisHelper
def markdown_to_html(text)
RDiscount.new(text).to_html.html_safe
end
end
2 changes: 1 addition & 1 deletion app/views/wikis/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions lib/redcarpet/render/gitlab_html.rb
Original file line number Diff line number Diff line change
@@ -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

5 comments on commit 9cb51c6

@ariejan
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@randx You forgot something:

$ grep -iR RDiscount *
app/views/notify/note_wall_email.html.haml:                  = RDiscount.new(@note.note, :autolink, :no_pseudo_protocols, :safelink, :smart, :filter_html).to_html.html_safe
app/views/notify/note_merge_request_email.html.haml:                  = RDiscount.new(@note.note, :autolink, :no_pseudo_protocols, :safelink, :smart, :filter_html).to_html.html_safe
app/views/notify/note_commit_email.html.haml:                  = RDiscount.new(@note.note, :autolink, :no_pseudo_protocols, :safelink, :smart, :filter_html).to_html.html_safe
app/views/notify/note_issue_email.html.haml:                  = RDiscount.new(@note.note, :autolink, :no_pseudo_protocols, :safelink, :smart, :filter_html).to_html.html_safe

This currently breaks adding notes with the 'notify team' options selected.

@dzaporozhets
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f*ck. Can you fix it? We definitely should make a 2.4.1 release

@ariejan
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't get to my dev machine today, tomorrow evening soonest. Maybe @arthurschreiber can help out? It's his code anyway :)

@dzaporozhets
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know. But i dont want to wait. its a bad thing. I'll handle it

@ariejan
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

Please sign in to comment.