Skip to content

fix(export): number nested BlockNote lists on their own - #1937

Merged
MODSetter merged 1 commit into
MODSetter:devfrom
MohammadHijjawi97:fix/blocknote-nested-numbered-lists
Sep 28, 2026
Merged

MODSetter merged 1 commit into
MODSetter:devfrom
MohammadHijjawi97:fix/blocknote-nested-numbered-lists

Conversation

@MohammadHijjawi97

@MohammadHijjawi97 MohammadHijjawi97 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

What

blocknote_to_markdown renders a block's children with a fresh numbered-list counter instead of reusing and overwriting the parent's.

Why

Children were rendered with the parent's numbered_list_counter, and the value they returned replaced it. A nested numbered list therefore continued the parent's numbering, and the next sibling skipped ahead. For a list First (children Sub A, Sub B), then Second:

before:            after:
1. First           1. First
  2. Sub A           1. Sub A
  3. Sub B           2. Sub B
4. Second          2. Second

This converter is used when exporting or opening legacy BlockNote notes (export_service.resolve_document_markdown, editor_routes), so the exported Markdown had wrong numbers. test_mixed_deep_nested_children_indentation had captured the old output (2. Nested Child 2 for a child of 1. Nested Child 1) and is updated.

How to test

cd surfsense_backend
uv run pytest tests/unit/utils/test_blocknote_to_markdown.py

The new test fails before the change and passes after. ruff check and ruff format --check are clean on the changed files.

High-level PR Summary

This PR fixes a bug in the blocknote_to_markdown converter where nested numbered lists incorrectly continued their parent's numbering instead of starting fresh at 1. The fix ensures each nested list maintains its own independent counter, preventing sibling items from skipping numbers. This affects Markdown exports and legacy BlockNote note rendering.

⏱️ Estimated Review Time: 5-15 minutes

💡 Review Order Suggestion
Order File Path
1 surfsense_backend/tests/unit/utils/test_blocknote_to_markdown.py
2 surfsense_backend/app/utils/blocknote_to_markdown.py

Need help? Join our Discord

Children of a block were rendered with the parent's numbered-list counter
and handed the result back to it, so a nested numbered list continued the
parent's numbering ("1. A / 2. A.1") and the next sibling skipped ahead
("4. B"). Children now count from zero and the parent's counter is kept.
@vercel

vercel Bot commented Sep 28, 2026

Copy link
Copy Markdown

@MohammadHijjawi97 is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Sep 28, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: b1395669-75f8-43d2-a139-f193de51ca19

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@MODSetter MODSetter left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MODSetter
MODSetter merged commit d084e8b into MODSetter:dev Sep 28, 2026
14 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants