This Angular Component converts plain text tweets into real tweets. This component is responsible for parsing the tweets and handles transform mention (@sodhanalibrary), hashtags (#AngularJS) and URLs inserted in the tweet in functional URLs. This was created based on jquery-tweet-parser
Source Code           DEMO

Angular Component

This is the Angular Component which you can use it for converting plain text to real tweets
import { Component, Input } from '@angular/core';

@Component({
    selector: 'tweetParser',
    template: `<div [innerHTML]="myHtml"></div>`
})
export class TweetParser {
    @Input('urlClass') urlClass: string = 'react-tweet-parser__url';
    @Input('userClass') userClass: string = 'react-tweet-parser__user';
    @Input('hashtagClass') hashtagClass: string = 'react-tweet-parser__hashTag';
    @Input('target') target: string = '_blank';
    @Input('searchWithHashtags') searchWithHashtags: boolean = true;
    @Input('parseUsers') parseUsers : boolean = true;
    @Input('parseUrls') parseUrls :  boolean = true;
    @Input('parseHashtags') parseHashtags: boolean = true;
    @Input('tweet') tweet: string = '';

    myHtml: string = '';
    constructor() {
    }

    generateLink(url, urlClass, target, text) {
      return `<a href="${url}" className="${urlClass}" target="${target}">${text}</a>`;
    }

    ngOnChanges() {
      this.parseTweet();
    }

    ngOnInit(){
      this.parseTweet();
    }

    parseTweet() {
     const {urlClass, userClass, hashtagClass, target, searchWithHashtags, parseUsers, parseUrls, parseHashtags} = this;

     const REGEX_URL = /(?:\s)(f|ht)tps?:\/\/([^\s\t\r\n<]*[^\s\t\r\n<)*_,\.])/g, //regex for urls
                REGEX_USER = /\B@([a-zA-Z0-9_]+)/g, //regex for @users
                REGEX_HASHTAG = /\B(#[á-úÁ-Úä-üÄ-Üa-zA-Z0-9_]+)/g; //regex for #hashtags
     let searchlink, myTweet = this.tweet; //search link for hashtags
      //Hashtag Search link
     if (searchWithHashtags) {
          //this is the search with hashtag
          searchlink = "https://twitter.com/hashtag/";
      } else {
          //this is a more global search including hashtags and the word itself
          searchlink = "https://twitter.com/search?q=";
      }
      //turn URLS in the tweet into... working urls
      if (parseUrls) {
          myTweet = myTweet.replace(REGEX_URL, (url) => {
              let link = this.generateLink(url, urlClass, target, url);
              return url.replace(url, link);
          });
      }
      //turn @users in the myTweet into... working urls
      if (parseUsers) {
          myTweet = myTweet.replace(REGEX_USER, (user) => {
              let userOnly = user.slice(1),
                  url = `http://twitter.com/${userOnly}`,
                  link = this.generateLink(url, userClass, target, user);
              return user.replace(user, link);
          });
      }
      //turn #hashtags in the myTweet into... working urls
      if (parseHashtags) {
          myTweet = myTweet.replace(REGEX_HASHTAG, (hashtag) => {
              let hashtagOnly = hashtag.slice(1),
                  url = searchlink + hashtagOnly,
                  link = this.generateLink(url, hashtagClass, target, hashtag);
              return hashtag.replace(hashtag, link);
          });
      }

      this.myHtml  = myTweet;
   }
}

Usage

<tweetParser [tweet]="myTweet" urlClass="myUrlClass"></tweetParser>

40 comments:

  1. Pretty blog, so many ideas in a single site, thanks for the informative article, keep updating more article.
    Webdesining course in chennai

    ReplyDelete
  2. Your article is detailed, thanks to it I solved the problem I am entangled. I will regularly follow your writers and visit this site daily slope game

    ReplyDelete
  3. Nowadays, games have rewards programs that you may need to use real money to get. Make sure you choose the right option! On one hand, there is not much more enjoyment in playing. Then again, they may save a bit of time.
    free Studio One Professional 4 Crack
    free WinThruster 2018 Crack

    ReplyDelete
  4. Really informative article.Really looking forward to read more. Really Cool.
    โปรโมชั่นGclub ของทางทีมงานตอนนี้แจกฟรีโบนัส 50%
    เพียงแค่คุณสมัคร Gclub กับทางทีมงานของเราเพียงเท่านั้น
    ร่วมมาเป็นส่วนหนึ่งกับเว็บไซต์คาสิโนออนไลน์ของเราได้เลยค่ะ
    สมัครสล็อตออนไลน์ >>> goldenslot
    สนใจร่วมลงทุนกับเรา สมัครเอเย่น Gclub คลิ๊กได้เลย

    ReplyDelete
  5. Im grateful for the blog post.Really thank you!
    เว็บไซต์คาสิโนออนไลน์ที่ได้คุณภาพอับดับ 1 ของประเทศ
    เป็นเว็บไซต์การพนันออนไลน์ที่มีคนมา Gclub Royal1688
    และยังมีหวยให้คุณได้เล่น สมัครหวยออนไลน์ ได้เลย
    สมัครสล็อตออนไลน์ได้ที่นี่ >>> Golden slot
    ร่วมลงทุนสมัครเอเย่น Gclubกับทีมงานของเราได้เลย

    ReplyDelete
  6. Things are very open and intensely clear explanation of issues. was truly information. Your website is very beneficial.
    hotmail login

    ReplyDelete
  7. This is really a great stuff for sharing. Keep it up . Thanks for sharing.
    gmail login

    ReplyDelete
  8. Attend The Data Analytics Courses From ExcelR. Practical Data Analytics Courses Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Data Analytics Courses.
    ExcelR Data Analytics Courses

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. Help full post, lots of information about it. Thank you admin for providing this information.

    ReplyDelete
  11. Thank you so much for the sharing article. I have been reading your articles and they are really very helpful for the user. It’s a very nice blog on
    Digital exhibition
    Online trade fair
    online events
    digital events
    digital trade fair
    Upcoming Online events
    upcoming exhibitions
    Explore Best Online Events

    ReplyDelete

  12. อยากมีเงินใช้ เงินเที่ยว เกมเล่นสนุกๆ slot online สล็อตออนไลน์ เล่นง่ายๆ เล่นสล็อต แจกฟรีเครดิตสล็อต slotxo ฟรีเครดิต ได้เงินจริง เล่นเลยที่นี่ คลิกเลย
    https://www.slot2xl.com/

    ReplyDelete
  13. Thanks for sharing these wonderful informations. I really appreciate your hardwork. Keep it up. We buyjunk cars and truck

    ReplyDelete
  14. Your site is in reality extremely alluring. Your own course is really immense. We should be existing by and by there. I'm agreeable along with your distribute. I'll go to an individual with respect to considerably more reconsider. Much obliged! Printer Repair

    ReplyDelete
  15. ยินดีต้อนรับเข้าสู่ Click1234 สุดยอดเว็บแทงหวยออนไลน์ที่ดีที่สุดของประเทศไทย เว็บหวยออนไลน์อันดับ1 ของเมืองไทย ด้วยระบบที่ทันสมัย อยู่ที่ไหนก็เล่นได้ เล่นง่ายแค่ปลายนิ้ว อีกทั้งยังสามารถยกเลิกตั๋วด้วยตัวเอง เล่นง่ายไม่มีเลขอั้น ใหม่พร้อมเวอร์ชั่นโมบาย รองรับสมาร์ทโฟนทุกรุ่น ทำให้ไม่พลาดทุกเลขเด็ด สมัครสมาชิกฟรี ไม่เสียค่าใช้จ่าย เล่นง่ายไม่มีขั้นต่ำ เปิดรับการเล่นถึง 15.25น. มั่นคง ปลอดภัย 100% เล่นง่ายจ่ายจริงรับเงินเร็ว ไม่มีโกงแน่นอน “ท้าให้คุณลอง เปิดให้คุณเล่น หวยออนไลน์ยุคใหม่ อยู่ที่ไหนก็เล่นได้”

    ติดตามเรื่องราวและบทความเกี่ยวกับลอตเตอรี่ได้อีกที่ https://onlinelotterys.livejournal.com/

    ReplyDelete
  16. Nice Blog.

    We Are The Best Canada Immigration Consultants in India,Offering Canada Visa Assistance for Those Who Are Under the process of Immigration to Canada.

    For more Details Please follow below link

    https://www.canaanservices.in/

    ReplyDelete
  17. For getting best feed for animal,fish and poultry
    Pashu ahar in Bihar

    ReplyDelete
  18. Crypto-currency as a modern form of the digital asset has received a worldwide acclaim for easy and faster financial transactions and its awareness among people have allowed them to take more interest in the field thus opening up new and advanced ways of making payments. Crypto.com Referral Code with the growing demand of this global phenomenon more,new traders and business owners are now willing to invest in this currency platform despite its fluctuating prices however it is quite difficult to choose the best one when the market is full. In the list of crypto-currencies bit-coins is one of the oldest and more popular Crypto.com Referral Code for the last few years. It is basically used for trading goods and services and has become the part of the so-called computerized block-chain system allowing anyone to use it thus increasing the craze among the public, Crypto.com Referral Code.

    Common people who are willing to purchase BTC can use an online wallet system for buying them safely in exchange of cash or credit cards and in a comfortable way from the thousands of BTC foundations around the world and keep them as assets for the future. Due to its popularity, many corporate investors are now accepting them as cross-border payments and the rise is unstoppable. With the advent of the internet and mobile devices,information gathering has become quite easy as a result the BTC financial transactions are accessible and its price is set in accordance with people’s choice and preferences thus leading to a profitable investment with Crypto.com Referral Code Code. Recent surveys have also proved that instability is good for BTC exchange as if there is instability and political unrest in the country due to which banks suffer then investing in BTC can surely be a better option. Again bit-coin transaction fees are pretty cheaper and a more convenient technology for making contracts thus attracting the crowd. The BTC can also be converted into different fiat currencies and is used for trading of securities, for land titles, document stamping, public rewards and vice versa.

    Another advanced block-chain project is Ethereumor the ETH which has served much more than just a digital form of crypto-currency Crypto.com Referral Code and its popularity in the last few decades have allowed billions of people to hold wallets for them. With the ease of the online world,the ETH have allowed the retailers and business organizations to accept them for trading purposes, therefore, can serve as the future of the financial system.

    ReplyDelete
  19. Thank you so much. This article was very essential for me . I after a long time I found this kind of article. know about Roobet Promo Code Gambling Bitcoin Casino

    ReplyDelete
  20. Our full Lace Front Wigs are all hand made with a lace cap. They are manufactured with thin lace sewn on top of the cap. Individual hairs are then sewn onto the thin lace. Each lace wig has lace all around the unit which will need to be cut prior to securing the wig to your head. You will need to cut along the hairline around your entire head. By doing so, you will be able to wear your hair anyway you like. You can even style ponytails, up-dos, etc. Once the Lace Wigs is successfully applied, it will appear that all the hair is growing directly from your head!

    Lace front wigs are hand-made with lace front cap & machine weft at back. Lace front wigs are manufactured with a thin lace that extends from ear to ear across the hairline. When you receive the wig, the lace will be quite long in the front. Cut and style according to your preference, as you will need to apply adhesive along the front of the wig. Once the wig is applied, you will still have Lace Wigs with a very natural appearance.
    TeamWigz Provide the Best Lace Front Wigs and Lace Wigs in Johannesburg and South Africa.

    ReplyDelete
  21. news,busines,followers,likes,france,social,media,fitness,
    Thanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative.
    I can't wait to read lots of your posts.
    acheter des abonnés instagram france .
    acheter instagram aime france
    .

    ReplyDelete
  22. This was a great article. It is very helpful and informative. Thanks for sharing such kind of article.
    Keep up sharing such kind of article about DIgital Marketing.

    ReplyDelete
  23. Thank you for this informative post

    Get Six Sigma Certification In Delhi with HenryHarvin.
    Learn from experts and be on top.

    ReplyDelete
  24. Well written article, loved it!
    Get Six Sigma Certification Online with HenryHarvin.
    Learn from experts and be on top

    ReplyDelete
  25. Marvelous Designer Free Download not only make conventional T-shirts but also makes dresses and professional outfits with various complex details. The property effects also can be displayed most realistically, accurately simulated. Therefore, It also can modify and check out clothing in real timeFullmaccrack .

    ReplyDelete
  26. Tongkat Ali ist eine Pflanze beheimatet in Südostasien. Sie gehört zur Gattung der Bittereschengewächse und Ihr botanischer Name lautet “Eurycoma longifolia”. Es gibt noch eine weitere Reihe länderspezifischer Namen
    wie z. B. “Pasak Bumi”, wie die Pflanze in Indonesien genannt wird oder “longjack”, die allgemeine Bezeichnung für Tongkat Ali Kaufen in den USA, Kanada und Australien.

    Das Ursprungsland von Tongkat Ali Kaufen ist Indonesien, daher findet man auch dort auch die größten Bestände. Weitere Vorkommen gibt es in Ländern wie Thailand, Malaysia, Vietnam und Laos.

    Die Einnahme von Tongkat Ali Kaufen empfiehlt sich insbesondere für Leistungssportler, die einen schnellen
    Muskelaufbau und Muskelzuwachs anstreben und nicht auf illegale und künstliche Substanzen zurückgreifen möchten um Ihren Testosteronspiegel zu erhöhen.

    Generell empfiehlt sich eine Einnahme von Tongkat Ali für alle Männer ab dem 30ten Lebensjahr, da in dieser Phase nachweislich die Produktion von körpereigenem Testosteron zurückgeht. Dies macht sich vor allem dadurch bemerkbar dass die körperliche Leistungsfähigkeit nachlässt, die Lust auf Sex spürbar abnimmt und dadurch allgemein das Selbstwertgefühl negativ beeinflusst wird.

    Mit der Einnahme von Tongkat Ali können Sie nachweislich Ihre Libido steigern, Ihr Testosteron erhöhen und Ihre gewohnte Lebensenergie aus den jungen Jahren Ihres Lebens wieder herbeiführen. Hier können Sie übrigens weitere Informationen bekommen zum Thema ‘Libido steigern‘ ganz natürlich. Sollten Sie daran interessiert sein lohnt es sich auch unseren Artikel über
    Butea Superba zu lesen.

    Tongkat Ali wächst als Strauch und kann Höhen von bis zu 12 Metern erreichen. Typischerweise dauert es 10-15 Jahre bis solche Ausmaße erreicht werden. Der Strauch trägt anfangs grüne Blüten die sich im Laufe der Zeit, bis zur Reife, rot färben.

    Allerdings sind die Blüten im Hinblick auf die Wirkung der Pflanze weniger interessant. Der wertvolle Teil verbirgt sich unter der Erde.
    Im Laufe der Jahre wachsen die Wurzeln teilweise senkrecht und bis zu mehrere Meter tief in den Boden, was die Ernte zu einer schweren und mühsamen Arbeit werden lässt. Je älter die Wurzeln sind, desto höher ist auch die Anzahl der Wirkstoffe Butea Superba.
    Von daher gilt es einige Dinge zu beachten sollten Sie Tongkat Ali kaufen wollen.

    ReplyDelete
  27. The article is well written and understandable. for more content i will get back to you SEO SERVICE COMPANY CHENNAI

    ReplyDelete

Blogroll

Follow this blog by Email

Popular Posts