Comments
-
Greg Hurrell
Status changed:
- From: New
- To: Open
-
Greg Hurrell
At the same time as fixing the class, probably makes sense to fix up the linked text as well.
ie. Note how we given:
mailto:user@example.com
We produce:
<a href="mailto:user@example.com">mailto:user@example.com</a>
When it would perhaps be nicer if we produced:
<a href="mailto:user@example.com">user@example.com</a>
Another possibility is that we could also (or instead) start accepting input like:
[user@example.com email me]
Not sure if that is too lax and could lead to false positives, though.
-
Greg Hurrell
Bah; I wasn't thinking to clearly late last night when I wrote that comment. On reflecting further on the desirable behaviour today I've come up with the following changes to the spec suite:
diff --git a/spec/autolinking_spec.rb b/spec/autolinking_spec.rb index 382a93c..743ae46 100755 --- a/spec/autolinking_spec.rb +++ b/spec/autolinking_spec.rb @@ -1,5 +1,5 @@ #!/usr/bin/env ruby -# Copyright 2007-2008 Wincent Colaiuta +# Copyright 2007-2009 Wincent Colaiuta # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or @@ -43,7 +43,7 @@ describe Wikitext::Parser, 'autolinking' do it 'should convert mailto URIs into hyperlinks' do uri = 'mailto:user@example.com' - @parser.parse(uri).should == %Q{<p><a href="mailto:user@example.com" class="external">mailto:user@example.com</a></p>\n} + @parser.parse(uri).should == %Q{<p><a href="mailto:user@example.com" class="mailto">mailto:user@example.com</a></p>\n} end it 'should convert SVN URIs into hyperlinks' do @@ -81,18 +81,30 @@ describe Wikitext::Parser, 'autolinking' do @parser.parse(uri).should == %Q{<p><a href="mailto:user@example.com" class="mailto">user@example.com</a></p>\n} end - it 'should apply the mailto CSS class if set' do + it 'should apply the mailto CSS class if set (raw address)' do uri = 'user@example.com' @parser.mailto_class = 'foo' @parser.parse(uri).should == %Q{<p><a href="mailto:user@example.com" class="foo">user@example.com</a></p>\n} end - it 'should apply no CSS if the mailto class is set to nil' do + it 'should apply the mailto CSS class if set (mailto URI)' do + uri = 'mailto:user@example.com' + @parser.mailto_class = 'foo' + @parser.parse(uri).should == %Q{<p><a href="mailto:user@example.com" class="foo">mailto:user@example.com</a></p>\n} + end + + it 'should apply no CSS if the mailto class is set to nil (raw address)' do uri = 'user@example.com' @parser.mailto_class = nil @parser.parse(uri).should == %Q{<p><a href="mailto:user@example.com">user@example.com</a></p>\n} end + it 'should apply no CSS if the mailto class is set to nil (mailto URI)' do + uri = 'mailto:user@example.com' + @parser.mailto_class = nil + @parser.parse(uri).should == %Q{<p><a href="mailto:user@example.com">mailto:user@example.com</a></p>\n} + end + it 'should pass through emails unchanged inside <nowiki></nowiki> spans' do @parser.parse("<nowiki>user@example.com</nowiki>").should == "<p>user@example.com</p>\n" # was a crasher end diff --git a/spec/external_link_spec.rb b/spec/external_link_spec.rb index caba9fa..275d679 100755 --- a/spec/external_link_spec.rb +++ b/spec/external_link_spec.rb @@ -43,12 +43,15 @@ describe Wikitext::Parser, 'external links' do end it 'should format valid external mailto links' do - # although note in this case the CSS class is "external" rather than "mailto" - # this is because we're matching this as a (generic) URI rather than an email address - expected = %Q{<p><a href="mailto:user@example.com" class="external">john</a></p>\n} + expected = %Q{<p><a href="mailto:user@example.com" class="mailto">john</a></p>\n} @parser.parse('[mailto:user@example.com john]').should == expected end + it 'should not treat raw email addresses as valid link targets' do + expected = %Q{<p>[<a href="mailto:user@example.com" class="mailto">user@example.com</a> john]</p>\n} + @parser.parse('[user@example.com john]').should == expected + end + it 'should format absolute path links' do expected = %Q{<p><a href="/foo/bar">fb</a></p>\n} # note no "external" class @parser.parse('[/foo/bar fb]').should == expected
Now working on implementing the necessary changes.
-
Greg Hurrell
Ok, this is now implemented. It will be in the next release (1.5.2).
-
Greg Hurrell
Status changed:
- From: Open
- To: Closed
Add a comment
Comments are now closed for this issue.