Skip to content

Commit 8f499b4

Browse files
JohnMcLearclaude
andauthored
fix(ExportHtml): don't poison ol counter when closing a sibling ul (#7791)
When an ordered-list level was the only consumer of olItemCounts, closing any list at that depth (including an unordered list that happens to share the level) reset olItemCounts[level] to 0. A later, unrelated ordered list at the same depth then took the "counter exists but is 0" branch in the ol-opening logic and emitted `<ol class="...">` without the start attribute that line.start would have supplied. Round-trip: importing <ul>...<ul>...</ul></ul><ol><li>x<ol><li>y</li></ol></li></ol> exported the inner ol as `<ol class="number">` instead of `<ol start="2" class="number">`, because the closing of the inner bullet ul wrote olItemCounts[2]=0 before the outer ol even opened. Gate the reset on line.listTypeName === 'number' so closing an unordered list never touches the ol bookkeeping. Closing an actual ordered list still resets, as #7470 intended. Fixes #7786 Fixes #7787 Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 0e90184 commit 8f499b4

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/node/utils/ExportHtml.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,10 @@ const getHTMLFromAtext = async (pad:PadType, atext: AText, authorColors?: string
470470
// preserve counters so numbering can continue after interruptions.
471471
// Use 0 as sentinel (not delete) so the ol-opening logic knows this
472472
// level was explicitly reset and won't fall back to line.start.
473-
if (diff + 1 > actualNextLevel) {
473+
// Only reset when closing an ordered list — closing an unordered list
474+
// at the same level must not poison the ol counter for a future
475+
// unrelated ol at this level (which would still want line.start).
476+
if (line.listTypeName === 'number' && diff + 1 > actualNextLevel) {
474477
olItemCounts[diff + 1] = 0;
475478
}
476479

0 commit comments

Comments
 (0)