iamcal/lib_autolink

Adds anchors to urls in a text

Installs: 1 223 438

Dependents: 3

Suggesters: 0

Security: 0

Stars: 62

Watchers: 7

Forks: 22

Open Issues: 7

pkg:composer/iamcal/lib_autolink

v1.9 2022-09-12 16:35 UTC

This package is auto-updated.

Last update: 2025-09-23 21:23:53 UTC


README

Build Status Latest Stable Version

Find URLs in HTML that are not already links, and make them into links.

Looking to do this in JavaScript? https://github.com/iamcal/autolink-js

Usage

include('lib_autolink.php');


# simple mode
$html = autolink($html);

# truncate URLs longer than 20 characters
$html = autolink($html, 20);

# insert some magic into the <a> tags
$html = autolink($html, 30, ' class="mylink"');

# By default if the display url is truncated, a title attribute is added to the link, if you don't want this, add a 4th parameter of false
$html = autolink($html, 30, ' class="mylink"', false);

# link up email address
$html = autolink_email($html);

Testing

If you have perl's Test::Harness installed (you almost certainly do), you can run the tests using:

prove --exec 'php' t/*.t