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

GitHub rendering does not respect case-sensitive anchor tag names #32

Open
refset opened this issue Feb 24, 2023 · 5 comments
Open

GitHub rendering does not respect case-sensitive anchor tag names #32

refset opened this issue Feb 24, 2023 · 5 comments

Comments

@refset
Copy link
Sponsor

refset commented Feb 24, 2023

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 🙂

@borkdude
Copy link
Owner

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

@refset
Copy link
Sponsor Author

refset commented Feb 24, 2023

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

@borkdude
Copy link
Owner

Is there anything quickdoc can do to fix this?

@refset
Copy link
Sponsor Author

refset commented Feb 26, 2023

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 🤔

@borkdude
Copy link
Owner

This is kind of what I had before:

(defn with-idx [s memo]
(let [v (swap! memo update s (fnil inc -1))
c (get v s)]
(if (zero? c)
s
(str s "-" c))))

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

(println "- " (format "[`%s`](#%s) %s" ns-name
(str (with-idx (md-munge ns-name) memo))
(str (when-let [summary (var-summary ns)]
(str " - " summary)))))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants