fix(renderer): preserve ordered flag on list items (#6700)

openItem() received ordered but dropped it from the item constructor, so
it.ordered was always undefined and every item looked unordered at the
task-list check. An ordered item whose text begins with [x] or [ ] (e.g.
'1. [x] shipped') was silently converted to a task icon and lost its
literal prefix. Task-list rendering now applies only to unordered items.
This commit is contained in:
webtecnica committed 2026-09-08 01:16:00 -03:00
1 parent 13dd97d60d
commit b810e5466f
2 files changed
+15 -1

No files matched your search

+1 -1
View File
@@ -7829,7 +7829,7 @@ function renderMd(raw){
if(listStack[depth]) listStack.pop();
listStack[depth]=openList(depth,ordered);
}
const item={value,content:[content],sublists:[]};
const item={ordered,value,content:[content],sublists:[]};
listStack[depth].items.push(item);
itemStack[depth]=item;
for(let k=itemStack.length-1;k>depth;k--) itemStack.pop();
+14
View File
@@ -420,6 +420,20 @@ class TestMixedNestedLists:
) in out, out
assert "</li>" not in out, out
def test_ordered_item_with_task_marker_keeps_literal_prefix(self, driver_path):
"""Task-list rendering applies only to unordered items: an ordered
item whose text starts with [x]/[ ] must keep its literal prefix
(e.g. '1. [x] shipped') instead of being silently converted to a
✅/☐ task icon (review fix for #6700: openItem() dropped `ordered`
from the item constructor, so every item looked unordered)."""
out = _render(driver_path, "1. [x] shipped\n2. [ ] pending")
assert 'class="task-done"' not in out, out
assert 'class="task-todo"' not in out, out
assert "✅" not in out, out
assert "☐" not in out, out
assert '<ol><li value="1">[x] shipped</li>' in out, out
assert '<li value="2">[ ] pending</li>' in out, out
# ─────────────────────────────────────────────────────────────────────────────
# Block-level constructs INSIDE blockquotes — the six bugs documented in