webui: add rehype plugin to restore HTML in Markdown table cells #17477
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.


Make sure to read the contributing guidelines before submitting a PR
Description
When writing <br> or <ul><li>...</li></ul> inside Markdown table cells, they were displayed as raw text instead of being rendered as actual HTML elements.
This happens because the remark/rehype pipeline neutralizes inline HTML as literal text (via remarkLiteralHtml) so that XML/HTML snippets in LLM responses display as-is instead of being rendered. For lists, the pipeline can also fragment the markup across multiple AST nodes, so pattern detection fails.
The fix is a small rehype plugin that runs after Markdown conversion. It parses whitelisted HTML patterns (<br>, <ul><li>) from text nodes and replaces them with actual HAST element nodes. For lists, adjacent siblings are combined first to handle fragmentation.
Lists are validated strictly: if there's garbage text mixed in, it stays as raw text to avoid creating broken HTML.
Close #17462