Giter Club home page Giter Club logo

linkify's Introduction

Linkify

Finding and linkifying things that look like links.

It focuses on: a main use case, short and fast code, and code-sharing between backend and frontend.

This package works for multiple languages, right now php and js.

Install

Use Composer. And use require to get the latest stable version:

composer require alsvanzelf/linkify:dev-master

Features

The basics:

  • Anything that starts with http://, https:// or www.
  • No support for ftp, email addresses, basic auth, and other edge cases.
  • No advanced validation, for example real tld's.
  • Adds http:// for the href when it was not given in the text.

Things that work:

  • Case insensitive
  • Unicode
  • Paths, query strings, hashes, and other allowed characters
  • Urls starting/ending a line or the whole string
  • Not including punctuation after the url
  • Urls enclosed in brackets
  • Urls with brackets inside the url

Things that -currently- do not work:

  • Urls which contain one of: @ |

Usage

$linkifier = new alsvanzelf\linkify\linkify();
$linkified = $linkifier->linkify($plain);
var linkified = linkify(plain);

Note the input string should NOT contain html to prevent XSS. As afterwards one can not differentiate the added anchors from existing html.

Contribute

Pull Requests or issues are welcome!

For example on adding more languages, or perfecting the cases catched.

License

MIT

Thanks

Thanks to inspiration from:

linkify's People

Contributors

lode avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.