| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
Autolinker.matcher.Hashtag = Autolinker.Util.extend( Autolinker.matcher.Matcher, { |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
matcherRegex : new RegExp( '#[_' + Autolinker.RegexLib.alphaNumericCharsStr + ']{1,139}', 'g' ), |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
nonWordCharRegex : new RegExp( '[^' + Autolinker.RegexLib.alphaNumericCharsStr + ']' ), |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
constructor : function( cfg ) { |
| 46 |
Autolinker.matcher.Matcher.prototype.constructor.call( this, cfg ); |
| 47 |
|
| 48 |
this.serviceName = cfg.serviceName; |
| 49 |
}, |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
parseMatches : function( text ) { |
| 56 |
var matcherRegex = this.matcherRegex, |
| 57 |
nonWordCharRegex = this.nonWordCharRegex, |
| 58 |
serviceName = this.serviceName, |
| 59 |
tagBuilder = this.tagBuilder, |
| 60 |
matches = [], |
| 61 |
match; |
| 62 |
|
| 63 |
while( ( match = matcherRegex.exec( text ) ) !== null ) { |
| 64 |
var offset = match.index, |
| 65 |
prevChar = text.charAt( offset - 1 ); |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
if( offset === 0 || nonWordCharRegex.test( prevChar ) ) { |
| 71 |
var matchedText = match[ 0 ], |
| 72 |
hashtag = match[ 0 ].slice( 1 ); |
| 73 |
|
| 74 |
matches.push( new Autolinker.match.Hashtag( { |
| 75 |
tagBuilder : tagBuilder, |
| 76 |
matchedText : matchedText, |
| 77 |
offset : offset, |
| 78 |
serviceName : serviceName, |
| 79 |
hashtag : hashtag |
| 80 |
} ) ); |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
return matches; |
| 85 |
} |
| 86 |
|
| 87 |
} ); |