feat(asides): attach standalone asides to preceding paragraphs - #327
Merged
Conversation
Contributor
There was a problem hiding this comment.
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
rehypeAttachAsidesToPreviousParagraphand integrated it into both the Markdown and HTML processing pipelines ahead of grounding/grouping. - Simplified
rehypeGroupAsidesby 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.
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.
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
Verification
npm test— 1,038 passed, 23 skippednpm run lintnpm run build