Commit 2398af9ab03e79f807c5e989cd25aafe0799a61e
1 parent
cec866a7
Exists in
master
and in
4 other branches
Fixed wierd gitlab markdown issue
Showing
2 changed files
with
12 additions
and
5 deletions
Show diff stats
lib/redcarpet/render/gitlab_html.rb
| ... | ... | @@ -13,10 +13,17 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML |
| 13 | 13 | options = { options: {encoding: 'utf-8'} } |
| 14 | 14 | options.merge!(lexer: language.downcase) if Pygments::Lexer.find(language) |
| 15 | 15 | |
| 16 | + # New lines are placed to fix an rendering issue | |
| 17 | + # with code wrapped inside <h1> tag for next case: | |
| 18 | + # | |
| 19 | + # # Title kinda h1 | |
| 20 | + # | |
| 21 | + # ruby code here | |
| 22 | + # | |
| 16 | 23 | <<-HTML |
| 17 | - <div class="#{h.user_color_scheme_class}"> | |
| 18 | - #{Pygments.highlight(code, options)} | |
| 19 | - </div> | |
| 24 | + | |
| 25 | + <div class="#{h.user_color_scheme_class}">#{Pygments.highlight(code, options)}</div> | |
| 26 | + | |
| 20 | 27 | HTML |
| 21 | 28 | end |
| 22 | 29 | ... | ... |
spec/helpers/gitlab_markdown_helper_spec.rb
| ... | ... | @@ -331,9 +331,9 @@ describe GitlabMarkdownHelper do |
| 331 | 331 | it "should leave code blocks untouched" do |
| 332 | 332 | helper.stub(:user_color_scheme_class).and_return(:white) |
| 333 | 333 | |
| 334 | - helper.markdown("\n some code from $#{snippet.id}\n here too\n").should == "<div class=\"white\"><div class=\"highlight\"><pre><span class=\"n\">some</span> <span class=\"n\">code</span> <span class=\"n\">from</span> $#{snippet.id}\n<span class=\"n\">here</span> <span class=\"n\">too</span>\n</pre></div></div>" | |
| 334 | + helper.markdown("\n some code from $#{snippet.id}\n here too\n").should include("<div class=\"white\"><div class=\"highlight\"><pre><span class=\"n\">some</span> <span class=\"n\">code</span> <span class=\"n\">from</span> $#{snippet.id}\n<span class=\"n\">here</span> <span class=\"n\">too</span>\n</pre></div></div>") | |
| 335 | 335 | |
| 336 | - helper.markdown("\n```\nsome code from $#{snippet.id}\nhere too\n```\n").should == "<div class=\"white\"><div class=\"highlight\"><pre><span class=\"n\">some</span> <span class=\"n\">code</span> <span class=\"n\">from</span> $#{snippet.id}\n<span class=\"n\">here</span> <span class=\"n\">too</span>\n</pre></div></div>" | |
| 336 | + helper.markdown("\n```\nsome code from $#{snippet.id}\nhere too\n```\n").should include("<div class=\"white\"><div class=\"highlight\"><pre><span class=\"n\">some</span> <span class=\"n\">code</span> <span class=\"n\">from</span> $#{snippet.id}\n<span class=\"n\">here</span> <span class=\"n\">too</span>\n</pre></div></div>") | |
| 337 | 337 | end |
| 338 | 338 | |
| 339 | 339 | it "should leave inline code untouched" do | ... | ... |