OSDN Git Service

Fixed wierd gitlab markdown issue
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Sat, 22 Dec 2012 12:18:40 +0000 (14:18 +0200)
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Sat, 22 Dec 2012 12:18:40 +0000 (14:18 +0200)
lib/redcarpet/render/gitlab_html.rb
spec/helpers/gitlab_markdown_helper_spec.rb

index 3c5ca1c..3a430e0 100644 (file)
@@ -13,10 +13,17 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
     options = { options: {encoding: 'utf-8'} }
     options.merge!(lexer: language.downcase) if Pygments::Lexer.find(language)
 
+    # New lines are placed to fix an rendering issue
+    # with code wrapped inside <h1> tag for next case:
+    #
+    # # Title kinda h1
+    #
+    #     ruby code here
+    #
     <<-HTML
-       <div class="#{h.user_color_scheme_class}">
-         #{Pygments.highlight(code, options)}
-       </div>
+
+       <div class="#{h.user_color_scheme_class}">#{Pygments.highlight(code, options)}</div>
+
     HTML
   end
 
index 1eafc66..f0b792f 100644 (file)
@@ -331,9 +331,9 @@ describe GitlabMarkdownHelper do
     it "should leave code blocks untouched" do
       helper.stub(:user_color_scheme_class).and_return(:white)
 
-      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>"
+      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>")
 
-      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>"
+      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>")
     end
 
     it "should leave inline code untouched" do