Defect #20841

Bare URLs in Markdown don't have "external" class

Added by Go MAEDA over 4 years ago. Updated over 1 year ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Text formatting
Target version:-
Resolution: Affected version:

Description

expected:
http://www.redmine.org/ =>
<a href="http://www.redmine.org/" class="external">http://www.redmine.org/</a>

actual:
http://www.redmine.org/ =>
<a href="http://www.redmine.org/">http://www.redmine.org/</a>

No problem in Textile formatter. Probably all versions that support Markdown are affected.


Related issues

Related to Redmine - Patch #32424: CommonMark Markdown Text Formatting New
Blocks Redmine - Feature #1151: Open Links in New-Window New 2008-05-01

History

#1 Updated by Go MAEDA over 4 years ago

#2 Updated by Go MAEDA over 1 year ago

  • Target version set to Candidate for next minor release

The following patch fixes this issue.

Index: lib/redmine/wiki_formatting/markdown/formatter.rb
===================================================================
--- lib/redmine/wiki_formatting/markdown/formatter.rb    (revision 17445)
+++ lib/redmine/wiki_formatting/markdown/formatter.rb    (working copy)
@@ -123,7 +123,8 @@
           @@formatter ||= Redcarpet::Markdown.new(
             Redmine::WikiFormatting::Markdown::HTML.new(
               :filter_html => true,
-              :hard_wrap => true
+              :hard_wrap => true,
+              :link_attributes => {:class => 'external'}
             ),
             :autolink => true,
             :fenced_code_blocks => true,

#3 Updated by Go MAEDA over 1 year ago

  • Subject changed from No "external" class when bare url is used in Markdown formatter to Bare URLs in Markdown don't have "external" class

Go MAEDA wrote:

The following patch fixes this issue.

Unfortunately, it breaks some tests.

Failure:
ApplicationHelperTest#test_attachment_links_to_images_with_email_format_should_not_be_parsed [test/helpers/application_helper_test.rb:709]:
Expected /<p><a class="attachment" href="\/attachments\/75">image@2x.png<\/a> should not be parsed in image@2x.png<\/p>/ to match "<p><a class=\"attachment\" href=\"/attachments/75\">image@2x.png</a>\" class=\"external should not be parsed in <a href=\"mailto:image@2x.png\" class=\"external\">image@2x.png</a></p>\n".

bin/rails test test/helpers/application_helper_test.rb:698

.................................F

Failure:
ApplicationHelperTest#test_user_links_with_email_as_login_name_should_not_be_parsed_markdown [test/helpers/application_helper_test.rb:430]:
Expected /<p><a class=\"user active\".*>Bob Doe<\/a> should not be parsed in <a href=\"mailto:jsmith@somenet.foo\">jsmith@somenet.foo<\/a><\/p>/ to match "<p><a class=\"user active\" href=\"/users/14\">Bob Doe</a>\" class=\"external should not be parsed in <a href=\"mailto:jsmith@somenet.foo\" class=\"external\">jsmith@somenet.foo</a></p>\n".

bin/rails test test/helpers/application_helper_test.rb:424

#4 Updated by Go MAEDA over 1 year ago

  • Target version deleted (Candidate for next minor release)

#5 Updated by Jan from Planio www.plan.io 5 months ago

  • Related to Patch #32424: CommonMark Markdown Text Formatting added

Also available in: Atom PDF