Skip to content

Conversation

damourChris
Copy link

A new widget for showing the estimated reading time of all the markdown output in a Pluto Notebook

A few notes:

  • This only reads the markdown output of cells
  • I am not a fan of the style, especially the floating one in the corner but this as of now stands more as a prototype
  • I inspired the code based on TableOfContents.jl so hope this is the "pluto" way.
  • Mostly JS as the reader updates the word count everytime cells update

Motivation:

I started to write some long notebooks (quite text heavy) and I wanted to show an estimate of the reading time and I was inspired by the "reading time" extensions that you find in some blog websites framework

If this is that is interesting I'd be happy to try and make it prettier or try to incoporate a more complete time estimation by including other stuff like lines of code or smth

Let me know :))

aim to add an indication of the approximate reading time

this is only for the markdown output of cells
Copy link

Try this Pull Request!

Open Julia and type:

julia> import Pkg
julia> Pkg.activate(temp=true)
julia> Pkg.add(url="https://github.com/damourChris/PlutoUI.jl", rev="feat/reading-time")
julia> using PlutoUI

Or run this code in your browser: Run with binder

@fonsp
Copy link
Member

fonsp commented Sep 1, 2025

Wow this is awesome, and the implementation is super good!! Congrats! I would be very happy to merge this 🌟🌟🌟🌟🌟 Thanks so much!

…ver system, global state management, and content extraction utilities

- Introduce a global state management system for reading time instances.
- Implement a  DOM observer system to monitor changes in the notebook and cells.
- content extraction methods to accurately count words from markdown, HTML, and Julia code.
- Improved the style
@damourChris
Copy link
Author

Thanks!!
Made a few changes to styles and made it prettier and more accessible
Also updated the implementation to use a singleton approache cos if you ended up using multiple cells you could quickly overload the notebook and hang the whole noteobok

I got lost in trying to parse input code, and realised that Pluto lazy loads the input cells so wasnt accurate, if there a way to get the code inputs ahead of time that would be great, but it would probaly impact perfomance so probably not worth it. Maybe something that can live on the server?

I'll can go make a PR for the PlutoUI featured notebook to add some docs if needed

Everything should be ready now!
🌟🌟🌟

@damourChris damourChris marked this pull request as ready for review September 2, 2025 17:32
also remove some comments and fixing some indentation
everything was in different cell blokcs and now are all in one
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants