Skip to content

fix(js): preserve <shiny-aside> in Markdown list items - #305

Merged
cpsievert merged 10 commits into
mainfrom
fix/rich-aside-list-item
Aug 13, 2026
Merged

fix(js): preserve <shiny-aside> in Markdown list items#305
cpsievert merged 10 commits into
mainfrom
fix/rich-aside-list-item

Conversation

@cpsievert

@cpsievert cpsievert commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Follow up to #278

Why this matters

Rich <shiny-aside> content can follow claims in Markdown lists without changing list structure, corrupting the aside body, or losing document-scoped Markdown behavior.

Previously, the Markdown parser could place an aside opener inside a list item while placing its block body and closing tag outside the list. The resulting raw HTML span caused adjacent list items to nest incorrectly.

What changed

Complete asides opened from list items are normalized to the list item's required continuation indentation before the complete document is parsed again. Keeping the final Markdown in one document parse preserves reference definitions, footnotes, nested-list structure, and relative code indentation without replacing micromark's list tokenizer.

The change also preserves:

  • Rich block Markdown inside aside bodies
  • Inline aside openers and multi-digit ordered-list markers
  • Literal aside markup in code spans and code fences
  • Authored custom elements without internal placeholder collisions
  • Incomplete tags during streaming
  • Existing URL sanitization and React-based rendering

The rebuilt JavaScript assets are included for the Python and R packages.

Verification

  • Focused aside/template tests: 19 passed
  • Full JavaScript suite: 970 passed, 23 skipped
  • npm run lint
  • npm run build
  • Distributed JS and source-map hashes match across js/dist, Python, and R package assets

@cpsievert
cpsievert marked this pull request as ready for review August 12, 2026 22:58
@cpsievert
cpsievert requested a lite review from Copilot August 12, 2026 22:58

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 shinychat’s Markdown pipeline so rich <shiny-aside> blocks that are opened from within Markdown list items remain structurally attached to the correct list item. It does this by normalizing the indentation of complete asides discovered in list-item contexts and then re-parsing the full Markdown document so that reference definitions/footnotes and list structure are preserved.

Changes:

  • Added a remark plugin that detects complete <shiny-aside>...</shiny-aside> regions opened from list items and rewrites their continuation indentation so the aside body stays inside the list item.
  • Integrated the new normalization plugin into the main markdownProcessor pipeline (before remark-rehype).
  • Expanded tests to cover list-adjacent rich asides (including nested lists, blockquotes, reference definitions, footnotes, and URL sanitization) and streaming finalization behavior; updated distributed asset version stamps.

Reviewed changes

Copilot reviewed 6 out of 12 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 web-asset version stamp for the R distribution.
pkg-py/src/shinychat/www/GIT_VERSION Updates packaged web-asset version stamp for the Python distribution.
js/tests/markdown/plugins/rewriteAsideTemplate.test.ts Adds Markdown parsing assertions for list-item asides, nesting, refs/footnotes, and literal-aside-in-code scenarios.
js/tests/chat/AsideGroup.test.tsx Adds a streaming/non-streaming render test ensuring adjacent list-item asides finalize correctly without corrupting list structure.
js/src/markdown/processors.ts Wires the new remark normalization step into the main markdown processor.
js/src/markdown/plugins/normalizeAsideMarkdown.ts Implements the list-item aside indentation normalization + document reparse transformer.

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

@cpsievert cpsievert changed the title fix(js): preserve rich asides in Markdown list items fix(js): preserve <shiny-aside> in Markdown list items Aug 13, 2026
@cpsievert
cpsievert merged commit 6ee547b into main Aug 13, 2026
17 checks passed
@cpsievert
cpsievert deleted the fix/rich-aside-list-item branch August 13, 2026 00:11
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