-
Notifications
You must be signed in to change notification settings - Fork 101
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
Fix TableOfContents Examples links #1665
Conversation
bb86610
to
f9c73f2
Compare
Thanks for the PR! While I like the approach of coming up with some logic for the anchor links, I feel that this solution would introduce too many, seemingly arbitrary conventions that documentation writers would have to follow (it only works on I think a better solution would be something more generic that works for all table of contents items, e.g. use `heading.innerText.toLowerCase() to remove characters that cannot be in a link. Also while you work on this part you could look into why anchors dont work when opened as links, e.g. https://instructure.design/#Badge/#Guidelines does not scroll down to the 'Guidelines' part, just shows the top of the page. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see my comment above
f9c73f2
to
527e6d6
Compare
Thank you for the input. I changed the heading Id generation process in the I will look into the anchor issue as well. |
The issue with scrolling was that the |
7e16bfa
to
7fd447f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this solution, also now anchor links work, nice job!
When an example heading in the readme.md file contains markdown elements like code, the generated heading ID is based only on the text before the markdown. This can lead to duplicate heading IDs. For example, in the DateTimeInput documentation, the following examples both end up with the same ID, "A", because DateTimeInput is formatted as code:
Another common issue is that when linking to these examples from the table of contents, the ID includes whitespace from before the markdown part is cut off. However, the link’s href omits the trailing whitespace, causing the link to break. For instance, in the DateTimeInput docs:
And corresponding header
<h4 dir="ltr" id="A DateTimeInput with " class="css-xjt99e-view-heading">A DateTimeInput with <code>columns</code> layout and a default value:</h4>
To resolve these issues, I propose assigning example headings an ID in the format example-{number-of-example}. This ensures that each heading has a unique and functional ID.