Skip to content

Fix README table of contents generator title linking #7

@fevrin

Description

@fevrin

Background

The table of contents generator does a decent job until it handles a Markdown file with duplicate titles. In that case, the titles' links all point to the same reference, whereas the links for first duplicate title on should have -1, -2, etc. appended to it to properly reference the correct title.

For instance, right now a Markdown file like this:

# Main title

${TOC}

## Subtitle

## Subtitle 2

### Subtitle

### Subtitle 2

#### Subtitle 3

#### Subtitle 2

would get a table of contents like this:

- [Subtitle](#subtitle)
- [Subtitle 2](#subtitle-2)
  - [Subtitle](#subtitle)
  - [Subtitle 2](#subtitle-2)
    - [Subtitle 3](#subtitle-3)
    - [Subtitle 2](#subtitle-2)

instead of this:

- [Subtitle](#subtitle)
- [Subtitle 2](#subtitle-2)
  - [Subtitle](#subtitle-1)
  - [Subtitle 2](#subtitle-2-1)
    - [Subtitle 3](#subtitle-3)
    - [Subtitle 2](#subtitle-2-2)

Definition of Done

  • table of contents generator correctly creates links for duplicate titles

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions