Project

General

Profile

Actions

Defect #20841

closed

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

Added by Go MAEDA about 9 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Text formatting
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Wont fix
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 - Feature #32424: CommonMark Markdown Text FormattingClosedMarius BÄ‚LTEANU

Actions
Has duplicate Redmine - Feature #39003: Add css class to external links in markdownClosed

Actions
Blocks Redmine - Feature #1151: Open Links in New-WindowNew2008-05-01

Actions
Actions #1

Updated by Go MAEDA about 9 years ago

Actions #2

Updated by Go MAEDA over 6 years 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,
Actions #3

Updated by Go MAEDA over 6 years 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
Actions #4

Updated by Go MAEDA over 6 years ago

  • Target version deleted (Candidate for next minor release)
Actions #5

Updated by Jan from Planio www.plan.io about 5 years ago

  • Related to Feature #32424: CommonMark Markdown Text Formatting added
Actions #6

Updated by Go MAEDA over 3 years ago

  • Status changed from New to Closed
  • Resolution set to Wont fix

The CommonMark formatter that will be available in Redmine 5.0.0 (#32424) correctly adds an "external" class. The existing RedCarpet based Markdown formatter still has this bug, but I don't think we need to make any effort to fix it because it is going to be dropped in the near future.

Actions #7

Updated by Go MAEDA about 1 year ago

  • Has duplicate Feature #39003: Add css class to external links in markdown added
Actions

Also available in: Atom PDF