Skip to content
This repository was archived by the owner on Apr 4, 2020. It is now read-only.

Commit 69c181c

Browse files
committed
Merge v0.3.1
2 parents de2ce9f + aa88bb5 commit 69c181c

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased][unreleased]
99

10+
## [0.3.1] - 2019-06-17
11+
12+
### Fixed
13+
14+
- Fixed extension incorrectly double-linking standard CommonMark autolinks (#12)
15+
1016
## [1.0.0-beta2] - 2019-06-05
1117

1218
### Changed
@@ -56,6 +62,7 @@ Initial release!
5662
[unreleased]: https://github.com/thephpleague/commonmark-ext-autolink/compare/v1.0.0-beta2...HEAD
5763
[1.0.0-beta2]: https://github.com/thephpleague/commonmark-ext-autolink/compare/v1.0.0-beta1...v1.0.0-beta2
5864
[1.0.0-beta1]: https://github.com/thephpleague/commonmark-ext-autolink/compare/v0.3.0...v1.0.0-beta1
65+
[0.3.1]: https://github.com/thephpleague/commonmark-ext-autolink/compare/v0.3.0...v0.3.1
5966
[0.3.0]: https://github.com/thephpleague/commonmark-ext-autolink/compare/v0.2.1...v0.3.0
6067
[0.2.1]: https://github.com/thephpleague/commonmark-ext-autolink/compare/v0.2.0...v0.2.1
6168
[0.2.0]: https://github.com/thephpleague/commonmark-ext-autolink/compare/v0.1.0...v0.2.0

src/EmailAutolinkProcessor.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ public function __invoke(DocumentParsedEvent $e)
2929
$walker = $e->getDocument()->walker();
3030

3131
while ($event = $walker->next()) {
32-
if ($event->getNode() instanceof Text) {
33-
self::processAutolinks($event->getNode());
32+
$node = $event->getNode();
33+
if ($node instanceof Text && !($node->parent() instanceof Link)) {
34+
self::processAutolinks($node);
3435
}
3536
}
3637
}

src/UrlAutolinkProcessor.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ public function __invoke(DocumentParsedEvent $e)
5858
$walker = $e->getDocument()->walker();
5959

6060
while ($event = $walker->next()) {
61-
if ($event->getNode() instanceof Text) {
62-
self::processAutolinks($event->getNode(), $this->finalRegex);
61+
$node = $event->getNode();
62+
if ($node instanceof Text && !($node->parent() instanceof Link)) {
63+
self::processAutolinks($node, $this->finalRegex);
6364
}
6465
}
6566
}

tests/EmailAutolinkProcessorTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,8 @@ public function dataProviderForEmailAutolinks()
4747
yield ['a.b-c_d@a.b.', '<p><a href="mailto:a.b-c_d@a.b">a.b-c_d@a.b</a>.</p>'];
4848
yield ['a.b-c_d@a.b-', '<p>a.b-c_d@a.b-</p>'];
4949
yield ['a.b-c_d@a.b_', '<p>a.b-c_d@a.b_</p>'];
50+
51+
// Regression: CommonMark autolinks should not be double-linked
52+
yield ['<foo@example.com>', '<p><a href="mailto:foo@example.com">foo@example.com</a></p>'];
5053
}
5154
}

tests/UrlAutolinkProcessorTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,8 @@ public function dataProviderForAutolinkTests()
7272

7373
// Regression: two links with one underscore each
7474
yield ["https://eventum.example.net/history.php?iss_id=107092\nhttps://gitlab.example.net/group/project/merge_requests/39#note_150630", "<p><a href=\"https://eventum.example.net/history.php?iss_id=107092\">https://eventum.example.net/history.php?iss_id=107092</a>\n<a href=\"https://gitlab.example.net/group/project/merge_requests/39#note_150630\">https://gitlab.example.net/group/project/merge_requests/39#note_150630</a></p>"];
75+
76+
// Regression: CommonMark autolinks should not be double-linked
77+
yield ['<https://www.google.com>', '<p><a href="https://www.google.com">https://www.google.com</a></p>'];
7578
}
7679
}

0 commit comments

Comments
 (0)