Home

Awesome

reading_time

A Liquid filter that intelligently counts the number of words in a piece of HTML and estimates how long the text will take to read.

Installation

The easiest way to install this plugin is with RubyGems: gem install liquid_reading_time.

If you’re using Jekyll, see the Jekyll documentation on installing plugins for more-detailed installation instructions. This plugin requires Nokogiri, so if you install this one manually you’ll need to make sure that that one is installed too.

Usage

Two functions are provided:

Details

These functions try to be smart about counting words. Specifically, words are not counted if they are contained within any of the following HTML elements: area, audio, canvas, code, embed, footer, form, img, map, math, nav, object, pre, script, svg, table, track, and video. My intention here is to prevent words from contributing toward the count if they don’t seem to be part of the running text—contrast this with the simple but inaccurate approach of e.g. Jekyll’s built-in number_of_words.

The plugin assumes a reading speed of 270 words per minute. Wikipedia cites 250–300 words per minute as a typical range, and I found that I could read articles on my website at about 270 words per minute.

Author

This plugin was created by Benjamin Esham.

This project is hosted on GitHub. Please feel free to submit pull requests.

Version history

The version numbers of this project conform to Semantic Versioning 2.0.

License

Copyright © 2013, 2015, 2017 Benjamin D. Esham. This program is released under the ISC license, which you can find in the file LICENSE.md.