DEV Community

Meghan (she/her)
Meghan (she/her)

Posted on

Links in an inline code don't link

There is a bug in the markdown parser that does not hyperlink links from within an inline code block.

Code:

`[DOM Standard](https://dom.spec.whatwg.org/)`
Enter fullscreen mode Exit fullscreen mode

Real:

[DOM Standard](https://dom.spec.whatwg.org/)

Top comments (9)

Collapse
 
ben profile image
Ben Halpern

Hmmm never even considered this the expected behavior.

Collapse
 
nektro profile image
Meghan (she/her) • Edited

Hmmm, it seems it works if the code is put inside the hyperlink

edit: nevermind

Collapse
 
andy profile image
Andy Zhao (he/him)

Hmm agreed with Ben, I would think if a link is in code it's meant to show you the code and not the hyperlink.

Thread Thread
 
nektro profile image
Meghan (she/her)

This is the effect I was going for. The idea was that I would link a keyword to the documentation but put the keyword in an inline code block to have the monospace font.

Thread Thread
 
ben profile image
Ben Halpern

In the ink it shows this code:

[`EventTarget`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget)

Which renders like this:

EventTarget

Which is different from what you wrote, right?

Thread Thread
 
nektro profile image
Meghan (she/her)

slightly, but because i realized the original way didn't properly compile to adding the <code> part, which dev.to does not with with the backticks inside or outside the url

Thread Thread
 
ben profile image
Ben Halpern

Hah whoops I expected that to go differently. I now know what you're talking about.

Thread Thread
 
andy profile image
Andy Zhao (he/him)

Ahh that makes sense. @nektro I think on GitHub it does what you're talking about.

Collapse
 
nullvoxpopuli profile image
NullVoxPopuli

prism.js supports this :)