-
Notifications
You must be signed in to change notification settings - Fork 326
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
Simple solution for global unique header IDs #3262
Conversation
Overrides __
This reverts commit 1861c7d.
This reverts commit a88b256.
This reverts commit 04187cf.
This reverts commit 67a4391.
Trusts that MarkedGFMHeadingId will make the ids unique per page and header level and then massages them to have what should be a global uniq name via the hooks: postprocess system.
Code tests are failing due to an issue with jest and dom that I do not have enough knowledge of to solve. |
The useful thing for putting See this brew for an example: https://homebrewery.naturalcrit.com/share/SyXKaZmQM This only remains useful if the Adding or removing a page early in the brew will cause all the headings in this solution to change. And not in an obviously broken way either (i.e. clicking the link to |
Okay. I'll go to plan b. |
This uses the GFMHeaderID Profix feaure to tag automatically generated IDs and then swap them out with Page and Header Type prefixes to result in a render unique tag.
@ericscheid This now keeps the original ID from users, but still applies a page number and counter: Is this any better for your use case, or do you have an alternate preferred behavior? I understand this may still be an issue when deleting or adding pages because the |
This is no better. The The numbering will also change if headings are inserted or deleted or rearranged on a given page. |
Well, this is going to be true of any solution that creates unique identifiers for duplicated names. Rearranging the headings in text would always correspond to a rearrangement of the unique IDs being generated, no? Unless I'm missing something, what naming scheme would you propose that is immune to reordering of the text? Or maybe if you don't mind making a short example document showing what rearrangements of headers you expect to be stable? So we are all working from the same requirements. |
The issue isn't the instability of "unique identifiers for duplicated names", but rather that even for non-duplicated names the ids are unstable. For example .. this document
should have the same ids as
and even this
|
I see
|
Absolutely. Bottom line: the fix for one specific case shouldn't break a more general case. |
There is no way to prevent this other than by the user forcing an id via { }. Even if we could maintain a global list without massaging the IDs ( similar to how we have in the PR for reflinks ) nothing guarantees the integrity of auto-generated header ID reflinks staying valid. It is an unreliable method of internal document linking and should be discouraged. Even in a single-page document. |
Expanding the scope of a problem from specific to general cannot be excused by saying there's already a problem with an edge case. |
Solves Issue #2832.
Trusts that MarkedGFMHeadingId will make the ids unique per page and header level and then massages them to have what should be a global uniq name via the hooks: postprocess system.