mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-10-19 15:44:27 +00:00
Merge pull request #1937 from MohammadHijjawi97/fix/blocknote-nested-numbered-lists
fix(export): number nested BlockNote lists on their own
This commit is contained in:
commit
d084e8bdef
2 changed files with 23 additions and 3 deletions
|
|
@ -217,9 +217,12 @@ def _render_block(
|
|||
|
||||
# --- Render nested children (indented) ---
|
||||
if children:
|
||||
# Children form their own list: numbering starts over and must not
|
||||
# leak into this block's siblings.
|
||||
child_counter = 0
|
||||
for child in children:
|
||||
child_lines, numbered_list_counter = _render_block(
|
||||
child, indent=indent + 1, numbered_list_counter=numbered_list_counter
|
||||
child_lines, child_counter = _render_block(
|
||||
child, indent=indent + 1, numbered_list_counter=child_counter
|
||||
)
|
||||
lines.extend(child_lines)
|
||||
|
||||
|
|
|
|||
|
|
@ -494,7 +494,24 @@ def test_mixed_deep_nested_children_indentation():
|
|||
|
||||
assert (
|
||||
blocknote_to_markdown(test_block)
|
||||
== f"- Parent\n{prefix}- Child 1\n{prefix * 2}1. Nested Child 1\n{prefix * 3}2. Nested Child 2\n{prefix}- Child 2\n{prefix}- Child 3"
|
||||
== f"- Parent\n{prefix}- Child 1\n{prefix * 2}1. Nested Child 1\n{prefix * 3}1. Nested Child 2\n{prefix}- Child 2\n{prefix}- Child 3"
|
||||
)
|
||||
|
||||
|
||||
def test_nested_numbered_list_numbers_independently_of_parent():
|
||||
"""A nested numbered list starts at 1 and leaves the parent list's count alone."""
|
||||
|
||||
def item(text, children=()):
|
||||
return {
|
||||
"type": "numberedListItem",
|
||||
"content": [{"type": "text", "text": text}],
|
||||
"children": list(children),
|
||||
}
|
||||
|
||||
blocks = [item("First", [item("Sub A"), item("Sub B")]), item("Second")]
|
||||
|
||||
assert (
|
||||
blocknote_to_markdown(blocks) == "1. First\n 1. Sub A\n 2. Sub B\n2. Second"
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue