diff --git a/src/components/Note/MarkdownArticle/MarkdownArticle.tsx b/src/components/Note/MarkdownArticle/MarkdownArticle.tsx index 8f04e83..0b82956 100644 --- a/src/components/Note/MarkdownArticle/MarkdownArticle.tsx +++ b/src/components/Note/MarkdownArticle/MarkdownArticle.tsx @@ -444,7 +444,8 @@ function parseMarkdownContent( // Add text before pattern if (pattern.index > lastIndex) { const text = content.slice(lastIndex, pattern.index) - if (text) { + // Skip whitespace-only text to avoid empty spans between block elements + if (text && text.trim()) { // Process text for inline formatting (bold, italic, etc.) // But skip if this text is part of a table (tables are handled as block patterns) const isInTable = blockLevelPatterns.some(p => @@ -597,10 +598,11 @@ function parseMarkdownContent( ) } else if (pattern.type === 'numbered-list-item') { - const { text } = pattern.data + const { text, number } = pattern.data const listContent = parseInlineMarkdown(text, `numbered-${patternIdx}`, footnotes) + const itemNumber = number ? parseInt(number, 10) : undefined parts.push( -
  • +
  • {listContent}
  • ) @@ -730,7 +732,8 @@ function parseMarkdownContent( // Add remaining text if (lastIndex < content.length) { const text = content.slice(lastIndex) - if (text) { + // Skip whitespace-only text to avoid empty spans + if (text && text.trim()) { // Process text for inline formatting // But skip if this text is part of a table const isInTable = blockLevelPatterns.some(p => @@ -750,11 +753,26 @@ function parseMarkdownContent( return { nodes: formattedContent, hashtagsInContent, footnotes } } + // Filter out empty spans before wrapping lists + const filteredParts = parts.filter(part => { + if (React.isValidElement(part) && part.type === 'span') { + const children = part.props.children + // Filter out spans with only whitespace or empty content + if (typeof children === 'string' && !children.trim()) { + return false + } + if (Array.isArray(children) && children.every(child => typeof child === 'string' && !child.trim())) { + return false + } + } + return true + }) + // Wrap list items in