quickdoc icon indicating copy to clipboard operation
quickdoc copied to clipboard

GitHub rendering does not respect case-sensitive anchor tag names

Open refset opened this issue 2 years ago • 5 comments

If you have a namespace with both Db (a protocol) and db (a function), the generated table of contents as GitHub renders it will incorrectly link both entries to the same db section due to the collision.

Inspecting GitHub's HTML shows that a case-insensitive naming scheming is applied e.g. user-content-db (for Db) and user-content-db-1 (for db), which perhaps hints at an approach to fixing this.

This is definitely not super important but I figured it was worth capturing :slightly_smiling_face:

refset avatar Feb 24 '23 16:02 refset

@refset But the links in the TOC should still work... right?

borkdude avatar Feb 24 '23 16:02 borkdude

Yes the TOC still contains clickable links that scroll the page, but they both scroll to the same db heading because GitHub ignores the case-sensitivity of the two otherwise distinct URL fragments [...]#my.ns/Db vs [...]#my.ns/db

refset avatar Feb 24 '23 20:02 refset

Is there anything quickdoc can do to fix this?

borkdude avatar Feb 24 '23 21:02 borkdude

I reckon always adding a positional index as a suffix to the tag names regardless (-1, -2, -3, etc.) would never fail to disambiguate all the generated/interpreted links. It would break any existing links people may be relying on though. To mitigate that impact we could specifically look for case-insensitive duplicate entries and only disambiguate those (but also check that you're not about to introduce new collisions in that case!)...but perhaps that's too haphazard :thinking:

refset avatar Feb 26 '23 18:02 refset

This is kind of what I had before:

https://github.com/borkdude/quickdoc/blob/66e4835e4b95d2dc2967aa5f984d11bedf4493fb/src/quickdoc/impl.clj#L113-L118

but got lost in a PR which improved the links in the TOC.

https://github.com/borkdude/quickdoc/blob/66e4835e4b95d2dc2967aa5f984d11bedf4493fb/src/quickdoc/impl.clj#L159-L162

borkdude avatar Feb 26 '23 20:02 borkdude