-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Anchor links changed? #2002
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
Comments
I might look into this myself later, but I had to write this down and do something else first. |
Oh no! I highly suspect the culprit to be related to the recent style changes (@jnavila does this sound plausible to you?) |
I hope it's recent and not broken since the Rails to Hugo transition, otherwise I expect both types of permalinks to be around on the interwebs. So that means we'd have to figure out a way to support both. @dscho Shall/Can we add test coverage for these permalinks? |
I suspect so. All the command options are now formatted as <code>, and it seems this bleeds into the automatic anchor generation... Quite an inexpected side-effect. We are never sure that the machine generated anchor name is reproducible. |
the generative part is here: git-scm.com/script/update-docs.rb Lines 175 to 182 in 2e65651
And indeed it works on final html and does not select the "text" part of the html node. |
We may have similar issues where I added "<placehoder>" marks. And it will have even a larger change effect after applying the new style formatting of #1921 |
It is recent: https://web.archive.org/web/20250113050613/https://git-scm.com/docs/git-clone#Documentation/git-clone.txt-code-lcode has the old-style links, and is well after the transition.
Absolutely! It's relatively easy in the Playwright tests, too, all you do is to call git-scm.com/tests/git-scm.spec.js Lines 203 to 205 in 2e65651
You probably need to use a different way to locate the link, as its text is not "--local", instead the element following the link has this text, possibly something like this: // The `<a>` element of class `anchor` directly preceding the `<code>` element whose text is "--local"
const anchor = page.locator('xpath=//code[text()="--local"]/preceding-sibling::a[@class="anchor"][1]')
await expect(anchor).toHaveAttribute('href', /#Documentation\/git-clone\.txt-l$/) My XPath is not very good, so I'll refrain from refining it: It should probably catch instances where the "--local" text is not enclosed in a tag, too.
Yes, and that's most likely really wrong. I guess the easiest way to fix this would not be to switch from html to text, but to do something like this: - text = $1.tr("^A-Za-z0-9-", "")
+ text = $1.gsub(/<[^>]*>/, "").tr("^A-Za-z0-9-", "") This would also proactively address the I guess we could also do this instead: - text = $1.tr("^A-Za-z0-9-", "")
+ text = $1.gsub(/<\/?(?:code|placeholder)>/, "").tr("^A-Za-z0-9-", "") Thoughts? |
I was more thinking of settling on a true html parsing such as: html.gsub!(/<dt class="hdlist1">(.*?)<\/dt>/) do |m|
sp = Nokogiri::HTML.parse(m)
sp.text.tr("^A-Za-z0-9-", "")
end Even with HTML5 now, we are not limited in the form of ids and do not need the last |
@jnavila we're still limited by backwards-compatibility: Previously-working links using anchors should continue to work. That's why I would highly suggest to stick with parsing text rather than html, and to retain the |
I ran across a link on the interwebs:
https://git-scm.com/docs/git-clone#Documentation/git-clone.txt---recurse-submodulesltpathspecgt
and I noticed it's not anchoring to the correct piece of the page. The nowadays seems to be:
https://git-scm.com/docs/git-clone#Documentation/git-clone.txt-code--recurse-submodulesltpathspecgtcode
What changed the
code
to be added around the anchor link? I'd prefer to not have this behavior broken.The text was updated successfully, but these errors were encountered: