tweetParser.js Parse an element containing a tweet and turn URLS, @user & #hashtags into working urls
tweetParser.js Parse elements containing a tweets and turn URLS, @users & #hashtags into working urls
tweetParser is also available as a Django Template Filter
Parameters | Type | default | description |
---|---|---|---|
urlClass | String | tweet_link | css Class used for url in the tweet |
userClass | String | tweet_user | css Class used for @user profil url in the tweet |
hashtagClass | String | hashtag | css Class used for hashtags url in the tweet |
target | HTML attribute for anchor tags | _blank | target used for all generated |
searchWithHashtags | Boolean | true | generate hashtag link, if true : "twitter.com/hashtag/", if false : "twitter.com/search?q=" |
ParseUsers | Boolean | true | will parse @users if is set to true |
parseUrls | Boolean | true | will parse URLS if is set to true |
parseHashtags | Boolean | true | will parse hashtags if is set to true |
if you want to use bower just type :
bower install tweetparser.js
npm install --save-dev tweetparser.js
<script src="js/tweetParser.min.js"></script>
<p class="tweet">This is my awesome text only tweet ! #web #twitter @twitter http://www.twitter.com/ !!</p>
//basic usage
tweetParser('.tweet');
//With Default parameters
tweetParser('.tweet', {
urlClass : "tweet_link", //this is default
userClass : "tweet_user", //this is default
hashtagClass : "hashtag", //this is default
target : "_blank", //this is default
searchWithHashtags : true //this is default
parseUsers : true,
parseHashtags : true,
parseUrls : true
});
// Note that '.tweet' is your own CSS selector
<script src="path/to/jquery.min.js"></script>
<script src="path/to/tweetParser.js"></script>
and call tweetParser like in v1 :
$([SELECTOR]).tweetParser([PARAMETERS]);
you can customize your tweet with css classes used in parameters
v2.2.0
v2.1.3
v2.1.2
v2.1.1
v2.1.0
<!-- To use it with jQuery : add tweetParser.js and jquery.tweetParser.js -->
<script src="dist/tweetParser.js"></script>
<script src="dev/jquery.tweetParser.js"></script>
and call tweetParser like in v1 :
$([SELECTOR]).tweetParser([PARAMETERS]);
It is always easier to use it without jQuery just don't add jquery.tweetParser.js and :
tweetParser([SELECTOR], [PARAMETERS]);
v2.0.2
v2.0.1
v2.0.0
NB : For you, there is just some small changes in the syntax to call tweetParser.
use
tweetParser([SELECTOR], [PARAMETERS]);
instead of :
$([SELECTOR]).tweetParser([PARAMETERS]);
v1.3.1
v1.3.0
v1.2.1
v1.2.0
v1.1.0
searchWithHashtags parameter added
You can now choose where hashtags links will point to.
when searchWithHastags = true (default), tweetParser will generate the following link for each hashtags : "twitter.com/hashtag/THE_HASHTAG".
if you set it to false, the link will be : "twitter.com/search?q=THE_HASHTAG"
code optimisation, remove useless var.
v1.0.0
Initial Version