Permalink
Browse files

fixed \#268 \#269: broken rule of autolink replacement

  • Loading branch information...
1 parent 4e15c6f commit e46be2f09f1dd8cc25a1f6eda6cc6a36de8eeb0a @hsbt hsbt committed Mar 20, 2013
Showing with 33 additions and 2 deletions.
  1. +1 −1 misc/style/gfm/gfm_style.rb
  2. +32 −1 spec/core/style/gfm_style_spec.rb
@@ -103,7 +103,7 @@ def to_html(string)
# ignore duplicate autolink
if r =~ /<a href="<a href="/
- r.gsub!(/<a href="(.*?)" rel="nofollow">.*?<\/a>/){ $1 }
+ r.gsub!(/<a href="<a href=".*?" rel="nofollow">(.*?)<\/a>">(.*?)<\/a>/){ "<a href=\"#{$1}\" rel=\"nofollow\">#{$2}</a>" }
end
# emoji
@@ -99,6 +99,37 @@
it { @diary.to_html.should eq @html }
end
+ describe 'autolink' do
+ before do
+ source = <<-EOF
+# subTitle
+
+ * http://www.google.com
+
+[google](https://www.google.com)
+
+http://www.google.com
+ EOF
+ @diary.append(source)
+ @html = <<-EOF
+<div class="section">
+<%=section_enter_proc( Time.at( 1041346800 ) )%>
+<h3><%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %></h3>
+<ul>
+<li><a href="http://www.google.com" rel="nofollow">http://www.google.com</a></li>
+</ul>
+
+<p><a href="https://www.google.com" rel="nofollow">google</a></p>
+
+<p><a href="http://www.google.com" rel="nofollow">http://www.google.com</a></p>
+<%=section_leave_proc( Time.at( 1041346800 ) )%>
+</div>
+ EOF
+ end
+
+ it { @diary.to_html.should eq @html }
+ end
+
describe 'url syntax with code blocks' do
before do
source = <<-'EOF'
@@ -141,7 +172,7 @@
<div class="section">
<%=section_enter_proc( Time.at( 1041346800 ) )%>
<h3><%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %></h3>
-<p><a href="http://example.com">example</a> is example.com</p>
+<p><a href="http://example.com" rel="nofollow">example</a> is example.com</p>
<%=section_leave_proc( Time.at( 1041346800 ) )%>
</div>
EOF

0 comments on commit e46be2f

Please sign in to comment.