Skip to content

feat(asides): attach standalone asides to preceding paragraphs - #327

Merged
cpsievert merged 4 commits into
mainfrom
feat/automatic-aside-attachment
Aug 18, 2026
Merged

feat(asides): attach standalone asides to preceding paragraphs#327
cpsievert merged 4 commits into
mainfrom
feat/automatic-aside-attachment

Conversation

@cpsievert

@cpsievert cpsievert commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Aside markers now stay beside the paragraph they support even when generated Markdown contains a blank line before the aside. This removes formatting sensitivity for server-verified citations while preserving normal block boundaries.

Motivated by posit-dev/commons#127

What changes

  • Attach an aside-only paragraph or direct aside sibling to the immediately preceding paragraph under the same parent.
  • Resolve attachment before grounded-text matching, grouping, and streaming state.
  • Preserve aside order, rich bodies, and list-item ownership.
  • Leave asides unchanged across code, lists, tables, headings, quotations, and mixed-content paragraphs.
  • Rebuild and distribute the browser assets for Python and R.

Verification

  • npm test — 1,038 passed, 23 skipped
  • npm run lint
  • npm run build

@cpsievert
cpsievert marked this pull request as ready for review August 18, 2026 23:14
@cpsievert
cpsievert requested a lite review from Copilot August 18, 2026 23:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves Markdown/HTML aside handling so standalone <shiny-aside> blocks (including those separated by a blank line in generated Markdown) are automatically attached to the immediately preceding paragraph under the same parent, enabling correct grounding/grouping without being sensitive to formatting.

Changes:

  • Added rehypeAttachAsidesToPreviousParagraph and integrated it into both the Markdown and HTML processing pipelines ahead of grounding/grouping.
  • Simplified rehypeGroupAsides by removing list-item-specific “move asides into paragraphs” logic now covered by the new attachment plugin.
  • Expanded test coverage across processor integration, the new plugin’s behavior, trailing-aside streaming behavior, and React rendering.

Reviewed changes

Copilot reviewed 10 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg-r/inst/lib/shiny/GIT_VERSION Updates packaged asset version reference for the R distribution.
pkg-py/src/shinychat/www/GIT_VERSION Updates packaged asset version reference for the Python distribution.
js/tests/markdown/processors.asides.test.ts Adds end-to-end tests asserting correct grounding/numbering when asides are separated by blank lines or are direct HTML siblings.
js/tests/markdown/plugins/rehypeGroupAsides.test.ts Updates grouping tests to reflect new attachment behavior and verify <br> trimming before grouped asides.
js/tests/markdown/plugins/rehypeAttachAsidesToPreviousParagraph.test.ts Adds focused unit tests for the new attachment plugin across paragraphs, raw HTML siblings, and list-item ownership boundaries.
js/tests/markdown/plugins/markTrailingAsides.test.ts Ensures trailing-aside “pending” marking works after automatic attachment (streaming path).
js/tests/markdown/MarkdownContent.test.tsx Validates React rendering attaches direct HTML asides to the preceding paragraph.
js/src/markdown/processors.ts Wires the new attachment plugin into both markdownProcessor and htmlProcessor in the intended order.
js/src/markdown/plugins/rehypeGroupAsides.ts Removes now-redundant loose-list-item aside relocation logic.
js/src/markdown/plugins/rehypeAttachAsidesToPreviousParagraph.ts Introduces the new rehype plugin that attaches standalone asides to the previous paragraph under the same parent.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@cpsievert
cpsievert merged commit c1654aa into main Aug 18, 2026
16 of 17 checks passed
@cpsievert
cpsievert deleted the feat/automatic-aside-attachment branch August 18, 2026 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants