{"id":27876916,"url":"https://github.com/ethauvin/readingtime","last_synced_at":"2025-05-05T02:53:55.276Z","repository":{"id":42123971,"uuid":"282024923","full_name":"ethauvin/readingtime","owner":"ethauvin","description":"Estimated Reading Time for Blog Posts, Articles, etc.","archived":false,"fork":false,"pushed_at":"2025-03-26T20:12:31.000Z","size":686,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T21:24:01.412Z","etag":null,"topics":["articles","blog","estimated","java","jsp","kotlin","medium","minutes","posts","read","reading","reading-time","text","time","weblog"],"latest_commit_sha":null,"homepage":"https://erik.thauvin.net/blog/posts/7867/readingtime-090","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ethauvin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.TXT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-23T18:18:14.000Z","updated_at":"2025-03-26T20:12:35.000Z","dependencies_parsed_at":"2023-11-13T01:25:24.778Z","dependency_job_id":"56d2b09c-28ad-428f-b363-6fbce89f75ed","html_url":"https://github.com/ethauvin/readingtime","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethauvin%2Freadingtime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethauvin%2Freadingtime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethauvin%2Freadingtime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethauvin%2Freadingtime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ethauvin","download_url":"https://codeload.github.com/ethauvin/readingtime/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252429952,"owners_count":21746571,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["articles","blog","estimated","java","jsp","kotlin","medium","minutes","posts","read","reading","reading-time","text","time","weblog"],"created_at":"2025-05-05T02:53:54.837Z","updated_at":"2025-05-05T02:53:55.268Z","avatar_url":"https://github.com/ethauvin.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![License (3-Clause BSD)](https://img.shields.io/badge/license-BSD%203--Clause-blue.svg?style=flat-square)](https://opensource.org/licenses/BSD-3-Clause)\n[![Kotlin](https://img.shields.io/badge/kotlin-2.1.20-7f52ff)](https://kotlinlang.org/)\n[![bld](https://img.shields.io/badge/2.2.1-FA9052?label=bld\u0026labelColor=2392FF)](https://rife2.com/bld)\n[![Release](https://img.shields.io/github/release/ethauvin/readingtime.svg)](https://github.com/ethauvin/readingtime/releases/latest)\n[![Maven Central](https://img.shields.io/maven-central/v/net.thauvin.erik/readingtime.svg?color=blue)](https://search.maven.org/search?q=g:%22net.thauvin.erik%22%20AND%20a:%22readingtime%22)\n[![Nexus Snapshot](https://img.shields.io/nexus/s/net.thauvin.erik/readingtime?label=snapshot\u0026server=https%3A%2F%2Foss.sonatype.org%2F)](https://oss.sonatype.org/content/repositories/snapshots/net/thauvin/erik/readingtime/)\n\n\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ethauvin_readingtime\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=ethauvin_readingtime)\n[![GitHub CI](https://github.com/ethauvin/readingtime/actions/workflows/bld.yml/badge.svg)](https://github.com/ethauvin/readingtime/actions/workflows/bld.yml)\n[![CircleCI](https://circleci.com/gh/ethauvin/readingtime/tree/master.svg?style=shield)](https://circleci.com/gh/ethauvin/readingtime/tree/master)\n\n# Estimated Reading Time for Blog Posts, Articles, etc.\n\nA simple implementation of [Medium's Read Time calculation](https://blog.medium.com/read-time-and-you-bc2048ab620c).\n\n## Examples (TL;DR)\n\n```kotlin\nimport net.thauvin.erik.readingtime.ReadingTime\n\n// ...\n\nval rt = ReadingTime(htmlText)\nprintln(rt.calcEstimatedReadTime()) // eg: 2 min read\n\n```\n\n- View [bld](https://github.com/ethauvin/readingtime/blob/master/examples/bld) or [Gradle](https://github.com/ethauvin/readingtime/blob/master/examples/gradle) Examples\n\nTo get the estimated reading time in seconds use the `calcReadingTimeInSec()` function.\n\n## bld\n\nTo use with [bld](https://rife2.com/bld), include the following dependency in your [build](https://github.com/ethauvin/readingtime/blob/master/examples/bld/src/bld/java/com/example/ReadingTimeExampleBuild.java) file:\n\n```java\nrepositories = List.of(MAVEN_CENTRAL);\n\nscope(compile)\n    .include(dependency(\"net.thauvin.erik:readingtime:0.9.2\"));\n```\n\nBe sure to use the [bld Kotlin extension](https://github.com/rife2/bld-kotlin) in your project.\n\n### Gradle, Maven, etc.\n\nTo use with [Gradle](https://gradle.org/), include the following dependency in your [build](https://github.com/ethauvin/readingtime/blob/master/examples/gradle/build.gradle.kts) file:\n\n```gradle\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    implementation(\"net.thauvin.erik:readingtime:0.9.2\")\n}\n```\n\nInstructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://search.maven.org/search?q=g:%22net.thauvin.erik%22%20AND%20a:%22readingtime%22).\n\n## Properties\n\nThe following properties are available:\n\n```kotlin\nReadingTime(\n    text,\n    wpm = 275,\n    postfix = \"min read\",\n    plural = \"min read\",\n    excludeImages = false, \n    extra = 0,\n    roundingMode = RoundingMode.HALF_EVEN\n)\n\n```\n\n| Property        | Description                                                                                                             |\n|:----------------|:------------------------------------------------------------------------------------------------------------------------|\n| `text`          | The text to be evaluated. (Required)                                                                                    |\n| `wpm`           | The words per minute reading average.                                                                                   |\n| `postfix`       | The value to be appended to the reading time.                                                                           |\n| `plural`        | The value to be appended if the reading time is more than 1 minute.                                                     |\n| `excludeImages` | Images are excluded from the reading time when set.                                                                     |\n| `extra`         | Additional seconds to be added to the total reading time.                                                               |\n| `roundingMode`  | The [rounding mode](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/math/RoundingMode.html) to apply. |\n\n## Functions\n\nA couple of useful functions are also available:\n\n```kotlin\nReadingTime.wordCount(htmlText) // Returns the count of words. (HTML stripped)\nReadingTime.imgCount(htmlText) // Returns the count of images. (HTML img tags)\n```\n\n## JSP\n\nA JSP tag is also available for easy incorporation into web applications:\n\n```jsp\n\u003c%@taglib uri=\"https://erik.thauvin.net/taglibs/readingtime\" prefix=\"t\"%\u003e\n\u003ct:readingtime\n    wpm=\"275\"\n    postfix=\"min read\"\n    plural=\"min read\"\n    excludeImages=\"false\"\n    extra=\"0\"\u003esome_text\u003c/t:readingtime\u003e\n```\n\nNone of the attributes are required.\n\n## Java\n\nIn addition to setters, a configuration builder is also available:\n\n```java\nfinal ReadingTime rt = new ReadingTime(text);\nrt.setPostfix(\"minute to read\");\nrt.setPlural(\"minutes to read\");\n```\n\nor\n\n```java\nfinal Config config =\n        new Config.Builder(text)\n                .postfix(\"minute to read\")\n                .plural(\"minutes to read\")\n                .build();\nfinal ReadingTime rt = new ReadingTime(config);\n```\n\n## Contributing\n\nIf you want to contribute to this project, all you have to do is clone the GitHub\nrepository:\n\n```console\ngit clone git@github.com:ethauvin/readingtime.git\n```\n\nThen use [bld](https://rife2.com/bld) to build:\n\n```console\ncd readingtime\n./bld compile\n```\n\nThe project has an [IntelliJ IDEA](https://www.jetbrains.com/idea/) project structure. You can just open it after all the dependencies were downloaded and peruse the code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethauvin%2Freadingtime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fethauvin%2Freadingtime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethauvin%2Freadingtime/lists"}