-
Notifications
You must be signed in to change notification settings - Fork 479
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
On-hover footnote preview #2080
Comments
I would like to work on this issue and this also come under my expertise, Can I have some details like in which part of Julia Codebase should I do this? And I am really sorry to ask this newbie question as I am new to Julia and I am still trying to understand Julia Codebase and Documenter.jl!! |
On the Julia side, the HTML for the footnotes is generated here: Documenter.jl/src/html/HTMLWriter.jl Lines 2019 to 2040 in 579d478
In the rendering phase, Documenter essentially gets a big object representing the Markdown and then runs over that, generating the HTML. The entry point into Documenter.jl/src/html/HTMLWriter.jl Lines 638 to 713 in 579d478
The Markdown elements are represented with MarkdownAST objects. However, what could be a good first step is to take just the generated HTML, probably tidy it up, and then create a HTML/CSS/JS proof-of-concept directly in the HTML. Once we know what the HTML needs to look like, we can think about how to incorporate it into Julia. |
As you said, I created a HTML/CSS/JS proof-of-concept directly in HTML, Please let me know if i should change something or there is any mistake and if it is correct than what should be my next step in STEP. |
Yeah, that's a good start. I guess there is no good way to do this via pure CSS with a If we're going to do it via JS, I wonder if we can re-use the generated HTML for the footnote definitions (i.e. copy the DOM to the preview For integration:
|
I strongly feel that this feature should be primarily implemented via JS, primarily for usability and accessibility reasons. Ideally, a Documenter page should be useable in a browser without JS script (e.g., a terminal browser like Showing footnotes on hover is exactly the kind of UI sugar you'd want in a full browser. At least arguably, though, you wouldn't want footnotes inserted into the basic non-JS rendering of the page, and then appear multiple times. This applies even more so to JuliaDocs/DocumenterCitations.jl#67 Since I'd be reluctant to add JS to DocumenterCitations (at least not until we implement a way for plugins to automatically inject CSS/JS), I'd want to reuse any implementation of this footnote-hover for the citation-hover. |
It seems like we could just have a single hidden-by-default div that renders the footnote, and we copy the DOM from the real footnote into that div whenever we trigger a hover event over the footnote reference. This way we'd keep the original footnotes around on the bottom of the page. |
I added a span (hidden by default) for footnote preview and also added styling for its appropriate positioning but I am not able to get the footnote definitions in that span! |
Would have to test that on a live site, but HTML/CSS-wise I think it looks quite fine. For getting the definitions, you'd have to modify HTMLWriter some more. Currently, I think we just gather them up as we go through the tree, since we only need them at the end: It's a bit tricky, since for rendering them inline, we need to know the definitions when we encounter the reference. I'd be okay if we'd do another pre-pass through the tree before actually rendering, to gather up the definitions. That seems to be the simplest solution. |
I used JQuery instead for fetching footnote definitions from the end of page and its working fine! I opened a PR for it, let me know if any changes are required! |
I.e. something like this
Example is from a Quarto document: https://mixtape.scunning.com/02-probability_and_regression#fnref1
Would be really handy, and a nice self-contained front-end feature for someone to take on.
The text was updated successfully, but these errors were encountered: