Merge pull request #1088 from buster-so/big-nate-bus-1892-errors-with-at-start-of-a-text-body

escape first line conversion
This commit is contained in:
Nate Kelley 2025-09-23 15:48:31 -06:00 committed by GitHub
commit 3c966a5646
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 0 deletions

View File

@ -39,5 +39,9 @@ export const preprocessMarkdownForMdx = (markdown: string): string => {
// This prevents {avg}, {25%}, {data} etc from being interpreted as JSX expressions // This prevents {avg}, {25%}, {data} etc from being interpreted as JSX expressions
processed = processed.replace(/{([^{}]*?)}/g, '{$1}'); processed = processed.replace(/{([^{}]*?)}/g, '{$1}');
// 3. Escape > characters at start of line that are followed by digits (comparison operators like >500k)
// This prevents them from being interpreted as blockquote syntax
processed = processed.replace(/^>(\d)/gm, '>$1');
return processed; return processed;
}; };

View File

@ -2041,4 +2041,18 @@ describe('edge case tests for markdown parsing', () => {
expect(platejs[0].children[0].text).toContain('array[index]'); expect(platejs[0].children[0].text).toContain('array[index]');
expect(platejs[0].children[0].text).toContain('object.{property}'); expect(platejs[0].children[0].text).toContain('object.{property}');
}); });
it('should parse > at start of line followed by numbers as text, not blockquote', async () => {
const markdown = `### Purchase Motivation
<metric metricId="384457bc-da77-4d8f-893b-66db768b4eea"/>
>500k CLV customers are driven by **competition (58%)** and **fitness (42%)** - no recreational or transportation customers exist in this segment. Meanwhile, <500k CLV customers are primarily **recreational cyclists (76%)**, followed by transportation (14%) and competition (8%). This indicates high-value customers view cycling as a serious sport or fitness pursuit rather than casual recreation.
### Technical Expertise`;
const platejs = await markdownToPlatejs(editor, markdown);
expect(platejs).toBeDefined();
expect(platejs[1].type).toBe('metric');
const contentElement = platejs[2];
expect(contentElement.type).toBe('p');
expect(contentElement.children[0].text).toContain('>500k CLV customers are driven by');
});
}); });