From 12b14f2d897d45c9a91a7b4adb9714c660438815 Mon Sep 17 00:00:00 2001 From: Codepy <1942171924@qq.com> Date: Mon, 28 Jul 2025 22:30:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(BlogMake):=20=E4=BF=AE=E5=A4=8DMarkdown?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E8=A7=A3=E6=9E=90=E9=94=99=E8=AF=AF=E5=B9=B6?= =?UTF-8?q?=E4=BC=98=E5=8C=96HTML=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复正则表达式中的分组引用错误,确保h2和h3标题正确解析 优化博客页面样式,添加动画效果和响应式设计 移除调试用的echo语句 --- BlogMake.php | 6 +- posts/1.html | 182 ++++++++++++++++++++++++++++++++++++++++++++----- static/md/1.md | 2 +- 3 files changed, 169 insertions(+), 21 deletions(-) diff --git a/BlogMake.php b/BlogMake.php index d42980d..b870994 100644 --- a/BlogMake.php +++ b/BlogMake.php @@ -87,6 +87,8 @@ class BlogMake { // 读取markdown内容并解析 $mdContent = file_get_contents($mdFile); $content = $this->parseMarkdown($mdContent); + //echo "解析Markdown文件:{$mdFile}\n"; + //echo "解析Markdown内容:{$content}\n"; // 查找对应的博客信息 $blogInfo = null; @@ -115,8 +117,8 @@ class BlogMake { private function parseMarkdown($markdown) { // 标题转换 $markdown = preg_replace('/^# (.*)$/m', '

$1

', $markdown); - $markdown = preg_replace('/^## (.*)$/m', '

$2

', $markdown); - $markdown = preg_replace('/^### (.*)$/m', '

$3

', $markdown); + $markdown = preg_replace('/^## (.*)$/m', '

$1

', $markdown); + $markdown = preg_replace('/^### (.*)$/m', '

$1

', $markdown); // 粗体和斜体 $markdown = preg_replace('/\*\*(.*?)\*\*/', '$1', $markdown); diff --git a/posts/1.html b/posts/1.html index 746fff4..a23aaaf 100644 --- a/posts/1.html +++ b/posts/1.html @@ -2,15 +2,17 @@ -博客标题1 | +博客标题1 | JSONBlog -
-
-
-
-
-
-

博客标题1

-
作者: 作者1 | 发布时间: 2021-01-01
-

+
+
+
+
+
+
+ +
+

博客标题1

+ +

1.安装依赖

+
+ + \ No newline at end of file diff --git a/static/md/1.md b/static/md/1.md index 16eae33..c7792d4 100644 --- a/static/md/1.md +++ b/static/md/1.md @@ -1 +1 @@ -## 1. 安装依赖 \ No newline at end of file +## 1.安装依赖 \ No newline at end of file -- Gitee