r-lib / commonmark

High Performance CommonMark and Github Markdown Rendering in R
https://docs.ropensci.org/commonmark/
Other
88 stars 12 forks source link

target="_blank" not being parsed correctly #19

Closed boshek closed 2 years ago

boshek commented 2 years ago

👋 thanks for this amazing package. It enables so much. This might be an upstream issue but I thought to bring it here first.

commonmark::markdown_html doesn't seem to parse markdown correctly for links that open in a new tab.

For example commonmark::markdown_html generates this:

commonmark::markdown_html("[RStudio](https://www.rstudio.com/){target='_blank'}")
<p><a href=\"https://www.rstudio.com/\">RStudio</a>{target='_blank'}</p>

When I think this is what it should generate:

<p><a href="https://www.rstudio.com" target="_blank">RStudio</a></p>
jeroen commented 2 years ago

I think attributes are not supported in the commonmark specification, and also not by any GFM extension. For example if I use your example markdown code in a github issue, it is also not parsed:

RStudio{target='_blank'}

So I am afraid this is out of scope for commonmark.

boshek commented 2 years ago

Got it. Thanks for the quick response.