Placing links inside markdown code blocks

GithubHyperlinkMarkdown

Github Problem Overview


I want to have links inside my code blocks using GitHub flavored markdown.

```cpp
void Click ([Keycode](#keycode) key) const
```

Unfortunately, it renders that as code, anyway to make it a link instead?

Github Solutions


Solution 1 - Github

If its a short piece of code this should do the trick:

[`this is code`](https://this_is_url/)

Solution 2 - Github

As far as I know, the current instance of GitHub Flavored Markdown doesn't support this.

The all block is rendered with <div class="highlight highlight-html"><pre>... </pre></div>, meaning your markdown link is not interpreted.

It would be best to place that link just before the code section (unless said section has dozens of similar links in your code).

Solution 3 - Github

As suggested by VonC, it might not be possible with the current version of GitHub Flavored Markdown. That being said, I did find a way around it which suits my requirements. By using tags like <big>, <pre> and <b> I'm able to simulate syntax highlighting and get the effect I'm looking for. Too bad I can't add my own color though.

<big><pre>
**void** Click ([**Keycode**](#keycode) key) **const**
</pre></big>

Solution 4 - Github

You can do this using HTML in markdown, yes, even on Github:

<pre>
<a href="my-url">Something</a>
</pre>

Solution 5 - Github

This makes the trick.

I use it on my GitHub profile page to put links inside code blocks.

<pre>
 <code>
  <a href="https://github.com/gmarciani">gmarciani</a>
 </code>
</pre>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDaveView Question on Stackoverflow
Solution 1 - GithubKelvinView Answer on Stackoverflow
Solution 2 - GithubVonCView Answer on Stackoverflow
Solution 3 - GithubDaveView Answer on Stackoverflow
Solution 4 - GithubmlissnerView Answer on Stackoverflow
Solution 5 - GithubGiacomo MarcianiView Answer on Stackoverflow