1

I would like to use links in markdown that points to an element in a list or a table (or text) and not specially a header.

The only solution I found for markdown is to use HTML anchors :

This is a list of actions:
- <a id="action-one">action one</a>`: blablanla
- <a id="action-two">action two</a>`: patata

Later, in text, [action one](#action-one) is mandatory...

This works well in VScode (for example) but not in Gitlab.

FYI :

Any idea or solution is welcome. Thanks.

Slim Aloui
  • 320
  • 5
  • 12

1 Answers1

-1

There are two things to know :

  1. Writing the anchor tag

Example : [Text that will be a link](#this-is-my-tag)

  1. Knowing which tag to use

Which tag should you put ? Well gitlab generates them automatically. As you know, your markdown is translated to html to be displayed on the repo page. To know which tag you should use, just check the readme with the devtools. Inspect the html code. Here is an example of a heading in my repo, on gitlab :

<a aria-hidden="true" href="#2a-scrap-tarif" class="anchor" id="user-content-2a-scrap-tarif"></a>

We see the href tag is #2a-scrap-tarif.

So to go there, I will just write [Here is my link](#2a-scrap-tarif)

  • Thank you Yoann for your suggestion. But it's not working. Here's a link to a readme.md file in gitlab where I implemented your solution and you can test that the link in the bottom doesn't go back to the anchor in the first line. https://gitlab.com/slimal/markdownTestLinks/-/blob/main/README.md#2a-scrap-tarif – Slim Aloui Dec 05 '21 at 17:24
  • Hello Slim ! You used the href of my example instead of adapting to your heading. You must use the href of your heading, in your example it is : #some-dummy-text To check it, you have to inspect the href attribute of the heading of your text ! – Yoann Buzenet Dec 07 '21 at 07:54
  • As I mentioned in my question, I don't want a link to a header but a link to an anchor. I get what you are saying. "#some-dummy-text" is a header. When I click to I want to get a link to "Here is my link" I want to go to "Here is my anchor" and not "some dummy text". – Slim Aloui Dec 16 '21 at 15:02