From bd0f6ecbfc55c245813d07a558f8b8e89465af0a Mon Sep 17 00:00:00 2001 From: Edwin Noorlander Date: Wed, 19 Nov 2025 13:49:39 +0100 Subject: [PATCH] Fix Markdown link conversion in parseMarkdown function - Added regex to convert [text](url) to HTML links - Added conversion for relative internal links to CMS format - Links now work properly in blog posts and home page --- index.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/index.php b/index.php index bb303a5..4965702 100644 --- a/index.php +++ b/index.php @@ -211,6 +211,14 @@ class CodePressCMS { $body = preg_replace('/# (.+)/', '

$1

', $body); $body = preg_replace('/\*\*(.+?)\*\*/', '$1', $body); $body = preg_replace('/\*(.+?)\*/', '$1', $body); + + // Convert Markdown links to HTML links + $body = preg_replace('/\[([^\]]+)\]\(([^)]+)\)/', '$1', $body); + + // Convert relative internal links to CMS format + $body = preg_replace('/href="\/blog\/([^"]+)"/', 'href="?page=blog/$1"', $body); + $body = preg_replace('/href="\/([^"]+)"/', 'href="?page=$1"', $body); + $body = preg_replace('/\n\n/', '

', $body); $body = '

' . $body . '

'; $body = preg_replace('/

<\/p>/', '', $body);