Skip to content

Readme heading ids #1727

@tynanbe

Description

@tynanbe

Every readme heading should be generated with an id, such that links pointing to those headings work properly, e.g. on hexdocs (GitHub automatically does this).

Example

## Advanced Usage

### Another Example

Should generate something like

<h2 id="advanced-usage">
  <a href="#advanced-usage" class="anchor" aria-hidden="true"><svg class="icon icon-star"><use xlink:href="#icon-star"></use></svg></a>
  Advanced Usage
</h2>

<h3 id="another-example">
  <a href="#another-example" class="anchor" aria-hidden="true"><svg class="icon icon-star"><use xlink:href="#icon-star"></use></svg></a>
  Another Example
</h2>

Suggested CSS

.anchor {
  float: left;
  font-size: .75em;
  line-height: 2;
  margin-left: -1.125em;
  padding-right: .125em;
  visibility: hidden;
}
h1:hover .anchor,
h2:hover .anchor,
h3:hover .anchor,
h4:hover .anchor,
h5:hover .anchor,
h6:hover .anchor {
  visibility: visible;
}

Note that the same heading title might be used multiple times, so perhaps a number should be appended to the id in those cases.

Note that the same heading title might be used multiple times, so perhaps a number should be appended to the id in those cases.Note that the same heading title might be used multiple times, so perhaps a number should be appended to the id in those cases.

Mockup

Here's a screenshot of two sets of h2 and h3 tags, top on :hover and bottom normal.

2022-08-14_103156_470x301

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedContributions encouraged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions