fix: lists rendering p tags causing new lines

This commit is contained in:
7w1 committed 2026-05-26 23:37:09 -05:00
1 parent 744ebda30e
commit b0349b431c
3 files changed
+21 -2

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
default: patch
---
Fixed lists rendering `p` html tags on new lines.
@@ -446,4 +446,15 @@ describe('react custom html parser', () => {
expect(screen.queryByText('<test>')).not.toBeInTheDocument();
}
);
it('unwraps paragraph tags inside list items instead of rendering block breaks', () => {
const { container } = renderMessage(
'<ol><li><p>one</p></li><li><p>two</p></li></ol><ul><li><p>bullet</p></li></ul>'
);
expect(container.querySelector('p')).toBeNull();
expect(container.textContent).toContain('one');
expect(container.textContent).toContain('two');
expect(container.textContent).toContain('bullet');
});
});
+5 -2
View File
@@ -111,7 +111,7 @@ function KatexRenderer({
useEffect(() => {
let mounted = true;
Promise.all([import('katex'), import('katex/dist/katex.min.css')]).then(([katex]) => {
void Promise.all([import('katex'), import('katex/dist/katex.min.css')]).then(([katex]) => {
if (mounted) {
setHtml(katex.default.renderToString(math, { throwOnError: false, displayMode }));
}
@@ -430,7 +430,7 @@ export function CodeBlock({
const [copied, setCopied] = useTimeoutToggle();
const handleCopy = () => {
copyToClipboard(extractTextFromChildren(children));
void copyToClipboard(extractTextFromChildren(children));
setCopied();
};
@@ -631,6 +631,9 @@ export const getReactCustomHtmlParser = (
}
if (name === 'p') {
if (parent instanceof Element && parent.name === 'li') {
return <>{renderChildren()}</>;
}
return (
<Text {...props} className={classNames(css.Paragraph, css.MarginSpaced)} size="Inherit">
{renderChildren()}