Skip to content

Conversation

@arthrod
Copy link

@arthrod arthrod commented Jan 9, 2026

Summary

  • Fixes ordered list numbering that restarts at "1." after a nested list closes
  • Uses a stack (_ol_id_stack) to preserve parent list context during nesting

Problem

When an ordered list contains a nested list, items after the nested list were restarting numbering at "1." instead of continuing.

Example:

<ol>
  <li>First</li>      <!-- Shows as 1. ✓ -->
  <li>Second          <!-- Shows as 2. ✓ -->
    <ol>
      <li>Second.A</li>
      <li>Second.B</li>
    </ol>
  </li>
  <li>Third</li>      <!-- Was showing 1. ✗ (should be 3.) -->
</ol>

Root Cause

The handle_li function correctly uses current_ol_num_id to track list continuity. However, when a nested <ol> opens, current_ol_num_id is updated to a new value. When the nested <ol> closes, the parent's current_ol_num_id was not being restored.

Solution

Track current_ol_num_id in a stack to preserve parent context:

  • On <ol> open: push current ID to stack before creating new one
  • On <ol> close: pop from stack to restore parent's ID

Test plan

  • Verify nested ordered lists maintain correct numbering
  • Verify deeply nested lists (3+ levels) work correctly
  • Verify mixed nested lists (ol inside ul inside ol) work correctly

arthrod and others added 2 commits January 8, 2026 22:17
Refactor HTML-to-DOCX with centralized styles and test coverage
When an ordered list contains a nested list, items after the nested
list were restarting numbering at "1." instead of continuing from
the parent list's count.

The fix uses a stack (_ol_id_stack) to preserve parent list context:
- On <ol> open: push current_ol_num_id to stack before creating new one
- On <ol> close: pop from stack to restore parent's numId

Example fix:
<ol>
  <li>First</li>      <!-- 1. -->
  <li>Second          <!-- 2. -->
    <ol>
      <li>Second.A</li>
      <li>Second.B</li>
    </ol>
  </li>
  <li>Third</li>      <!-- Now shows 3. instead of 1. -->
</ol>
@dfop02 dfop02 self-requested a review January 11, 2026 21:16
@dfop02 dfop02 added bug Something isn't working good first issue Good for newcomers labels Jan 11, 2026
@dfop02 dfop02 changed the base branch from main to release/1.1.4 January 12, 2026 11:57
@dfop02 dfop02 self-assigned this Jan 14, 2026
@dfop02
Copy link
Owner

dfop02 commented Jan 25, 2026

hey @arthrod , Just a kindly reminder. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working good first issue Good for newcomers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants