Skip to content

Commit f5e25e6

Browse files
committed
Add support for multiple parsers with the same character.
1 parent ea7feec commit f5e25e6

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Release Notes
22

3+
## v1.3.0 (2018-06-15)
4+
5+
- Added support for multiple parsers with the same character.
6+
37
## v1.2.0 (2018-06-03)
48

59
- Change the version constraint to `^1.0` of the `symfony/polyfill-mbstring` package.

src/Autolink.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function addFilter(Filter $filter): self
4747
public function addParser(Parser $parser): self
4848
{
4949
foreach ($parser->getCharacters() as $character) {
50-
$this->parsers[$character] = $parser;
50+
$this->parsers[$character][] = $parser;
5151
}
5252

5353
return $this;
@@ -112,14 +112,18 @@ public function convert(string $text, callable $callback = null): HtmlString
112112
continue;
113113
}
114114

115-
$parser = array_get($this->parsers, $character);
115+
$parsers = array_get($this->parsers, $character);
116116

117-
if (is_null($parser)) {
117+
if (is_null($parsers)) {
118118
continue;
119119
}
120120

121-
if ($link = $parser->parse($cursor)) {
122-
$links[] = $link;
121+
foreach ($parsers as $parser) {
122+
if ($link = $parser->parse($cursor)) {
123+
$links[] = $link;
124+
125+
break;
126+
}
123127
}
124128
}
125129

0 commit comments

Comments
 (0)