Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Placing links inside markdown code blocks

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?

like image 371
Dave Avatar asked Nov 20 '13 09:11

Dave


People also ask

How do I add an internal link in Markdown?

Markdown syntax for a hyperlink is square brackets followed by parentheses. The square brackets hold the text, the parentheses hold the link.

Can you embed code snippets in Markdown?

Embedding Code in Markdown. If you're writing your code in markdown, the easiest way to embed snippets is to use "fenced code blocks", which also allows syntax highlighting. For examples in practice, see this assemble boilerplate for markdown projects, in particular take a look at the code in these templates.

How do you use code blocks in Markdown?

To format a code block in Markdown, indent every line of the block by at least four spaces. An indented code block cannot interrupt a paragraph, so you must insert at least one blank line between a paragraph the indented code block that follows.

How do I insert a table of contents in Markdown?

Press CTRL + SHIFT + P. Select Markdown: Create Table of Contents.


2 Answers

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

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

like image 191
Kelvin Avatar answered Sep 22 '22 10:09

Kelvin


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).

like image 41
VonC Avatar answered Sep 25 '22 10:09

VonC