Skip to content

Commit 79f5930

Browse files
committed
Merge pull request increments#16 from increments/mention-pattern
Relax mention name patterns with 2 characters length
2 parents cc2de4d + 82e2340 commit 79f5930

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

lib/qiita/markdown/filters/mention.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module Filters
88
class Mention < HTML::Pipeline::MentionFilter
99
MentionPattern = /
1010
(?:^|\W)
11-
@((?>[\w][\w-]{1,30}\w(?:@github)?))
11+
@((?>[\w][\w-]{0,30}\w(?:@github)?))
1212
(?!\/)
1313
(?=
1414
\.+[ \t\W]|

spec/qiita/markdown/processor_spec.rb

+19-1
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,18 @@
241241
end
242242
end
243243

244+
context "with mention to short name user" do
245+
let(:markdown) do
246+
"@al"
247+
end
248+
249+
it "replaces mention with link" do
250+
should include(<<-EOS.strip_heredoc.rstrip)
251+
<a href="/al" class="user-mention" title="al">@al</a>
252+
EOS
253+
end
254+
end
255+
244256
context "with mentions in complex patterns" do
245257
let(:markdown) do
246258
<<-EOS.strip_heredoc
@@ -258,7 +270,11 @@
258270
@justin
259271
@mallory@github
260272
@#{'o' * 33}
261-
@oo
273+
@o
274+
@o-
275+
@-o
276+
@o_
277+
@_o
262278
EOS
263279
end
264280

@@ -271,6 +287,8 @@
271287
Isaac
272288
justin
273289
mallory@github
290+
o_
291+
_o
274292
]
275293
end
276294
end

0 commit comments

Comments
 (0)