Skip to content

Commit 77df4c4

Browse files
committed
Merge branch 'master' of github.com:asika32764/php-autolink
2 parents e40825e + b223c3c commit 77df4c4

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ Output
190190

191191
## Scheme
192192

193-
You can add new scheme to convert URL begin with it, foe example: `vnc://example.com`
193+
You can add new scheme to convert URL begin with it, for example: `vnc://example.com`
194194

195195
``` php
196196
$autolink->addScheme('skype')
@@ -208,7 +208,7 @@ $autolink->setLinkBuilder(function($url, $attribs)
208208
{
209209
$attribs['src'] = htmlspecialchars($url);
210210

211-
return (string) \Windwalker\Html\HtmlElement('img', null, $attribs);
211+
return (string) new \Windwalker\Html\HtmlElement('img', null, $attribs);
212212
});
213213
```
214214

src/Autolink.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function convert($text, $attribs = array())
7878
$regex,
7979
function($matches) use ($self, $attribs)
8080
{
81-
preg_match('/[a-zA-Z]*\=\"(.*)\"/', $matches[0], $inElements);
81+
preg_match('/[a-zA-Z]*\=\"(.*)/', $matches[0], $inElements);
8282

8383
if (!$inElements)
8484
{
@@ -101,19 +101,21 @@ function($matches) use ($self, $attribs)
101101
*/
102102
public function convertEmail($text, $attribs = array())
103103
{
104+
$self = $this;
105+
104106
$regex = "/(([a-zA-Z]*=\")*\S+@\S+\.\S+)/";
105107

106108
return preg_replace_callback(
107109
$regex,
108-
function($matches) use ($attribs)
110+
function($matches) use ($self, $attribs)
109111
{
110-
preg_match('/[a-zA-Z]*\=\"(.*)\"/', $matches[0], $inElements);
112+
preg_match('/[a-zA-Z]*\=\"(.*)/', $matches[0], $inElements);
111113

112114
if (!$inElements)
113115
{
114116
$attribs['href'] = 'mailto:' . htmlspecialchars($matches[0]);
115117

116-
return $this->buildLink($matches[0], $attribs);
118+
return $self->buildLink($matches[0], $attribs);
117119
}
118120

119121
return $matches[0];

0 commit comments

Comments
 (0)