Sha256: 49a789ef99ae5da6c5dade1953218f9516ec7dff7fa8f59266b1587eaa71b852
Contents?: true
Size: 1.51 KB
Versions: 9
Compression:
Stored size: 1.51 KB
Contents
// // Twitter Extension // @username -> <a href="http://twitter.com/username">@username</a> // #hashtag -> <a href="http://twitter.com/search/%23hashtag">#hashtag</a> // (function(){ var twitter = function(converter) { return [ // @username syntax { type: 'lang', regex: '\\B(\\\\)?@([\\S]+)\\b', replace: function(match, leadingSlash, username) { // Check if we matched the leading \ and return nothing changed if so if (leadingSlash === '\\') { return match; } else { return '<a href="http://twitter.com/' + username + '">@' + username + '</a>'; } }}, // #hashtag syntax { type: 'lang', regex: '\\B(\\\\)?#([\\S]+)\\b', replace: function(match, leadingSlash, tag) { // Check if we matched the leading \ and return nothing changed if so if (leadingSlash === '\\') { return match; } else { return '<a href="http://twitter.com/search/%23' + tag + '">#' + tag + '</a>'; } }}, // Escaped @'s { type: 'lang', regex: '\\\\@', replace: '@' } ]; }; // Client-side export if (typeof window !== 'undefined' && window.Showdown && window.Showdown.extensions) { window.Showdown.extensions.twitter = twitter; } // Server-side export if (typeof module !== 'undefined') module.exports = twitter; }());
Version data entries
9 entries across 9 versions & 1 rubygems