From b0349b431cf7c3a7d8e48ea2e5ce05b4e73a92f8 Mon Sep 17 00:00:00 2001 From: 7w1 Date: Tue, 26 May 2026 23:37:09 -0500 Subject: [PATCH] fix: lists rendering p tags causing new lines --- .changeset/fix-list-rendering-p-tags.md | 5 +++++ src/app/plugins/react-custom-html-parser.test.tsx | 11 +++++++++++ src/app/plugins/react-custom-html-parser.tsx | 7 +++++-- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 .changeset/fix-list-rendering-p-tags.md diff --git a/.changeset/fix-list-rendering-p-tags.md b/.changeset/fix-list-rendering-p-tags.md new file mode 100644 index 000000000..813308d6c --- /dev/null +++ b/.changeset/fix-list-rendering-p-tags.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Fixed lists rendering `p` html tags on new lines. diff --git a/src/app/plugins/react-custom-html-parser.test.tsx b/src/app/plugins/react-custom-html-parser.test.tsx index 5f0cb8fb3..c29158224 100644 --- a/src/app/plugins/react-custom-html-parser.test.tsx +++ b/src/app/plugins/react-custom-html-parser.test.tsx @@ -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( + '
  1. one

  2. two

' + ); + + expect(container.querySelector('p')).toBeNull(); + expect(container.textContent).toContain('one'); + expect(container.textContent).toContain('two'); + expect(container.textContent).toContain('bullet'); + }); }); diff --git a/src/app/plugins/react-custom-html-parser.tsx b/src/app/plugins/react-custom-html-parser.tsx index 8a15df7ea..adb78f3a6 100644 --- a/src/app/plugins/react-custom-html-parser.tsx +++ b/src/app/plugins/react-custom-html-parser.tsx @@ -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 ( {renderChildren()}