React-markdown: Opening link in a new tab

Created on 21 Mar 2017  路  4Comments  路  Source: remarkjs/react-markdown

Is it possible to add target="blank" to Markdown links?

For example I wish to have the following URL open in a new browser tab when I left click:
[link to website](http://www.website.com)

Cheers

Most helpful comment

You can use a custom renderer:

function LinkRenderer(props) {
  return <a href={props.href} target="_blank">{props.children}</a>
}

<ReactMarkdown
  source="Click [here](https://espen.codes/) to visit external site"
  renderers={{link: LinkRenderer}}
/>

All 4 comments

You can use a custom renderer:

function LinkRenderer(props) {
  return <a href={props.href} target="_blank">{props.children}</a>
}

<ReactMarkdown
  source="Click [here](https://espen.codes/) to visit external site"
  renderers={{link: LinkRenderer}}
/>

@rexxars renderers={{Link: LinkRenderer}} is incorrect, Link: => link: to lowercase =)
just for this issue`s other viewers

it works here with the capital L in Links:

Can you please consider re-open this ticket in order to implementing support for opening a link in a new tab:
[link](url){:target="_blank"}

Is this feature make sense?
I'm willing to give it a try implementing this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

d0lb33 picture d0lb33  路  3Comments

kennetpostigo picture kennetpostigo  路  4Comments

joelin109 picture joelin109  路  3Comments

AlexLerman picture AlexLerman  路  3Comments

IonicaBizau picture IonicaBizau  路  4Comments