Skip to content

Bug: Quote block parsing breaks on empty continuation lines #855

Description

@malibio

Summary

The markdown parser incorrectly handles multi-line quote blocks that contain empty continuation lines (> without content).

Steps to Reproduce

Import a markdown file with this content:

> **First line of quote**
>
> **Second line of quote**
> **Third line of quote**

Expected Result

One quote-block node containing all lines:

> **First line of quote**
>
> **Second line of quote**
> **Third line of quote**

Actual Result

Three separate nodes:

  1. quote-block: > **First line of quote**
  2. text: >
  3. text: (remaining content, not as quote-block)

Example in Production

See node bdeb3a1b-7a93-425a-b724-a45e850fb16c (NodeSpace Testing Guide):

Original file (docs/architecture/development/testing-guide.md):

> **✅ AUTHORITATIVE DOCUMENT**: This is the single source of truth...
>
> **Status**: Active (Updated 2025-01-16)
> **Scope**: Covers actual implementation approach...

Parsed children (first 3):

  • Index 0: quote-block - only first line
  • Index 1: text - just >
  • Index 2: text - should be part of quote

Root Cause

In packages/core/src/mcp/handlers/markdown.rs (lines 252-259):

} else if content_line.starts_with("> ") {
    // Quote block
    let mut quote_lines = vec![content_line];
    while i + 1 < lines.len() && lines[i + 1].trim_start().starts_with("> ") {
        i += 1;
        quote_lines.push(lines[i].trim_start());
    }
    ("quote-block", quote_lines.join("\n"), None, true, None)
}

Bug: The check starts_with("> ") requires a space after >. Empty quote continuation lines are just > (no space), so they don't match and the loop exits.

Fix

The condition should also match > alone (empty quote continuation):

while i + 1 < lines.len() {
    let next_trimmed = lines[i + 1].trim_start();
    if next_trimmed.starts_with("> ") || next_trimmed == ">" {
        i += 1;
        quote_lines.push(next_trimmed);
    } else {
        break;
    }
}

Acceptance Criteria

  • Multi-line quotes with empty continuation lines (>) are parsed as single quote-block
  • Quote block content preserves the > prefixes correctly (for rendering)
  • Add test case for multi-paragraph quotes
  • Re-import affected documents to fix existing data (or provide migration)

Metadata

Metadata

Assignees

Labels

backendbugSomething isn't working

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions