iamcal / lib_autolink
在文本中添加到URL的锚点
v1.9
2022-09-12 16:35 UTC
This package is auto-updated.
Last update: 2024-09-23 18:57:42 UTC
README
查找HTML中尚未成为链接的URL,并将它们转换为链接。
想要用JavaScript实现?请访问https://github.com/iamcal/autolink-js
用法
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);
测试
如果您已安装perl的Test::Harness(您几乎肯定已经安装),您可以使用以下命令运行测试:
prove --exec 'php' t/*.t