cwjohan / markdown-to-html

Command-line utility to convert Github Flavored Markdown to HTML.
MIT License
236 stars 86 forks source link

Header anchor link hrefs are wrong (no user-content- added) #24

Open mb185390 opened 6 years ago

mb185390 commented 6 years ago

When adding a Table of Contents as follows:

# Table of Contents

* [1. Introduction](#user-content-1-introduction)

and the corresponding heading like so:

# 1. Introduction

An anchor link is generated inside the header tag:

<a id="user-content-1-introduction" class="anchor" href="#1-introduction" aria-hidden="true">
    <span aria-hidden="true" class="octicon octicon-link"></span>
</a>

Notice the href="#1-introduction" meaning that if I was to right-click the anchor link and copy the address it is copied as "www.example.com/document#1-introduction" so when navigating there it doesn't scroll down to the Introduction section as it can't find the anchor link.

I've tried adding my own custom anchor and setting the name and id to "introduction" to no avail.

Is anyone aware of a fix for this?