diff --git a/index.compiler.spec.tsx b/index.compiler.spec.tsx index f0b9f539..6b3769d8 100644 --- a/index.compiler.spec.tsx +++ b/index.compiler.spec.tsx @@ -755,6 +755,20 @@ describe('images', () => { `) }) + it('should gracefully handle an empty image reference', () => { + render( + compiler(theredoc` + ![][1] + [2]: /xyz.png + `) + ) + + expect(root.innerHTML).toMatchInlineSnapshot(` +
+
+ `) + }) + it('should handle an image reference with alt text', () => { render( compiler(theredoc` @@ -890,6 +904,23 @@ describe('links', () => { `) }) + it('should gracefully handle an empty link reference', () => { + render( + compiler(theredoc` + [][1] + [2]: foo + `) + ) + + expect(root.innerHTML).toMatchInlineSnapshot(` ++ + [][1] + +
+ `) + }) + it('list item should break paragraph', () => { render(compiler('foo\n- item')) diff --git a/index.tsx b/index.tsx index 1004049a..36898ba0 100644 --- a/index.tsx +++ b/index.tsx @@ -1799,14 +1799,14 @@ export function compiler( } }, react(node, output, state) { - return ( + return refs[node.ref] ? ( - ) + ) : null }, } as MarkdownToJSX.Rule<{ alt?: string; ref: string }>,