Skip to content

Commit 3801fd5

Browse files
author
Simeon F. Willbanks
committed
Merge remote-tracking branch 'upstream/master' into simple-dependency-management
2 parents 0471de4 + 8ef9c5e commit 3801fd5

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/html/pipeline/autolink_filter.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class Pipeline
1111
#
1212
# Context options:
1313
# :autolink - boolean whether to autolink urls
14+
# :link_attr - HTML attributes for the link that will be generated
1415
# :skip_tags - HTML tags inside which autolinking will be skipped.
1516
# See Rinku.skip_tags
1617
# :flags - additional Rinku flags. See https://github.com/vmg/rinku
@@ -24,7 +25,7 @@ def call
2425
flags = 0
2526
flags |= context[:flags] if context[:flags]
2627

27-
Rinku.auto_link(html, :urls, nil, skip_tags, flags)
28+
Rinku.auto_link(html, :urls, context[:link_attr], skip_tags, flags)
2829
end
2930
end
3031
end

test/html/pipeline/autolink_filter_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ def test_autolink_option
1919
AutolinkFilter.to_html('<p>"http://www.github.com"</p>', :autolink => false)
2020
end
2121

22+
def test_autolink_link_attr
23+
assert_equal '<p>"<a href="http://www.github.com" target="_blank">http://www.github.com</a>"</p>',
24+
AutolinkFilter.to_html('<p>"http://www.github.com"</p>', :link_attr => 'target="_blank"')
25+
end
26+
2227
def test_autolink_flags
2328
assert_equal '<p>"<a href="http://github">http://github</a>"</p>',
2429
AutolinkFilter.to_html('<p>"http://github"</p>', :flags => Rinku::AUTOLINK_SHORT_DOMAINS)

0 commit comments

Comments
 (0)