serokell/xrefcheck

Allow uppercase in anchors

Sorokin-Anton opened this issue · 3 comments

Clarification and motivation

Currently, if a file a.md has heading H1, reference [...](a.md#H1) is reported as

  ➥  In file a.md
     bad reference (current file) at src:3:8-21:
       - text: "..."
       - link: 
       - anchor: H1
     
     ⛀  Anchor 'H1' is not present, did you mean:
         - h1 (header I) at src:11:1-4

But GitHub renderer supports both h1 and H1 as anchors here, tested there
that anchors are case insensitive. I think we should allow this, but first we need to check what happens on GitLab. If anchors are case-insensitive on GitLab too, we can simply convert anchors to lowercase before checking. Otherwise we should do this only if GitHub flavor is specified

Acceptance criteria

We consider anchors case-insensitively on flavors that support uppercase in anchors.

Also, let's make sure "case-insensitivity" works well together with our features for detecting:

  1. ambiguous anchors
  2. similar anchors
aeqz commented

If anchors are case-insensitive on GitLab too

I have checked it and anchors seem to be case-sensitive on GitLab.

Regarding other anchor features I think that, even if the flavour is case-sensitive, the similar anchors detection should always be case-insensitive. Do you agree?

I can confirm that GitHub is case-insensitive now, at least in my browser. So let's go with the flavor-depending fix.

Regarding other anchor features I think that, even if the flavour is case-sensitive, the similar anchors detection should always be case-insensitive

Yeah, that's a good note, having it case-insensitive unconditionally would be very cool.