From 15ecda86a7272dcc92ddc8a9b4485a8be0c2d86a Mon Sep 17 00:00:00 2001
From: Caen De Silva
Date: Wed, 24 Jul 2024 17:58:44 +0200
Subject: [PATCH] Update Markdown link support to work without single quotes
---
.../Processing/DynamicMarkdownLinkProcessor.php | 12 ++++++------
.../DynamicMarkdownLinkProcessorTest.php | 17 +++++++++++++++++
2 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/packages/framework/src/Markdown/Processing/DynamicMarkdownLinkProcessor.php b/packages/framework/src/Markdown/Processing/DynamicMarkdownLinkProcessor.php
index 52ae7a605eb..bf00a9a8c1a 100644
--- a/packages/framework/src/Markdown/Processing/DynamicMarkdownLinkProcessor.php
+++ b/packages/framework/src/Markdown/Processing/DynamicMarkdownLinkProcessor.php
@@ -22,14 +22,14 @@ public static function postprocess(string $html): string
protected static function patterns(): array
{
return [
- '/ function (array $matches): string {
- return ' function (array $matches): string {
+ return ' function (array $matches): string {
- return ' function (array $matches): string {
+ return ' function (array $matches): string {
- return ' function (array $matches): string {
+ return 'Home
';
$expected = 'Home
';
$this->assertSame($expected, DynamicMarkdownLinkProcessor::postprocess($input));
+
+ $inputUnquoted = 'Home
';
+ $this->assertSame($expected, DynamicMarkdownLinkProcessor::postprocess($inputUnquoted));
}
public function testRelativeLinkReplacement()
@@ -43,6 +46,9 @@ public function testRelativeLinkReplacement()
$input = 'About
';
$expected = 'About
';
$this->assertSame($expected, DynamicMarkdownLinkProcessor::postprocess($input));
+
+ $inputUnquoted = 'About
';
+ $this->assertSame($expected, DynamicMarkdownLinkProcessor::postprocess($inputUnquoted));
}
public function testAssetReplacement()
@@ -50,6 +56,9 @@ public function testAssetReplacement()
$input = '';
$expected = '';
$this->assertSame($expected, DynamicMarkdownLinkProcessor::postprocess($input));
+
+ $inputUnquoted = '';
+ $this->assertSame($expected, DynamicMarkdownLinkProcessor::postprocess($inputUnquoted));
}
public function testMultipleReplacements()
@@ -67,6 +76,14 @@ public function testMultipleReplacements()
HTML;
$this->assertSame($expected, DynamicMarkdownLinkProcessor::postprocess($input));
+
+ $inputUnquoted = <<<'MARKDOWN'
+ Home
+ About
+
+ MARKDOWN;
+
+ $this->assertSame($expected, DynamicMarkdownLinkProcessor::postprocess($inputUnquoted));
}
public function testNoReplacements()