Skip to content

Broken anchor links within markdown documents #1627

Open
@uecasm

Description

@uecasm

Example: https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#S-introduction

Anchor links to this document are commonplace elsewhere on the Internet, and are used extensively within the document itself. However it appears that somewhere in the github rendering pipeline an additional prefix is being inserted which breaks things.

An example link to the introduction section from within the markdown source:

* [In: Introduction](#S-introduction)

The introduction section anchor target in the markdown source:

# <a name="S-introduction"></a>In: Introduction

The rendered link:

<a href="#S-introduction">In: Introduction</a>

The rendered target (with some pretty-printing):

<h1 dir="auto">
  <a id="user-content-in-introduction" class="anchor" aria-hidden="true" href="#in-introduction"><svg ... /></a>
  <a name="user-content-S-introduction"></a>In: Introduction
</h1>

There are two problems with this:

  • The auto-generated section anchor specifies an id of user-content-in-introduction, but then an href of #in-introduction. Prefix or not doesn't especially matter (unless someone has already externally copied such a link) but these do need to be the same.
  • The <a name/> anchor explicitly specified in the markdown source has also erroneously had a user-content- prefix added to it, which is absolutely a bug.

So the quick fix might be to find and boot whatever is adding those prefixes, though that may not be the best fix depending on the history.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions