fonsp / Pluto.jl

🎈 Simple reactive notebooks for Julia
https://plutojl.org/
MIT License
4.91k stars 284 forks source link

Make `#id` URLs work by setting the location.hash again after all cells are rendered #2789

Closed fonsp closed 5 months ago

fonsp commented 5 months ago

Now you will be able to share a URL like:

https://plutojl.org/en/docs/abstractplutodingetjes/#c3e83475-6ab0-4aa8-9a57-c2f25772cc75

Before this PR, this does not work because cells are rendered with a delay, and the UA tries to scroll to the element quickly after the page got loaded.


This PR also makes this URL work:

https://plutojl.org/en/docs/abstractplutodingetjes/#possible_values

By giving all Docs.binding displays the id of the variable name.

github-actions[bot] commented 5 months ago

Try this Pull Request!

Open Julia and type:

  julia> import Pkg
  julia> Pkg.activate(temp=true)
  julia> Pkg.add(url="https://github.com/fonsp/Pluto.jl", rev="restore-location.hash-after-load")
  julia> using Pluto
fonsp commented 5 months ago

Unfortunately this does not work with Chrome's "Copy link to this selection" feature, because the special chrome hash (#:~:text=.-,Add%20a%20comment,-Comment) is hidden from the window.location.hash, so there's nothing we can do about that.