npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

npm-text-parser

v1.0.8

Published

Text parser which receives text data as input and replaces the urls with clickable links (anchor tags), emails as clickable mail:to tags and also replaces hash tags (#tag) with empty clickable anchor tags

Downloads

78

Readme

npm-text-parser

Text parser which receives text data as input and replaces the urls with clickable links (anchor tags), emails as clickable mail:to tags and also replaces hash tags (#tag) empty clickable anchor tag.

Installation

npm i npm-text-parser

Usage

var parseText = require('npm-text-parser');

parseUrl(text)

Receives the input text and replaces all the url matches with clickable anchor links


  var inputString = "This is awesome it parses the url's dude and http://krishcdbry.com done !"
  
  parseText.parseUrl(inputString);
  // This is awesome it parses the url's dude and <a href="http://krishcdbry.com" 
  // target="_blank">http://krishcdbry.com</a> done !

parseEmail(text)

Receives the input text and replaces all the email matches with clickable mail:to anchor links

  
  var inputString = "This is awesome it parses the email's dude and [email protected] done !"
  
  parseText.parseEmail(inputString);
  // This is awesome it parses the email's dude and  
  // <a href="mailto:[email protected]">[email protected]</a> done !
 

parseHash(text)

Receives the input text and replaces all the hashtag matches with clickable empty anchor links

  
  var inputString = "This is awesome it parses the hash tag's dude and #krishcdbry done !"
  
  parseText.parseHashtags(inputString);
   // This is awesome it parses the hash tag's dude and <a href="javascript:;">#krishcdbry</a> done !
 

parse(text)

Receives the input text and replaces the urls with clickable links (anchor tags), emails as clickable mail:to tags and also replaces hash tags (#tag) with empty clickable anchor tags


  var inputString = "his is awesome it parses the url's , email's and hash tag's dude http://[email protected] and email [email protected] also #krishcdbry done !"
 
  parseText.parse(inputString)
  // This is awesome it parses the url's , email's and hash tag's dude 
  // <a href="http://[email protected]" target="_blank">http://[email protected]</a>
  // and email <a href="mailto:[email protected]">[email protected]</a> 
  // also <a href="javascript:;">#krishcdbry</a> done !
 
 

getUrls(text)

(Array of url occurrences) - Receives the input text, reads all the Urls in it and returns
and array of all url occurrences


  var inputString = 'This is awesome http://krishcdbry.com and www.heartynote.com done !'
 
  textParser.getUrls(inputString)
  // ['http://krishcdbry.com', 'www.heartynote.com']
 

getEmails(text)

(Array of email occurrences) - Receives the input text, reads all the emails in it and returns
and array of all email occurrences

  var inputString = 'This is awesome [email protected] and [email protected] done !'
 
  textParser.getEmails(inputString)
  // ['[email protected]', '[email protected]']

getHashtags(text)

(Array of hashtags occurrences) - Receives the input text, reads all the hashtagss in it and returns
and array of all hashtags occurrences

  var inputString = 'This is awesome #krishcdbry, #heartynote and #node done !'
 
  textParser.getHashtags(inputString)
  // ['#krishcdbry', '#heartynote', '#node']

getAll(text)

All occurrences includes (Urls, emails and hashtags)


  var inputString = 'This is awesome [email protected] and also http://nmpjs.org, www.krishcdbry.com and #heartynote and #node done !'
 
  textParser.getAllOccurrences(inputString)
  //	{
  //		parsed_text: 'This is awesome <a href="mailto:[email protected]">[email protected]</a> and also <a href="http://nmpjs.org" target="_blank">http://nmpjs.org</a>, <a href="www.krishcdbry.com" target="_blank">www.krishcdbry.com</a> and<a href="javascript:;" target="_blank"> #heartynote</a> and<a href="javascript:;" target="_blank"> #node</a> done !',
  //		urls: [ 'http://nmpjs.org', 'www.krishcdbry.com' ],
  //		emails: [ '[email protected]' ],
  //		hashtags: [ ' #heartynote', ' #node' ]
  //	}
 

Demo

Demo @npm-text-parser | https://tonicdev.com/npm/npm-text-parser

Author

Krishcdbry [[email protected]]

Licence

MIT @krishcdbry