Plaint Text To HTML Link Converter – Anchorme.js

Category: Javascript , Recommended , Text | March 31, 2017
Author: alexcorvi
Views Total: 1,924
Official Page: Go to website
Last Update: March 31, 2017
License: MIT

Preview:

Plaint Text To HTML Link Converter – Anchorme.js

Description:

Anchorme.js is simple yet robust JavaScript library that finds URs, IPs, files and email addresses in your plain text and convert them into clickable html links. Works with Node.js and browser.

Installation:

# NPM
$ npm install anchorme

How to use it:

// NPM
var anchorme = require("anchorme").default; 

// ES6 / Typescript style imports
import anchorme from "anchorme";

Or directly include the JavaScript anchorme.js on the webpage.

<script src="anchorme.js"></script>

Basic usage:

anchorme(string,option)

Default configurations.

anchorme(string,{

  //addiontal attributes
  attributes: [],

  // converts IPs
  ips: true,

  // converts email addresses
  emails: true,

  // converts URLs
  urls: true,

  // converts files
  files: true,

  // truncate links
  truncate: Infinity,

  // default protocol
  defaultProtocol: "http://",

  // Although anchorme was authored to transform URLs in text strings to a click-able HTML anchor tags, passing `true` to `list` property in options will change the library's behavior and instead of returning a text with an HTML tags it will only return an array of valid URLs.
  list: false
  
})

You Might Be Interested In:


Leave a Reply