From e80474099edfa5c2e26668f246c86ac05a04e9f7 Mon Sep 17 00:00:00 2001 From: codytseng Date: Wed, 25 Mar 2026 11:02:00 +0800 Subject: [PATCH] fix: improve markdown detection and fix line spacing in embedded notes Count total occurrences of medium signals in containsMarkdown instead of only distinct types, so repeated patterns like multiple list items correctly trigger markdown rendering. Add whitespace-normal to MarkdownContent to prevent inherited whitespace-pre-wrap from parent note content causing inconsistent line spacing in embedded notes. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/components/MarkdownContent/index.tsx | 2 +- src/lib/markdown.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/MarkdownContent/index.tsx b/src/components/MarkdownContent/index.tsx index ebbe57e..01a5a98 100644 --- a/src/components/MarkdownContent/index.tsx +++ b/src/components/MarkdownContent/index.tsx @@ -122,7 +122,7 @@ export default function MarkdownContent({ ) return ( -
+
{ diff --git a/src/lib/markdown.ts b/src/lib/markdown.ts index c8f7036..841a945 100644 --- a/src/lib/markdown.ts +++ b/src/lib/markdown.ts @@ -34,10 +34,10 @@ export function containsMarkdown(content: string): boolean { let matchCount = 0 for (const pattern of mediumPatterns) { - if (pattern.test(cleaned)) { - matchCount++ - if (matchCount >= 2) return true - } + const globalPattern = new RegExp(pattern.source, pattern.flags.includes('m') ? 'gm' : 'g') + const occurrences = (cleaned.match(globalPattern) || []).length + matchCount += occurrences + if (matchCount >= 2) return true } return false