Skip to content

Broken links to Headings that are link targets in Markdown documents

Summary

When you have a heading with an id in a markdown document, the links to that heading are broken because of a dash suffix added by the markdown renderer.

This in the original markdown document:

<h2 id="introduction">
  Introduction
</h2>

It becomes this after rendered:

<h2 dir="auto">
<a id="user-content--introduction" class="anchor" href="#-introduction" aria-hidden="true"></a>
  Introduction
</h2>

Note that href="#-introduction".

Steps to reproduce

Go to https://gitlab.com/midion/mongodb-crud and click on "complete sample" in the "TL;DR" section.

Example Project

https://gitlab.com/midion/mongodb-crud

What is the current bug behavior?

The href of anchor links rendered for a heading with an id has an additional leading dash.

What is the expected correct behavior?

The href of anchor links rendered for a heading with an id should match that id.