Skip to content

Commit dfeb1e2

Browse files
committed
fix(mentions): allow for usernames with dot, underscore and dash
Closes #574
1 parent 79ed024 commit dfeb1e2

File tree

9 files changed

+28
-11
lines changed

9 files changed

+28
-11
lines changed

dist/showdown.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/showdown.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/showdown.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/showdown.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/subParsers/anchors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ showdown.subParser('anchors', function (text, options, globals) {
7575

7676
// Lastly handle GithubMentions if option is enabled
7777
if (options.ghMentions) {
78-
text = text.replace(/(^|\s)(\\)?(@([a-z\d\-]+))(?=[.!?;,[\]()]|\s|$)/gmi, function (wm, st, escape, mentions, username) {
78+
text = text.replace(/(^|\s)(\\)?(@([a-z\d]+(?:[a-z\d.-]+?[a-z\d]+)*))/gmi, function (wm, st, escape, mentions, username) {
7979
if (escape === '\\') {
8080
return st + mentions;
8181
}

test/features/ghMentions.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
<p>hello <a href="https://github.com/tivie">@tivie</a> how are you?</p>
22
<p>this email foo@gmail.com is not parsed</p>
3-
<p>this @mentions is not parsed also</p>
3+
<p>this @mentions is not parsed</p>
4+
<p><a href="https://github.com/john.doe">@john.doe</a></p>
5+
<p><a href="https://github.com/john-doe">@john-doe</a></p>
6+
<p>@.johndoe</p>
7+
<p>@_johndoe</p>
8+
<p>@-johndoe</p>
9+
<p><a href="https://github.com/johndoe">@johndoe</a>.</p>
10+
<p><a href="https://github.com/johndoe">@johndoe</a>-</p>

test/features/ghMentions.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,18 @@ hello @tivie how are you?
22

33
this email foo@gmail.com is not parsed
44

5-
this \@mentions is not parsed also
5+
this \@mentions is not parsed
6+
7+
@john.doe
8+
9+
@john-doe
10+
11+
@.johndoe
12+
13+
@_johndoe
14+
15+
@-johndoe
16+
17+
@johndoe.
18+
19+
@johndoe-

test/functional/makehtml/cases/issues/#585.error-when-using-image-references.html

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/functional/makehtml/cases/issues/#585.error-when-using-image-references.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)