@@ -193,7 +193,6 @@ def test_markdown_to_html
193193 end
194194
195195 def test_markdown_table_alignment
196- # Ensure that kramdown table alignment styles are converted to bootstrap classes
197196 markdown_table = <<~MARKDOWN
198197 | foo | bar |
199198 |:----:|----:|
@@ -226,9 +225,11 @@ def test_text_to_html_linkify
226225 end
227226
228227 def test_linkify_username_with_space
229- text = 'Hello @"Open Mapper"'
230- html = RichText . new ( "markdown" , text ) . to_html
231- assert_match %r{<a href="/user/Open%20Mapper" rel="nofollow noopener noreferrer">@”Open Mapper”</a>} , html
228+ with_settings ( :linkify => { :detection_rules => [ { :patterns => [ "@(?<username>\\ w+)" ] , :path_template => "user/\\ k<username>" } ] } ) do
229+ text = 'Hello @"Open Mapper"'
230+ html = RichText . new ( "markdown" , text ) . to_html
231+ assert_match %r{<a href="/user/Open%20Mapper" #{ RichText ::LINK_ATTRIBUTES } >@[“”]Open Mapper[“”]</a>}o , html
232+ end
232233 end
233234
234235 def test_text_to_html_linkify_replace
@@ -243,6 +244,18 @@ def test_text_to_html_linkify_replace
243244 end
244245 end
245246
247+ def test_linkify_username_with_quotes
248+ text = "Hello @'\" Yo\" '"
249+ html = RichText . new ( "markdown" , text ) . to_html
250+ assert_match %r{<a href="/user/%22Yo%22" #{ RichText ::LINK_ATTRIBUTES } >@[‘'’]“Yo”[‘'’]</a>}o , html
251+ end
252+
253+ def test_linkify_short_username
254+ text = "Hello @Yo"
255+ html = RichText . new ( "markdown" , text ) . to_html
256+ assert_match %r{<a href="/user/Yo" #{ RichText ::LINK_ATTRIBUTES } >@Yo</a>}o , html
257+ end
258+
246259 def test_text_to_html_linkify_recognize
247260 with_settings ( :linkify_hosts => [ "replace-me.example.com" ] , :linkify_hosts_replacement => "repl.example.com" ) do
248261 r = RichText . new ( "text" , "foo repl.example.com/some/path?query=te<st&limit=20>10#result12 bar" )
0 commit comments