From: ArthurHoaro Date: Thu, 15 Aug 2019 10:56:32 +0000 (+0200) Subject: Markdown plugin: fix RSS feed direct link reverse X-Git-Tag: v0.12.0-beta~43^2 X-Git-Url: https://git.immae.eu/?p=github%2Fshaarli%2FShaarli.git;a=commitdiff_plain;h=354fb98cc96595870c1962d5939f0bab24951ffa Markdown plugin: fix RSS feed direct link reverse The plugin was only reversing permalinks and failed with setting rss_permalinks set to false --- diff --git a/plugins/markdown/markdown.php b/plugins/markdown/markdown.php index 628970d6..f6f66cc5 100644 --- a/plugins/markdown/markdown.php +++ b/plugins/markdown/markdown.php @@ -259,7 +259,7 @@ function reverse_space2nbsp($description) function reverse_feed_permalink($description) { - return preg_replace('@— (\w+)$@im', '— [$2]($1)', $description); + return preg_replace('@— ([^<]+)$@im', '— [$2]($1)', $description); } /** diff --git a/tests/plugins/PluginMarkdownTest.php b/tests/plugins/PluginMarkdownTest.php index 9ddbc558..15fa9ba5 100644 --- a/tests/plugins/PluginMarkdownTest.php +++ b/tests/plugins/PluginMarkdownTest.php @@ -156,6 +156,16 @@ class PluginMarkdownTest extends \PHPUnit\Framework\TestCase $this->assertEquals($expected, $processedText); } + public function testReverseFeedDirectLink() + { + $text = 'Description... '; + $text .= '— Direct link'; + $expected = 'Description... — [Direct link](http://domain.tld/?0oc_VQ)'; + $processedText = reverse_feed_permalink($text); + + $this->assertEquals($expected, $processedText); + } + public function testReverseLastFeedPermalink() { $text = 'Description... ';