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) <noreply@anthropic.com>
This commit is contained in:
codytseng 2026-03-25 11:02:00 +08:00
parent c7eef9fa48
commit e80474099e
2 changed files with 5 additions and 5 deletions

View file

@ -122,7 +122,7 @@ export default function MarkdownContent({
)
return (
<div className="space-y-3">
<div className="space-y-3 whitespace-normal">
<Markdown
remarkPlugins={[remarkGfm, remarkNostr, remarkInlineContent]}
urlTransform={(url) => {

View file

@ -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