fix(matrix): preserve markdown table structure

This commit is contained in:
Sarvesh 2026-06-13 11:18:43 +05:30 committed by Teknium
parent 4373e802a1
commit 45f9099e51
2 changed files with 19 additions and 1 deletions

View file

@ -209,7 +209,7 @@ class _MatrixHtmlSanitizer(HTMLParser):
_ALLOWED_TAGS = {
"a", "b", "blockquote", "br", "code", "del", "em", "h1", "h2", "h3",
"h4", "h5", "h6", "hr", "i", "li", "ol", "p", "pre", "s", "strike",
"strong", "ul",
"strong", "table", "tbody", "td", "th", "thead", "tr", "ul",
}
_VOID_TAGS = {"br", "hr"}

View file

@ -1090,6 +1090,24 @@ class TestMatrixMarkdownToHtml:
assert "<code" in result
assert "print" in result
def test_matrix_markdown_preserves_table_structure(self):
table = "\n".join(
[
"| Item | Quantity |",
"| --- | --- |",
"| Apples | 4 |",
"| Bread | 1 |",
]
)
result = self.adapter._markdown_to_html(table)
assert "<table>" in result
assert "<thead>" in result
assert "<tbody>" in result
assert "<th>Item</th>" in result
assert "<td>Apples</td>" in result
# ---------------------------------------------------------------------------
# Helper: display name extraction