React-markdown: The following format causes a link to be made: [[whatever]]

Created on 4 Dec 2017  路  3Comments  路  Source: remarkjs/react-markdown

This is messing with a program of mine as the link is basically causing a redirect to my page (I am coding in electron.js and react.js so reloading a page to a '/' is very bad.) and showing an unnecessary link.

Edit: even just doing [whatever] creates a blank link.

Most helpful comment

It's not a problem with react-markdown package, it's more on how markdown is parsed via remark-parse.

The fast workaround may be to create custom renderer for linkReference:

 <ReactMarkdown
      source={source}
      renderers={{
        linkReference: (reference) => {
          if (!reference.href) {
            return `[ ${reference.children[0]} ]`;
          }

          return <a href={reference.$ref}>{reference.children}</a>
        }
      }}/>

All 3 comments

Its noted here that:

brackets that aren鈥檛 part of links do not take precedence

It's not a problem with react-markdown package, it's more on how markdown is parsed via remark-parse.

The fast workaround may be to create custom renderer for linkReference:

 <ReactMarkdown
      source={source}
      renderers={{
        linkReference: (reference) => {
          if (!reference.href) {
            return `[ ${reference.children[0]} ]`;
          }

          return <a href={reference.$ref}>{reference.children}</a>
        }
      }}/>

Im having the same issue. It works great locally but as soon as I deploy to aws-amplify there is an redirect causing it to not display the .md file....

Any insight?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kennetpostigo picture kennetpostigo  路  4Comments

guilhermecastro-hotmart picture guilhermecastro-hotmart  路  3Comments

pcvandamcb picture pcvandamcb  路  3Comments

zhenyulin picture zhenyulin  路  3Comments

wqh17101 picture wqh17101  路  3Comments