Replies: 0 comments 10 replies
-
The only link fragments that are not on an Hx that I see having some usefulness are the #attr-xyz on the HTML pages. E.g. The ping attribute of the a element. |
Beta Was this translation helpful? Give feedback.
-
I say; let it break. You could probably use -## Old heading
+
+<a name="old_heading"></a>
+
+## New heading ...As a way of making (note: I haven't even tested if that works in our newly landed Markdown) That would solve the problem with legacy links into that section. Something potentially possible to do for hugely popular links like https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach#polyfill (note2: I don't know if there are a lot of inbound links to |
Beta Was this translation helpful? Give feedback.
-
Sounds doable, |
Beta Was this translation helpful? Give feedback.
-
Sorry if I'm coming to this a bit late @teoli2003 I've assumed this is the number of files non heading ids affect? In the past month, these are the top listed urls users have landed on the site direct, which include a fragment: /en-us/docs/web/api/screen_capture_api/using_screen_capture#result There's 263 results, but the above are all those over 2 users - the top one by far is the screen capture one at the top with 111 using the direct url with id and this is linking directly to an h4. I'd be inclined to have a guideline which says ids should only be used on headers moving forward (omitting existing macros) and as that's auto with markdown, just no ids. Which in turn concludes -> Not a showstopper 👍 |
Beta Was this translation helpful? Give feedback.
-
I'm happy for them to break too, provided the anchor break is reported as a flaw (in linking topics) so we can fix these over time. (@peterbe).
FWIW There this is how heading anchor persistence is normally handled:
|
Beta Was this translation helpful? Give feedback.
-
In HTML, we can represent heading IDs independently of the heading text. So we can have:
<h2 id="My_heading_id">Something</h2>
We can also of course attach IDs to any kind of element:
<p id="this_paragraph">
Then someone on a different page (or site) can link to https://developer.mozilla.org/en-US/docs/My/Page#My_heading_id or https://developer.mozilla.org/en-US/docs/My/Page#this_paragraph , and get to that part of the page.
In GFM we don't have the ability to support these cases. The only IDs we will have are on headings, and they are always derived from the heading text. So we will break link fragments on non-headings or on heading where the ID is not derived from the heading text.
We can find and fix these cases on MDN itself, but we can't, obviously, do it for external sites.
If this is a showstopper problem, the only option I can see is to support explicitly representing IDs in Markdown (for example, using something like https://about.gitlab.com/handbook/markdown-guide/#classes-ids-and-attributes).
I think this isn't a showstopper, for a couple of reasons:
But either way I would like us to be clear about this choice :).
cc @escattone , @peterbe (with whom I've talked this over already), @Rumyra , @Elchi3
Beta Was this translation helpful? Give feedback.
All reactions