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

Add title attribute with footnote content to link leading to the footnote #4

Closed
4 tasks done
remarcable opened this issue Mar 15, 2024 · 3 comments
Closed
4 tasks done
Labels
🙋 no/question This does not need any changes 👎 phase/no Post cannot or will not be acted on

Comments

@remarcable
Copy link

remarcable commented Mar 15, 2024

Initial checklist

Problem

The UX of using footnotes is often distracting – you click on a link that takes you to the bottom of the page, and then you click the "back" character to get back. Often, I'm losing the place where I originally left off.

Solution

It would be great to be able to hover the footnote and have an overlay show the contents of the footnote. E.g. like this:
Screenshot 2024-03-15 at 12 52 58

Here, I manually changed the HTML of the <a> tag to have a title attribute with the contents of the footnote.

Alternatives

I think adding footnotes as titles would be sensible, as it is very unobtrusive. Only users looking for this will actually be impacted, adding lots of Capital-D Delight to the footnotes.

(I'm not exactly sure if this is the right package to add this as an issue. I'm using remark with the remark-gfm plugin that seems to be using this package.)

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Mar 15, 2024
@remarcable remarcable changed the title Add footnote content as title attribute Add title attribute with footnote content to link leading to the footnote Mar 15, 2024
@wooorm
Copy link
Member

wooorm commented Mar 15, 2024

Hey!

Title doesn’t work with touch devices and can’t contain HTML. AFAIK all accessibility guidelines really strongly recommend against using it for such important content. I’m not sure this is a good idea.


This micromark project here deals with parsing footnotes.
It has a simple HTML compilation part too, but that’s only if you use micromark directly.
With unified/remark/rehype, we use ASTs. There’s an entire ecosystem where you can do whatever you want with ASTs.

Markdown footnote constructs are turned into HTML elements ion remark-rehype.
Please take 10 minutes to read over the readme there: https://github.com/remarkjs/remark-rehype. There are many options to affect the generated HTML.

After that plugin, you can (in the rehype ecosystem, working on hast ASTs), transform the HTML to your heart’s desire.

What I personally would recommend if you want to improve the footnote experience for readers, is to use client side javascript to look for all a[data-footnote-ref], and then for each anchor replace it with a sort of <details> element containing the corresponding footnote definition, that people can click/tap on to expand.

@wooorm wooorm added the 🙋 no/question This does not need any changes label Mar 15, 2024
@wooorm
Copy link
Member

wooorm commented Mar 15, 2024

Marking as a Q because it’s not something for here, and still a bit vague what the good way to go about it is

@github-actions github-actions bot added 👎 phase/no Post cannot or will not be acted on and removed 🤞 phase/open Post is being triaged manually labels Mar 15, 2024
@remarcable
Copy link
Author

Thank you for the fast responses! I found this genuinely helpful.

I think what I wanted to suggest was adding the title attribute in addition to how footnotes are currently displayed in the HTML. Think more of a progressive improvement for footnotes on desktop, without hurting anyone else who is on mobile, instead of removing footnotes altogether.

I'll continue exploring how to transform the hast, thanks for the suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙋 no/question This does not need any changes 👎 phase/no Post cannot or will not be acted on
Development

No branches or pull requests

2 participants