Estimated Reading Time for Blog Posts, Articles, etc. https://github.com/ethauvin/readingtime
Find a file
2020-07-24 18:01:46 -07:00
.circleci Added TravisCI and CircleCI configurations. 2020-07-23 22:52:25 -07:00
.idea Added maven publication, bintray, etc. 2020-07-23 20:55:48 -07:00
config/detekt Added detekt. 2020-07-23 10:50:52 -07:00
examples Cleanup. 2020-07-24 18:01:46 -07:00
gradle/wrapper Initial commit. 2020-07-23 01:47:35 -07:00
src Cleanup. 2020-07-23 20:56:07 -07:00
.editorconfig Initial commit. 2020-07-23 01:47:35 -07:00
.gitattributes Initial commit. 2020-07-23 01:47:35 -07:00
.gitignore Initial commit. 2020-07-23 01:47:35 -07:00
.travis.yml Added TravisCI and CircleCI configurations. 2020-07-23 22:52:25 -07:00
build.gradle.kts Added maven publication, bintray, etc. 2020-07-23 20:55:48 -07:00
gradlew Made gradlew executable in git. 2020-07-23 22:58:01 -07:00
gradlew.bat Made gradlew executable in git. 2020-07-23 22:58:01 -07:00
LICENSE.TXT Added license and copyright. 2020-07-23 11:44:43 -07:00
pom.xml Added maven publication, bintray, etc. 2020-07-23 20:55:48 -07:00
README.md Added reference to calcReadingTimeInSec() function. 2020-07-24 17:34:08 -07:00
settings.gradle.kts Initial commit. 2020-07-23 01:47:35 -07:00

License (3-Clause BSD) release Maven Central Download

Known Vulnerabilities Quality Gate Status Build Status CircleCI

Estimated Reading Time for Blog Posts, Articles, etc.

A simple Kotlin/Java implementation of Medium's Read Time calculation.

Examples (TL;DR)

import net.thauvin.erik.readingtime.ReadingTime

...

val rt = ReadingTime(htmlText)
println(rt.calcEstimatedReadTime()) // eg: 2 min read

To get the estimated reading time in seconds use the calcReadingTimeInSec() function.

Properties

The following properties are available:

ReadingTime(
    text = "sometext",
    wpm = 275,
    postfix = "min read",
    plural = "min read",
    excludeImages = false
)

Property Description
text The text to be evaluated.
wpm The words per minute reading average.
postfix The value to be appended to the reading time.
plural The value to be appended if the reading time is more than 1 minute.
excludeImages Images are excluded from the reading time when set.

Functions

A couple of useful functions are also available:

ReadingTime.wordCount(htmlText) // Returns the count of words. (HTML stripped)
ReadingTime.imgCount(htmlText) // Returns the count of images. (img HTML tags)

Gradle

To use with Gradle, include the following dependency in your build file:

repositories {
    jcenter()
}

dependencies {
    implementation("net.thauvin.erik:readingtime:0.9.0")
}