Merge pull request #1355 from ArthurHoaro/hotfix/feed-md-directlink

Markdown plugin: fix RSS feed direct link reverse
This commit is contained in:
ArthurHoaro 2019-08-15 12:59:57 +02:00 committed by GitHub
commit 188a99db99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -259,7 +259,7 @@ function reverse_space2nbsp($description)
function reverse_feed_permalink($description)
{
return preg_replace('@&#8212; <a href="([^"]+)" title="[^"]+">(\w+)</a>$@im', '&#8212; [$2]($1)', $description);
return preg_replace('@&#8212; <a href="([^"]+)" title="[^"]+">([^<]+)</a>$@im', '&#8212; [$2]($1)', $description);
}
/**

View file

@ -156,6 +156,16 @@ class PluginMarkdownTest extends \PHPUnit\Framework\TestCase
$this->assertEquals($expected, $processedText);
}
public function testReverseFeedDirectLink()
{
$text = 'Description... ';
$text .= '&#8212; <a href="http://domain.tld/?0oc_VQ" title="Direct link">Direct link</a>';
$expected = 'Description... &#8212; [Direct link](http://domain.tld/?0oc_VQ)';
$processedText = reverse_feed_permalink($text);
$this->assertEquals($expected, $processedText);
}
public function testReverseLastFeedPermalink()
{
$text = 'Description... ';