-
Notifications
You must be signed in to change notification settings - Fork 2
/
autolink.js
29 lines (29 loc) · 1.48 KB
/
autolink.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
$(function ()
{
// Replace text node children of all elements except <textarea>s according
// to regular expressions, http://dev.jquery.com/ticket/4361
$(':not(textarea)')
.contents()
.filter(function ()
{
return 3 == this.nodeType;
})
.each(function ()
{
$(this).replaceWith(this.nodeValue
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/\br(\d+)\b/g, '<a class="external text" href="http://code.google.com/p/qubit-toolkit/source/detail?r=$1">$&</a>')
.replace(/\b(?:commit|revision)s?\s+#?\d+(?:,?\s+(?:(?:&|and)\s+)?#?\d+)+\b/gi, function ($0)
{
return $0.replace(/#?(\d+)/gi, '<a class="external text" href="http://code.google.com/p/qubit-toolkit/source/detail?r=$1">$&</a>');
})
.replace(/\b(?:commit|revision)\s+#?(\d+)\b/gi, '<a class="external text" href="http://code.google.com/p/qubit-toolkit/source/detail?r=$1">$&</a>')
.replace(/\b(?:issue|bug)s?\s+#?\d+(?:,?\s+(?:(?:&|and)\s+)?#?\d+)+\b/gi, function ($0)
{
return $0.replace(/#?(\d+)/gi, '<a class="external text" href="http://code.google.com/p/qubit-toolkit/issues/detail?id=$1">$&</a>');
})
.replace(/\b(?:issue|bug)\s+#?(\d+)\b/gi, '<a class="external text" href="http://code.google.com/p/qubit-toolkit/issues/detail?id=$1">$&</a>'));
});
});