Search code examples
urlgithubmarkdowncode-formattinggithub-flavored-markdown

Can I Include a URL Link Within a Chunk of Code in a Github Markdown Document?


I'm looking to propose some small tweaks/improvements to my employer's coding standard written in Github markdown (*.md).

I've prepped by reviewing a couple of references this markdown language's formatting conventions.

From my readings I see that I can add URLs in at least two different ways:

  • Standard HTML:
    <a href="LINK_URL">TEXT</a>
  • Markdown style links:
    [TEXT](LINK_URL)

...and code markdown is written as:

  • Markdown style:

    ```LANGUAGE MY CODE; ```

  • Implicit code denotation via 4 space indent.

However, I've been unable to find a reference on whether you can include a hyperlink inside a block of code (i.e. to the location of that object's source in your repository).

i.e. I want to do something like:

```javascript
_myQObject: <a title="QML Source for MyQObject" href="URL_TO_SOURCE">MyQObject {}
```

That does not work, however, and I've been unable to find documentation explicitly stating whether this is possible or not.

How can I include a link to a URL within a chunk of formatted Github markdown?

Is this possible?

For reference the basic style guides I've reviewed are:


Solution

  • How can I include a link to a URL within a chunk of formatted Github markdown?

    As far as I know this is not possible.

    The original Markdown specification says:

    With a code span, ampersands and angle brackets are encoded as HTML entities automatically, which makes it easy to include example HTML tags.

    Regular Markdown syntax is not processed within code blocks. E.g., asterisks are just literal asterisks within a code block. This means it’s also easy to use Markdown to write about Markdown’s own syntax.

    I haven't seen anything in the GitHub Markdown docs to suggest that they have added support for links in code blocks, and nothing I've tried has worked.

    I also haven't seen this feature in any other Markdown implementations.