Skip to content

tweetParser.js Parse an element containing a tweet and turn URLS, @user & #hashtags into working urls

License

Notifications You must be signed in to change notification settings

ankalago/jquery.tweetParser

 
 

Repository files navigation

tweetParser.js

Parse Twitter Usernames, Hashtags and URLs Using jQuery tweetParser.js Parse elements containing a tweets and turn URLS, @users & #hashtags into working urls

PARAMETERS

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="

INITIALISATION

You can install tweetParser.js with Bower

if you want to use bower just type :

bower install jquery.tweet-parser
Add jquery lib and tweetParser.min.js to your HTML document
    <script src="js/jquery.min.js"></script>
    <script src="js/jquery.tweetParser.min.js"></script>
Your tweet in your html document
    <p class="tweets">This is my awesome text only tweet ! #web #twitter @twitter http://www.twitter.com/ !!</p>
getting started with tweetParser
    //basic usage
    $("p.tweets").tweetParser();
    
    //With parameters
    $("p.tweets").tweetParser({
        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
    });

RESULT EXAMPLE

Check out the demo or try it in codepen.io

you can customize your tweet with css classes used in parameters

Result After parsing tweets

Changelog

  • 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

About

tweetParser.js Parse an element containing a tweet and turn URLS, @user & #hashtags into working urls

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • JavaScript 46.4%
  • CSS 27.9%
  • HTML 25.7%