Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anchor link for headers with "and" #470

Open
lifeparticle opened this issue Jun 10, 2024 · 6 comments
Open

Anchor link for headers with "and" #470

lifeparticle opened this issue Jun 10, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@lifeparticle
Copy link
Owner

lifeparticle commented Jun 10, 2024

Steps to Reproduce:

  1. Create a markdown file with:
    ## Mention people and teams
    ## Reference issues and pull requests
  2. View it on GitHub.

Expected:
#mention-people-and-teams
#reference-issues-and-pull-requests

Actual:
#mention-people-andteams
#reference-issues-and-pullrequests

Impact:
Broken navigation links.

@lifeparticle lifeparticle added the bug Something isn't working label Jun 10, 2024
@lifeparticle
Copy link
Owner Author

curl -L \
  -X POST \
  -H "Accept: application/vnd.github+json" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/markdown \
  -d '{"text":"# Reference issues and pull requests \n # Mention people and teams", "mode": "markdown"}'
<div class="markdown-heading"><h1 class="heading-element">Reference issues and pull requests</h1><a id="user-content-reference-issues-and-pull-requests" class="anchor" aria-label="Permalink: Reference issues and pull requests" href="#reference-issues-and-pull-requests"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>

<div class="markdown-heading"><h1 class="heading-element">Mention people and teams</h1><a id="user-content-mention-people-and-teams" class="anchor" aria-label="Permalink: Mention people and teams" href="#mention-people-and-teams"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>

markdown api

@MajorKeen
Copy link

Looks to be a non-issue it was caused by the introduction of the ASCII character code 160 the non-breaking space. When generating the anchor navigation links, GitHub's markdown parser converts spaces to hyphens. In this particular case it was not happening due to the space character not being the standard ASCII space character code 30

DEC OCT HEX BIN Symbol HTML Number HTML Name Description
32 040 20 00100000 SP &#32;   Space
160 240 A0 10100000 NBSP &#160; &nbsp; Non-breaking space

@MajorKeen
Copy link

Other spaces characters to look out for but in the Unicode space are:

Code HTML Entity UTF-8 Encoding UTF-16 Encoding UTF-32 Encoding
U+2003 &#8195;
&#x2003;
&emsp;
0xE2 0x80 0x83 0x2003 0x00002003
U+2002

0xE2 0x80 0x82 0x2002 0x00002002

A list of other possible spaces in Unicode can be found at the below link:
https://www.compart.com/en/unicode/category/Zs

@lifeparticle
Copy link
Owner Author

@MajorKeen many thanks for your detailed explanation, it make sense now. I will try to handle these special cases in the TOC generator.

@lifeparticle
Copy link
Owner Author

curl -L \
  -X POST \
  -H "Accept: application/vnd.github+json" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/markdown \
  -d '{"text":"# Reference issues and pull&nbsp;requests \n # Mention people and teams", "mode": "markdown"}'
<div class="markdown-heading"><h1 class="heading-element">Reference issues and pull requests</h1><a id="user-content-reference-issues-and-pullrequests" class="anchor" aria-label="Permalink: Reference issues and pull requests" href="#reference-issues-and-pullrequests"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>

<div class="markdown-heading"><h1 class="heading-element">Mention people and teams</h1><a id="user-content-mention-people-and-teams" class="anchor" aria-label="Permalink: Mention people and teams" href="#mention-people-and-teams"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Sprint backlog (1 Week)
Development

No branches or pull requests

2 participants