Skip to content

Conversation

@ServeurpersoCom
Copy link
Collaborator

@ServeurpersoCom ServeurpersoCom commented Nov 24, 2025

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

@ServeurpersoCom
Copy link
Collaborator Author

Non-regression test prompt :
Prompt.txt

Before :
Before
After :
After

The remark/rehype pipeline neutralizes inline HTML as literal text
(remarkLiteralHtml) so that XML/HTML snippets in LLM responses display
as-is instead of being rendered. This causes <br> and <ul> markup in
table cells to show as plain text.

This plugin traverses the HAST post-conversion, parses whitelisted HTML
patterns (<br>, <ul><li>) from text nodes, and replaces them with actual
HAST element nodes. For lists, adjacent siblings must be combined first
as the AST fragmentation breaks pattern matching.

Strict validation rejects malformed markup, keeping it as raw text.
@allozaur allozaur merged commit b1846f1 into ggml-org:master Nov 25, 2025
13 of 14 checks passed
am17an pushed a commit to am17an/llama.cpp that referenced this pull request Nov 27, 2025
…l-org#17477)

* webui: add rehype plugin to restore HTML in Markdown table cells

The remark/rehype pipeline neutralizes inline HTML as literal text
(remarkLiteralHtml) so that XML/HTML snippets in LLM responses display
as-is instead of being rendered. This causes <br> and <ul> markup in
table cells to show as plain text.

This plugin traverses the HAST post-conversion, parses whitelisted HTML
patterns (<br>, <ul><li>) from text nodes, and replaces them with actual
HAST element nodes. For lists, adjacent siblings must be combined first
as the AST fragmentation breaks pattern matching.

Strict validation rejects malformed markup, keeping it as raw text.

* chore: update webui build output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Misc. bug: Web UI displays raw html tags (e.g. <br>) instead of rendering them in markdown tables

2 participants