Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display link url in markdown

Tags:

I have a markdown file in which I use a link multiple times, for example:

This [website][an_awesome_website_link] is awesome.  You will never use anything else than this [website][an_awesome_website_link].  [an_awesome_website_link]: https://stackoverflow.com 

Formatted, it looks like:

This website is awesome.

You will never use anything else than this website.


I want to display the link url of [an_awesome_website_link] without having to write again the said url.

For example, I want to have this, and write the url of stackoverflow only 1 time in my markdown file:

This website (https://stackoverflow.com).

You will never use anything else than this website.

Check out https://stackoverflow.com for more fun.

Is it possible ? How ?

like image 836
Jules Lamur Avatar asked Dec 27 '16 12:12

Jules Lamur


People also ask

How do I show a 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.

How do you add a URL in readme MD?

To link inline, type the text you want to link within brackets, "[x]", followed directly by the link URL parentheses, "(y)". Reference-style linking allows you to give a link a number or "name" and refer to it multiple times.

How do I show code in markdown?

There are two ways to format code in Markdown. You can either use inline code, by putting backticks (`) around parts of a line, or you can use a code block, which some renderers will apply syntax highlighting to.


1 Answers

In short, it's not possible without some sort of non-standard extension or macro.

There are three kinds of links in Markdown.

  1. Standard links in which both the label and URL are defined together:

    [label](http://example.com) 
  2. Reference links, which can be in one of two forms:

    [label][key] or [key]  [key]: http://example.com 
  3. Automatic Links, where the label is the URL:

    <http://example.com> 

    While some implementations do not require the angle brackets, it is best to include them so that is works across all implementations.

However, there is no facility to make reference to a reference link and have it display the URL instead of the label. Therefore, the most minimal way to generate your desired output would be with this Markdown input:

This [website (https://stackoverflow.com)][website] is awesome.  You will never use anything else than this [website].  Check out <https://stackoverflow.com> for more fun.  [website]: https://stackoverflow.com 

That said, some Markdown parsers have extension APIs and you could conceivably write an extension/plugin/macro which would give you the behavior you want. However, that would be non-standard and would not work anywhere else except with your locally modified parser. As you indicate you are using a third party hosting service, then that is not likely to be an option for you.

like image 53
Waylan Avatar answered Nov 08 '22 07:11

Waylan