diff --git a/src/__tests__/parseExpensiMark.test.ts b/src/__tests__/parseExpensiMark.test.ts index b49f46fa3..1d6a0436c 100644 --- a/src/__tests__/parseExpensiMark.test.ts +++ b/src/__tests__/parseExpensiMark.test.ts @@ -31,6 +31,10 @@ test('no formatting', () => { expect('Hello, world!').toBeParsedAs([]); }); +describe('parsing error', () => { + expect(`> [exa\nmple.com](https://example.com)`).toBeParsedAs([]); +}); + test('bold', () => { expect('Hello, *world*!').toBeParsedAs([ {type: 'syntax', start: 7, length: 1}, diff --git a/src/parseExpensiMark.ts b/src/parseExpensiMark.ts index cbf69845b..7657efd94 100644 --- a/src/parseExpensiMark.ts +++ b/src/parseExpensiMark.ts @@ -281,11 +281,12 @@ function parseExpensiMark(markdown: string): MarkdownRange[] { const tree = parseTokensToTree(tokens); const [text, ranges] = parseTreeToTextAndRanges(tree); if (text !== markdown) { - throw new Error( + console.error( `[react-native-live-markdown] Parsing error: the processed text does not match the original Markdown input. This may be caused by incorrect parsing functions or invalid input Markdown.\nProcessed input: '${JSON.stringify( text, )}'\nOriginal input: '${JSON.stringify(markdown)}'`, ); + return []; } const sortedRanges = sortRanges(ranges); const groupedRanges = groupRanges(sortedRanges);