feat(pampa): block-level attrs on list items (<li class>) (bd-aeyss6p5)#314
Merged
Merged
Conversation
Extend the Para block-attr capability (bd-itqcfxc3, PR #310) to list items: `- item {.foo}` now renders `<li class="foo">` across all three renderers (q2 render HTML, q2 preview JSON->React incl. revealjs incremental, and JSON round-trips). A Pandoc list item is `Vec<Block>` with no per-item Attr field, so an authored item attr lands as a trailing `Inline::Attr` in the item's last block. It is hoisted onto the `<li>` at write time and folded back at read time; the AST shape is unchanged. - block_attr.rs: `split_list_item_attr` collects the trailing attr from an item's last Para/Plain and returns a stripped clone of that block. The stripped clone is what keeps the class off an inner `<p>` (precedence trap). - html.rs: `write_list_item` / `composed_list_item_attr` hoist onto `<li>`, composing with the incremental `fragment` class. - json.rs writer: parallel `itemAttr` sibling key (the table `rowsS` precedent), alphabetical key order (c, itemAttr, l?, s, t). A fast path keeps ordinary lists byte-for-byte unchanged; Pandoc ignores `itemAttr`. - json.rs reader: `fold_item_attrs` restores the trailing `Inline::Attr`. - preview-renderer: shared `liItemAttrProps` helper applied in both the incremental component path (BulletList/OrderedList) and the editable registry path (dispatch). `itemAttr` is dropped on in-preview edits (v1). Tests: 7 helper + 6 html + 4 json + 4 React vitest. End-to-end verified through the binary (html; json + pandoc graceful degrade; json->html and json->qmd round-trips). Full `cargo xtask verify` green (14/14). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends the
Parablock-attr capability (bd-itqcfxc3, #310) to list items:- item {.foo}now renders<li class="foo">across all three renderers —q2 render(HTML),q2 preview(JSON → React, including the revealjs incremental path), and AST→JSON→AST round-trips.A Pandoc list item is
Vec<Block>with no per-itemAttrfield, so an authored item attr lands as a trailingInline::Attrin the item's last block. It is hoisted onto the<li>at write time and folded back at read time; the AST shape is unchanged. The JSON wire form mirrors the tablerowsSprecedent — a parallel sibling key on the list node that Pandoc ignores.Changes
block_attr.rs—split_list_item_attrcollects the trailing attr from an item's lastPara/Plainand returns a stripped clone of that block. The clone is what keeps the class off an inner<p>(the precedence trap).html.rs—write_list_item/composed_list_item_attrhoist onto<li>, composing with the incrementalfragmentclass.json.rswriter — parallelitemAttrsibling key, alphabetical key order (c, itemAttr, l?, s, t). A fast path keeps ordinary lists byte-for-byte unchanged.json.rsreader —fold_item_attrsrestores the trailingInline::Attr.liItemAttrPropshelper applied in both the incremental component path (BulletList/OrderedList) and the editable registry path (dispatch.tsx).Design decisions (v1)
itemAttrdropped on in-preview edits — the registry renderers'setLocalAstrebuilds the list node withoutitemAttr. Documented inline; follow-up if preservation is wanted.Para/Plainlast block — exactly where the parser places authored attrs.Testing
-t html→<li id="one" class="alpha" data-key="val">;-t jsonemitsitemAttrandpandoc -f jsondegrades gracefully (plain<li>, no error); json→html and json→qmd both round-trip the item attrs.cargo xtask verifygreen (14/14) — incl. WASM rebuild + hub-client + preview-renderer suites.Not done
No live browser
q2 previewrevealjs session against WASM-served output — the chain is covered piecewise (Rust JSON-contract tests + React vitest through the real component tree).Plan:
claude-notes/plans/2026-06-18-list-item-block-attrs.md. Strand: bd-aeyss6p5 (discovered-from bd-itqcfxc3, related bd-38ioql41).🤖 Generated with Claude Code