Skip to content

Commit 8ef9c5e

Browse files
committed
Merge pull request #89 from excid3/master
Add link_attr option to Autolink filter
2 parents df26d88 + fc795a6 commit 8ef9c5e

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
@@ -6,6 +6,7 @@ class Pipeline
66
#
77
# Context options:
88
# :autolink - boolean whether to autolink urls
9+
# :link_attr - HTML attributes for the link that will be generated
910
# :skip_tags - HTML tags inside which autolinking will be skipped.
1011
# See Rinku.skip_tags
1112
# :flags - additional Rinku flags. See https://github.com/vmg/rinku
@@ -19,7 +20,7 @@ def call
1920
flags = 0
2021
flags |= context[:flags] if context[:flags]
2122

22-
Rinku.auto_link(html, :urls, nil, skip_tags, flags)
23+
Rinku.auto_link(html, :urls, context[:link_attr], skip_tags, flags)
2324
end
2425
end
2526
end

test/html/pipeline/autolink_filter_test.rb

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

18+
def test_autolink_link_attr
19+
assert_equal '<p>"<a href="http://www.github.com" target="_blank">http://www.github.com</a>"</p>',
20+
AutolinkFilter.to_html('<p>"http://www.github.com"</p>', :link_attr => 'target="_blank"')
21+
end
22+
1823
def test_autolink_flags
1924
assert_equal '<p>"<a href="http://github">http://github</a>"</p>',
2025
AutolinkFilter.to_html('<p>"http://github"</p>', :flags => Rinku::AUTOLINK_SHORT_DOMAINS)

0 commit comments

Comments
 (0)