quantizor / markdown-to-jsx

🏭 The most lightweight, customizable React markdown component.
https://markdown-to-jsx.quantizor.dev/
MIT License
2.01k stars 174 forks source link

Bug when rendering ![][] #524

Closed anhydrous99 closed 7 months ago

anhydrous99 commented 1 year ago

Description

The following line ![][] raises a TypeError exception.

import Markdown from 'markdown-to-jsx'

<Markdown>![][]</Markdown>

Looks like refImage has no fallback for when the reference doesn't exist while refLink does.

Stack Trace -

TypeError: Cannot read properties of undefined (reading 'B')
    at Object.h (http://localhost:3000/main.8352f82ca6938aad7a39.hot-update.js:815:27)
    at http://localhost:3000/main.8352f82ca6938aad7a39.hot-update.js:991:26
    at t (http://localhost:3000/main.8352f82ca6938aad7a39.hot-update.js:1006:14)
    at t (http://localhost:3000/main.8352f82ca6938aad7a39.hot-update.js:1000:21)
    at q (http://localhost:3000/main.8352f82ca6938aad7a39.hot-update.js:539:15)
    at qt (http://localhost:3000/main.8352f82ca6938aad7a39.hot-update.js:1009:14)
    at __WEBPACK_DEFAULT_EXPORT__ (http://localhost:3000/main.8352f82ca6938aad7a39.hot-update.js:1038:58)
    at renderWithHooks (http://localhost:3000/static/js/bundle.js:20018:22)
    at mountIndeterminateComponent (http://localhost:3000/static/js/bundle.js:23304:17)
    at beginWork (http://localhost:3000/static/js/bundle.js:24600:20)

Steps to Reproduce

This can be reproduced in the paygroud.

  1. Open the official playgroud
  2. copy and paste the following code snippet. ![][]

Result - Screenshot 2023-10-26 at 1 48 27 PM

anhydrous99 commented 1 year ago

Here is my attempt at fixing this: #525.